Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions eng/Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
<ProjectToBuild Include="$(RepoRoot)tests\**\*.csproj" Condition="'$(SkipTestProjects)' != 'true'" />
</ItemGroup>

<!-- Extension build project -->
<ItemGroup Condition="'$(BuildExtension)' == 'true'">
<ProjectToBuild Include="$(RepoRoot)extension\Extension.proj" />
</ItemGroup>

<!-- Native build only -->
<ItemGroup Condition="'$(SkipNativeBuild)' != 'true'">
<!-- Add Aspire.Cli project here for native-only builds so it gets picked
Expand Down
2 changes: 2 additions & 0 deletions eng/Signing.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<FileExtensionSignInfo Update=".nupkg" CertificateName="NuGet" />
<FileExtensionSignInfo Update=".zip" CertificateName="None" />
<FileExtensionSignInfo Update=".js" CertificateName="MicrosoftDotNet500" />
<FileExtensionSignInfo Update=".vsix" CertificateName="VsixSHA2" />

<!-- add missing entry for .msi, this can be removed once aspire uses arcade 10.0 -->
<FileExtensionSignInfo Include=".msi" CertificateName="MicrosoftDotNet500" Condition="!@(FileExtensionSignInfo->AnyHaveMetadataValue('Identity', '.msi'))" />
Expand Down Expand Up @@ -54,6 +55,7 @@
<ItemsToSign Include="$(VisualStudioSetupInsertionPath)\**\*.zip" Condition="'$(PostBuildSign)' != 'true'" />
<ItemsToSign Include="$(ArtifactsPackagesDir)**\aspire-cli-*.zip" />
<ItemsToSign Include="$(ArtifactsPackagesDir)**\aspire-cli-*.tar.gz" />
<ItemsToSign Include="$(ArtifactsPackagesDir)**\aspire-vscode-*.vsix" />
<ItemsToSignPostBuild Include="$(VisualStudioSetupInsertionPath)\**\*.zip" Condition="'$(PostBuildSign)' == 'true'" />
</ItemGroup>
</Project>
80 changes: 1 addition & 79 deletions eng/common/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -98,81 +98,7 @@ function InitializeCustomToolset {
}
}

function Build-Extension {
$extensionDir = Join-Path $RepoRoot 'extension'
if (-not (Test-Path $extensionDir)) {
Write-Host "Extension directory not found at $extensionDir, skipping extension build"
return
}

Write-Host "Building VS Code extension..."

# Check if yarn is available
try {
$yarnVersion = & yarn --version 2>$null
if ($LASTEXITCODE -ne 0) {
throw "Yarn not found"
}
Write-Host "Found yarn version: $yarnVersion"
}
catch {
Write-Host "Warning: yarn is not installed or not available in PATH. Skipping extension build."
Write-Host "To build the extension, install yarn: https://yarnpkg.com/getting-started/install"
return
}

Push-Location $extensionDir
try {
Write-Host "Running yarn install..."
& yarn install
if ($LASTEXITCODE -ne 0) {
throw "yarn install failed with exit code $LASTEXITCODE"
}

Write-Host "Running yarn compile..."
& yarn compile
if ($LASTEXITCODE -ne 0) {
throw "yarn compile failed with exit code $LASTEXITCODE"
}

# Check if vsce is available and package the extension
try {
$vsceVersion = & vsce --version 2>$null
if ($LASTEXITCODE -eq 0) {
Write-Host "Found vsce version: $vsceVersion"

# Read version from package.json
$packageJsonPath = Join-Path $extensionDir 'package.json'
if (Test-Path $packageJsonPath) {
Write-Host "Packaging extension"
& vsce package --pre-release
if ($LASTEXITCODE -ne 0) {
throw "vsce package failed with exit code $LASTEXITCODE"
}

Write-Host "Extension packaged successfully"
} else {
Write-Host "Warning: package.json not found, skipping vsce package"
}
} else {
Write-Host "vsce not found, skipping package step"
}
}
catch {
Write-Host "Warning: Failed to package extension with vsce: $_"
# Don't throw here, just warn since this is optional
}

Write-Host "VS Code extension build completed successfully"
}
catch {
Write-Host "Error building VS Code extension: $_"
throw
}
finally {
Pop-Location
}
}

function Build {
$toolsetBuildProj = InitializeToolset
Expand Down Expand Up @@ -214,12 +140,8 @@ function Build {
/p:Sign=$sign `
/p:Publish=$publish `
/p:RestoreStaticGraphEnableBinaryLogger=$binaryLog `
/p:BuildExtension=$buildExtension `
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file (and build.sh) shouldn't have been changed for this, as we shouldn't touch files under eng\common. Those get overwritten by arcade each time we update, so this shouldn't be modified, and instead we should change the files under eng\build.ps1/sh. Last night we took an arcade update which broke the build as these scripts where replaced.

cc: @adamint @radical
Fyi: @davidfowl who was asking about this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed that up in the update-arcade Pr.

@properties

# Build VS Code extension if buildExtension parameter is specified
if ($buildExtension) {
Build-Extension
}
}

try {
Expand Down
66 changes: 1 addition & 65 deletions eng/common/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -226,67 +226,7 @@ function InitializeCustomToolset {
fi
}

function Build-Extension {
local extension_dir="$repo_root/extension"
if [[ ! -d "$extension_dir" ]]; then
echo "Extension directory not found at $extension_dir, skipping extension build"
return
fi

echo "Building VS Code extension..."

# Check if yarn is available
if ! command -v yarn &> /dev/null; then
echo "Warning: yarn is not installed or not available in PATH. Skipping extension build."
echo "To build the extension, install yarn: https://yarnpkg.com/getting-started/install"
return
fi

local yarn_version
yarn_version=$(yarn --version 2>/dev/null)
echo "Found yarn version: $yarn_version"

pushd "$extension_dir" > /dev/null

echo "Running yarn install..."
if ! yarn install; then
echo "Error: yarn install failed"
popd > /dev/null
ExitWithExitCode 1
fi

echo "Running yarn compile..."
if ! yarn compile; then
echo "Error: yarn compile failed"
popd > /dev/null
ExitWithExitCode 1
fi

# Check if vsce is available and package the extension
if command -v vsce &> /dev/null; then
local vsce_version
vsce_version=$(vsce --version 2>/dev/null)
echo "Found vsce version: $vsce_version"

# Read version from package.json
local package_json_path="$extension_dir/package.json"
if [[ -f "$package_json_path" ]]; then
echo "Packaging extension"
if vsce package --pre-release; then
echo "Extension packaged successfully"
else
echo "Warning: vsce package failed"
fi
else
echo "Warning: package.json not found, skipping vsce package"
fi
else
echo "vsce not found, skipping package step"
fi

echo "VS Code extension build completed successfully"
popd > /dev/null
}

function Build {
InitializeToolset
Expand Down Expand Up @@ -324,13 +264,9 @@ function Build {
/p:Sign=$sign \
/p:Publish=$publish \
/p:RestoreStaticGraphEnableBinaryLogger=$binary_log \
/p:BuildExtension=$build_extension \
${properties[@]+"${properties[@]}"}

# Build VS Code extension if build-extension parameter is specified
if [[ "$build_extension" == true ]]; then
Build-Extension
fi

ExitWithExitCode 0
}

Expand Down
23 changes: 23 additions & 0 deletions eng/pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,29 @@ extends:
script: |
Get-ChildItem -Path "$(Build.SourcesDirectory)\artifacts\packages" -File -Recurse | Select-Object FullName, @{Name="Size(MB)";Expression={[math]::Round($_.Length/1MB,2)}} | Format-Table -AutoSize
- task: NodeTool@0
displayName: 🟣Install node.js
inputs:
versionSpec: '20.x'

- task: PowerShell@2
displayName: 🟣Install yarn
inputs:
targetType: 'inline'
script: |
npm install -g yarn
yarn --version
workingDirectory: '$(Build.SourcesDirectory)'

- task: PowerShell@2
displayName: 🟣Install vsce
inputs:
targetType: 'inline'
script: |
npm install -g @vscode/vsce
vsce --version
workingDirectory: '$(Build.SourcesDirectory)'

- template: /eng/pipelines/templates/BuildAndTest.yml
parameters:
dotnetScript: $(Build.SourcesDirectory)/dotnet.cmd
Expand Down
8 changes: 8 additions & 0 deletions eng/pipelines/templates/BuildAndTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ steps:
-restore -build
-pack
-sign $(_SignArgs)
-buildExtension
-publish $(_PublishArgs)
-configuration ${{ parameters.buildConfig }}
/bl:${{ parameters.repoLogPath }}/build.binlog
Expand All @@ -45,6 +46,13 @@ steps:
/p:SkipTestProjects=true
displayName: 🟣Build

- task: 1ES.PublishBuildArtifacts@1
displayName: 🟣Publish vscode extension
condition: always()
inputs:
PathtoPublish: '${{ parameters.repoArtifactsPath }}/packages/Release/vscode'
ArtifactName: aspire-vscode-extension

- script: ${{ parameters.dotnetScript }}
build
tests/workloads.proj
Expand Down
58 changes: 58 additions & 0 deletions extension/Extension.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
<ExtensionSrcDir>$(MSBuildThisFileDirectory)</ExtensionSrcDir>
</PropertyGroup>

<Target Name="BuildAndPackageExtension" BeforeTargets="Build" DependsOnTargets="CheckYarnInstalled;CheckVsceInstalled">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future PRs it would be useful to add Inputs/Outputs to the targets, so this can be skipped on incremental builds. It would be useful if you are doing it locally.

<PropertyGroup>
<_PackageJsonPath>$([MSBuild]::NormalizePath($(ExtensionSrcDir), 'package.json'))</_PackageJsonPath>
<_VsixPath>$([MSBuild]::NormalizePath($(ArtifactsPackagesDir), 'aspire-vscode-$(Version).vsix'))</_VsixPath>
</PropertyGroup>

<Error Text="$(_PackageJsonPath) not found. Cannot package the extension." Condition="!Exists('$(_PackageJsonPath)')" />

<!-- Extract version from package.json using Node.js -->
<Exec Command="node -p &quot;require('./package.json').version&quot;"
ConsoleToMSBuild="true"
IgnoreStandardErrorWarningFormat="true"
WorkingDirectory="$(ExtensionSrcDir)">
<Output TaskParameter="ConsoleOutput" PropertyName="_ExtractedVersion" />
</Exec>

<!-- Install dependencies and compile -->
<Exec Command="yarn install" WorkingDirectory="$(ExtensionSrcDir)" IgnoreStandardErrorWarningFormat="true" />
<Exec Command="yarn compile" WorkingDirectory="$(ExtensionSrcDir)" IgnoreStandardErrorWarningFormat="true" />

<!-- Make extension directory -->
<MakeDir Directories="$(ArtifactsPackagesDir)\vscode" />

<!-- Package extension -->
<Exec Command="vsce package --pre-release --out $(ArtifactsPackagesDir)\vscode\aspire-vscode-$(_ExtractedVersion).vsix"
IgnoreStandardErrorWarningFormat="true"
WorkingDirectory="$(ExtensionSrcDir)" />
</Target>

<Target Name="CheckYarnInstalled">
<Exec Command="yarn --version" ContinueOnError="true" ConsoleToMSBuild="true" IgnoreStandardErrorWarningFormat="true">
<Output TaskParameter="ExitCode" PropertyName="YarnExitCode" />
<Output TaskParameter="ConsoleOutput" PropertyName="YarnVersion" />
</Exec>

<Error Condition="'$(YarnExitCode)' != '0'" Text="yarn is not installed or not available in PATH. To build the extension, install yarn: https://yarnpkg.com/getting-started/install" />

<Message Importance="high" Text="yarn version: $(YarnVersion)" />
</Target>

<Target Name="CheckVsceInstalled">
<Exec Command="vsce --version" ContinueOnError="true" ConsoleToMSBuild="true" IgnoreStandardErrorWarningFormat="true">
<Output TaskParameter="ExitCode" PropertyName="VsceExitCode" />
<Output TaskParameter="ConsoleOutput" PropertyName="VsceVersion" />
</Exec>

<Error Condition="'$(VsceExitCode)' != '0'" Text="vsce is not installed or not available in PATH. To build the extension, install vsce: npm install -g vsce" />

<Message Text="Found vsce version: $(VsceVersion)" />
</Target>

</Project>
1 change: 0 additions & 1 deletion extension/loc/.gitignore

This file was deleted.

Loading