Skip to content

Commit ad07d53

Browse files
adamintradical
andauthored
Set up extension build and sign pipeline (#11504)
* first try extension CI * move above other stages * install vsce globally before package * explicitly publish extension * try add signing * try #2 * Revert "try #2" This reverts commit 8006a85. * try to fix sign * try with artifacts packages dir property * remove verification * clean up * pr suggestions * run stages in parallel * see if this runs in parallel * add restore back * rename binlog * remove extra upload step * Move building extension to msbuild from the scripts. And always build extension on the internal pipeline * fix typo * fix build * Don't try to parse errors and warnings from yarn/npm invocations. Only use the exit code to determine success or failure * try publishing vsix * update paths * update paths 2 * Revert "update paths 2" This reverts commit e178308. * fix path to publish..? --------- Co-authored-by: Ankit Jain <radical@gmail.com>
1 parent 2f7aeda commit ad07d53

File tree

8 files changed

+98
-145
lines changed

8 files changed

+98
-145
lines changed

eng/Build.props

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
<ProjectToBuild Include="$(RepoRoot)tests\**\*.csproj" Condition="'$(SkipTestProjects)' != 'true'" />
2424
</ItemGroup>
2525

26+
<!-- Extension build project -->
27+
<ItemGroup Condition="'$(BuildExtension)' == 'true'">
28+
<ProjectToBuild Include="$(RepoRoot)extension\Extension.proj" />
29+
</ItemGroup>
30+
2631
<!-- Native build only -->
2732
<ItemGroup Condition="'$(SkipNativeBuild)' != 'true'">
2833
<!-- Add Aspire.Cli project here for native-only builds so it gets picked

eng/Signing.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<FileExtensionSignInfo Update=".nupkg" CertificateName="NuGet" />
55
<FileExtensionSignInfo Update=".zip" CertificateName="None" />
66
<FileExtensionSignInfo Update=".js" CertificateName="MicrosoftDotNet500" />
7+
<FileExtensionSignInfo Update=".vsix" CertificateName="VsixSHA2" />
78

89
<!-- add missing entry for .msi, this can be removed once aspire uses arcade 10.0 -->
910
<FileExtensionSignInfo Include=".msi" CertificateName="MicrosoftDotNet500" Condition="!@(FileExtensionSignInfo->AnyHaveMetadataValue('Identity', '.msi'))" />
@@ -54,6 +55,7 @@
5455
<ItemsToSign Include="$(VisualStudioSetupInsertionPath)\**\*.zip" Condition="'$(PostBuildSign)' != 'true'" />
5556
<ItemsToSign Include="$(ArtifactsPackagesDir)**\aspire-cli-*.zip" />
5657
<ItemsToSign Include="$(ArtifactsPackagesDir)**\aspire-cli-*.tar.gz" />
58+
<ItemsToSign Include="$(ArtifactsPackagesDir)**\aspire-vscode-*.vsix" />
5759
<ItemsToSignPostBuild Include="$(VisualStudioSetupInsertionPath)\**\*.zip" Condition="'$(PostBuildSign)' == 'true'" />
5860
</ItemGroup>
5961
</Project>

eng/common/build.ps1

Lines changed: 1 addition & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -98,81 +98,7 @@ function InitializeCustomToolset {
9898
}
9999
}
100100

101-
function Build-Extension {
102-
$extensionDir = Join-Path $RepoRoot 'extension'
103-
if (-not (Test-Path $extensionDir)) {
104-
Write-Host "Extension directory not found at $extensionDir, skipping extension build"
105-
return
106-
}
107-
108-
Write-Host "Building VS Code extension..."
109-
110-
# Check if yarn is available
111-
try {
112-
$yarnVersion = & yarn --version 2>$null
113-
if ($LASTEXITCODE -ne 0) {
114-
throw "Yarn not found"
115-
}
116-
Write-Host "Found yarn version: $yarnVersion"
117-
}
118-
catch {
119-
Write-Host "Warning: yarn is not installed or not available in PATH. Skipping extension build."
120-
Write-Host "To build the extension, install yarn: https://yarnpkg.com/getting-started/install"
121-
return
122-
}
123-
124-
Push-Location $extensionDir
125-
try {
126-
Write-Host "Running yarn install..."
127-
& yarn install
128-
if ($LASTEXITCODE -ne 0) {
129-
throw "yarn install failed with exit code $LASTEXITCODE"
130-
}
131-
132-
Write-Host "Running yarn compile..."
133-
& yarn compile
134-
if ($LASTEXITCODE -ne 0) {
135-
throw "yarn compile failed with exit code $LASTEXITCODE"
136-
}
137101

138-
# Check if vsce is available and package the extension
139-
try {
140-
$vsceVersion = & vsce --version 2>$null
141-
if ($LASTEXITCODE -eq 0) {
142-
Write-Host "Found vsce version: $vsceVersion"
143-
144-
# Read version from package.json
145-
$packageJsonPath = Join-Path $extensionDir 'package.json'
146-
if (Test-Path $packageJsonPath) {
147-
Write-Host "Packaging extension"
148-
& vsce package --pre-release
149-
if ($LASTEXITCODE -ne 0) {
150-
throw "vsce package failed with exit code $LASTEXITCODE"
151-
}
152-
153-
Write-Host "Extension packaged successfully"
154-
} else {
155-
Write-Host "Warning: package.json not found, skipping vsce package"
156-
}
157-
} else {
158-
Write-Host "vsce not found, skipping package step"
159-
}
160-
}
161-
catch {
162-
Write-Host "Warning: Failed to package extension with vsce: $_"
163-
# Don't throw here, just warn since this is optional
164-
}
165-
166-
Write-Host "VS Code extension build completed successfully"
167-
}
168-
catch {
169-
Write-Host "Error building VS Code extension: $_"
170-
throw
171-
}
172-
finally {
173-
Pop-Location
174-
}
175-
}
176102

177103
function Build {
178104
$toolsetBuildProj = InitializeToolset
@@ -214,12 +140,8 @@ function Build {
214140
/p:Sign=$sign `
215141
/p:Publish=$publish `
216142
/p:RestoreStaticGraphEnableBinaryLogger=$binaryLog `
143+
/p:BuildExtension=$buildExtension `
217144
@properties
218-
219-
# Build VS Code extension if buildExtension parameter is specified
220-
if ($buildExtension) {
221-
Build-Extension
222-
}
223145
}
224146

225147
try {

eng/common/build.sh

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -226,67 +226,7 @@ function InitializeCustomToolset {
226226
fi
227227
}
228228

229-
function Build-Extension {
230-
local extension_dir="$repo_root/extension"
231-
if [[ ! -d "$extension_dir" ]]; then
232-
echo "Extension directory not found at $extension_dir, skipping extension build"
233-
return
234-
fi
235-
236-
echo "Building VS Code extension..."
237-
238-
# Check if yarn is available
239-
if ! command -v yarn &> /dev/null; then
240-
echo "Warning: yarn is not installed or not available in PATH. Skipping extension build."
241-
echo "To build the extension, install yarn: https://yarnpkg.com/getting-started/install"
242-
return
243-
fi
244-
245-
local yarn_version
246-
yarn_version=$(yarn --version 2>/dev/null)
247-
echo "Found yarn version: $yarn_version"
248-
249-
pushd "$extension_dir" > /dev/null
250-
251-
echo "Running yarn install..."
252-
if ! yarn install; then
253-
echo "Error: yarn install failed"
254-
popd > /dev/null
255-
ExitWithExitCode 1
256-
fi
257229

258-
echo "Running yarn compile..."
259-
if ! yarn compile; then
260-
echo "Error: yarn compile failed"
261-
popd > /dev/null
262-
ExitWithExitCode 1
263-
fi
264-
265-
# Check if vsce is available and package the extension
266-
if command -v vsce &> /dev/null; then
267-
local vsce_version
268-
vsce_version=$(vsce --version 2>/dev/null)
269-
echo "Found vsce version: $vsce_version"
270-
271-
# Read version from package.json
272-
local package_json_path="$extension_dir/package.json"
273-
if [[ -f "$package_json_path" ]]; then
274-
echo "Packaging extension"
275-
if vsce package --pre-release; then
276-
echo "Extension packaged successfully"
277-
else
278-
echo "Warning: vsce package failed"
279-
fi
280-
else
281-
echo "Warning: package.json not found, skipping vsce package"
282-
fi
283-
else
284-
echo "vsce not found, skipping package step"
285-
fi
286-
287-
echo "VS Code extension build completed successfully"
288-
popd > /dev/null
289-
}
290230

291231
function Build {
292232
InitializeToolset
@@ -324,13 +264,9 @@ function Build {
324264
/p:Sign=$sign \
325265
/p:Publish=$publish \
326266
/p:RestoreStaticGraphEnableBinaryLogger=$binary_log \
267+
/p:BuildExtension=$build_extension \
327268
${properties[@]+"${properties[@]}"}
328269

329-
# Build VS Code extension if build-extension parameter is specified
330-
if [[ "$build_extension" == true ]]; then
331-
Build-Extension
332-
fi
333-
334270
ExitWithExitCode 0
335271
}
336272

eng/pipelines/azure-pipelines.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,29 @@ extends:
224224
script: |
225225
Get-ChildItem -Path "$(Build.SourcesDirectory)\artifacts\packages" -File -Recurse | Select-Object FullName, @{Name="Size(MB)";Expression={[math]::Round($_.Length/1MB,2)}} | Format-Table -AutoSize
226226
227+
- task: NodeTool@0
228+
displayName: 🟣Install node.js
229+
inputs:
230+
versionSpec: '20.x'
231+
232+
- task: PowerShell@2
233+
displayName: 🟣Install yarn
234+
inputs:
235+
targetType: 'inline'
236+
script: |
237+
npm install -g yarn
238+
yarn --version
239+
workingDirectory: '$(Build.SourcesDirectory)'
240+
241+
- task: PowerShell@2
242+
displayName: 🟣Install vsce
243+
inputs:
244+
targetType: 'inline'
245+
script: |
246+
npm install -g @vscode/vsce
247+
vsce --version
248+
workingDirectory: '$(Build.SourcesDirectory)'
249+
227250
- template: /eng/pipelines/templates/BuildAndTest.yml
228251
parameters:
229252
dotnetScript: $(Build.SourcesDirectory)/dotnet.cmd

eng/pipelines/templates/BuildAndTest.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ steps:
3636
-restore -build
3737
-pack
3838
-sign $(_SignArgs)
39+
-buildExtension
3940
-publish $(_PublishArgs)
4041
-configuration ${{ parameters.buildConfig }}
4142
/bl:${{ parameters.repoLogPath }}/build.binlog
@@ -45,6 +46,13 @@ steps:
4546
/p:SkipTestProjects=true
4647
displayName: 🟣Build
4748

49+
- task: 1ES.PublishBuildArtifacts@1
50+
displayName: 🟣Publish vscode extension
51+
condition: always()
52+
inputs:
53+
PathtoPublish: '${{ parameters.repoArtifactsPath }}/packages/Release/vscode'
54+
ArtifactName: aspire-vscode-extension
55+
4856
- script: ${{ parameters.dotnetScript }}
4957
build
5058
tests/workloads.proj

extension/Extension.proj

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<Project Sdk="Microsoft.Build.NoTargets">
2+
<PropertyGroup>
3+
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
4+
<ExtensionSrcDir>$(MSBuildThisFileDirectory)</ExtensionSrcDir>
5+
</PropertyGroup>
6+
7+
<Target Name="BuildAndPackageExtension" BeforeTargets="Build" DependsOnTargets="CheckYarnInstalled;CheckVsceInstalled">
8+
<PropertyGroup>
9+
<_PackageJsonPath>$([MSBuild]::NormalizePath($(ExtensionSrcDir), 'package.json'))</_PackageJsonPath>
10+
<_VsixPath>$([MSBuild]::NormalizePath($(ArtifactsPackagesDir), 'aspire-vscode-$(Version).vsix'))</_VsixPath>
11+
</PropertyGroup>
12+
13+
<Error Text="$(_PackageJsonPath) not found. Cannot package the extension." Condition="!Exists('$(_PackageJsonPath)')" />
14+
15+
<!-- Extract version from package.json using Node.js -->
16+
<Exec Command="node -p &quot;require('./package.json').version&quot;"
17+
ConsoleToMSBuild="true"
18+
IgnoreStandardErrorWarningFormat="true"
19+
WorkingDirectory="$(ExtensionSrcDir)">
20+
<Output TaskParameter="ConsoleOutput" PropertyName="_ExtractedVersion" />
21+
</Exec>
22+
23+
<!-- Install dependencies and compile -->
24+
<Exec Command="yarn install" WorkingDirectory="$(ExtensionSrcDir)" IgnoreStandardErrorWarningFormat="true" />
25+
<Exec Command="yarn compile" WorkingDirectory="$(ExtensionSrcDir)" IgnoreStandardErrorWarningFormat="true" />
26+
27+
<!-- Make extension directory -->
28+
<MakeDir Directories="$(ArtifactsPackagesDir)\vscode" />
29+
30+
<!-- Package extension -->
31+
<Exec Command="vsce package --pre-release --out $(ArtifactsPackagesDir)\vscode\aspire-vscode-$(_ExtractedVersion).vsix"
32+
IgnoreStandardErrorWarningFormat="true"
33+
WorkingDirectory="$(ExtensionSrcDir)" />
34+
</Target>
35+
36+
<Target Name="CheckYarnInstalled">
37+
<Exec Command="yarn --version" ContinueOnError="true" ConsoleToMSBuild="true" IgnoreStandardErrorWarningFormat="true">
38+
<Output TaskParameter="ExitCode" PropertyName="YarnExitCode" />
39+
<Output TaskParameter="ConsoleOutput" PropertyName="YarnVersion" />
40+
</Exec>
41+
42+
<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" />
43+
44+
<Message Importance="high" Text="yarn version: $(YarnVersion)" />
45+
</Target>
46+
47+
<Target Name="CheckVsceInstalled">
48+
<Exec Command="vsce --version" ContinueOnError="true" ConsoleToMSBuild="true" IgnoreStandardErrorWarningFormat="true">
49+
<Output TaskParameter="ExitCode" PropertyName="VsceExitCode" />
50+
<Output TaskParameter="ConsoleOutput" PropertyName="VsceVersion" />
51+
</Exec>
52+
53+
<Error Condition="'$(VsceExitCode)' != '0'" Text="vsce is not installed or not available in PATH. To build the extension, install vsce: npm install -g vsce" />
54+
55+
<Message Text="Found vsce version: $(VsceVersion)" />
56+
</Target>
57+
58+
</Project>

extension/loc/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)