-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* pipeline and stages * modularize build steps
- Loading branch information
Showing
5 changed files
with
495 additions
and
360 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,389 @@ | ||
steps: | ||
# Clone TestWinRT | ||
- task: CmdLine@2 | ||
displayName: Clone TestWinRT | ||
enabled: false | ||
inputs: | ||
script: get_testwinrt.cmd | ||
workingDirectory: $(Build.SourcesDirectory) | ||
|
||
# Download procdump | ||
- task: PowerShell@2 | ||
displayName: Download procdump | ||
enabled: false | ||
inputs: | ||
targetType: inline | ||
script: | | ||
mkdir $env:Agent_TempDirectory\procdump | ||
Invoke-WebRequest -Uri https://download.sysinternals.com/files/Procdump.zip -OutFile $env:Agent_TempDirectory\procdump\Procdump.zip | ||
Expand-Archive -Path $env:Agent_TempDirectory\procdump\Procdump.zip $env:Agent_TempDirectory\procdump\ | ||
set PROCDUMP_PATH=$env:Agent_TempDirectory\procdump\ | ||
Write-Host ##vso[task.setvariable variable=PATH;]${env:Agent_TempDirectory}\procdump;${env:PATH}; | ||
# Use .NET Core SDK 2.1 | ||
- task: UseDotNet@2 | ||
displayName: Use .NET Core SDK 2.1 | ||
inputs: | ||
version: 2.1.x | ||
installationPath: C:\Users\VssAdministrator\AppData\Local\Microsoft\dotnet\ | ||
performMultiLevelLookup: true | ||
|
||
# Install .NET 5 SDK | ||
- task: PowerShell@2 | ||
displayName: Install .NET 5 SDK | ||
inputs: | ||
targetType: inline | ||
failOnStderr: true | ||
script: | | ||
Write-Host ##vso[task.setvariable variable=PATH;]${env:LocalAppData}\Microsoft\dotnet;${env:PATH}; | ||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; | ||
&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version "$($env:NET5_SDK_VERSION)" -Architecture "x64" -AzureFeed "$($env:NET5_SDK_FEED)" | ||
# Install .NET 6 SDK | ||
- task: PowerShell@2 | ||
displayName: Install .NET 6 SDK | ||
inputs: | ||
targetType: inline | ||
failOnStderr: true | ||
script: | | ||
Write-Host ##vso[task.setvariable variable=PATH;]${env:LocalAppData}\Microsoft\dotnet;${env:PATH}; | ||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; | ||
dotnet new globaljson --sdk-version "$($env:NET6_SDK_VERSION)" | ||
&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version "$($env:NET6_SDK_VERSION)" -Architecture "x64" -AzureFeed "$($env:NET5_SDK_FEED)" | ||
# Verify .NET SDK | ||
- task: CmdLine@2 | ||
displayName: Verify .NET SDK | ||
inputs: | ||
workingDirectory: $(Build.SourcesDirectory) | ||
script: | | ||
where dotnet | ||
dotnet --info | ||
# Parse Version | ||
- task: CmdLine@2 | ||
displayName: Parse Version | ||
inputs: | ||
workingDirectory: $(Build.SourcesDirectory) | ||
script: | | ||
rem Parse the build-generated Build.BuildNumber into components that | ||
rem can be recombined for version resources, nuget packages, etc. | ||
@echo off | ||
rem Encode the build date/rev into a 16 bit value for resource versions | ||
if "$(PrereleaseVersion)"=="" ( | ||
set RevisionBase=30000 | ||
) else ( | ||
set RevisionBase=0 | ||
) | ||
for /f "tokens=4,5 delims=." %%i in ("$(Build.BuildNumber)") do set BuildMetadata=%%i.%%j & set /a BuildRevision=%RevisionBase%+(((%%i/10000)-20)*366+((%%i)%%10000)/100*31+((%%i)%%100))*10+%%j | ||
set VersionNumber=$(MajorVersion).$(MinorVersion).$(PatchVersion).%BuildRevision% | ||
if "$(PrereleaseVersion)"=="" ( | ||
set NugetVersion=$(MajorVersion).$(MinorVersion).$(PatchVersion) | ||
) else ( | ||
set NugetVersion=$(Build.BuildNumber) | ||
) | ||
rem Export generated version numbers back for subsequent tasks | ||
echo ##vso[task.setvariable variable=BuildMetadata;]%BuildMetadata% | ||
echo ##vso[task.setvariable variable=BuildRevision;]%BuildRevision% | ||
echo ##vso[task.setvariable variable=VersionNumber;]%VersionNumber% | ||
echo ##vso[task.setvariable variable=NugetVersion;]%NugetVersion% | ||
# Build Prerelease Targets | ||
- task: CmdLine@2 | ||
displayName: Build Prerelease Targets | ||
inputs: | ||
workingDirectory: $(Build.SourcesDirectory) | ||
script: | | ||
if "$(PrereleaseVersion)"=="" goto :eof | ||
set prerelease_targets=nuget\Microsoft.Windows.CsWinRT.Prerelease.targets | ||
echo ^<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="CsWinRTVerifyPrerelease"^> > %prerelease_targets% | ||
echo ^<Target Name="CsWinRTVerifyPrerelease" >> %prerelease_targets% | ||
echo Condition=" '$(NetCoreSdkVersion)' ^!= '$($env:NET5_SDK_VERSION)' and '$(Net5SdkVersion)' ^!= '$($env:NET5_SDK_VERSION)' "^> >> %prerelease_targets% | ||
echo ^<Warning Text="This C#/WinRT prerelease is designed for .Net SDK $($env:NET5_SDK_VERSION). Other versions may be incompatible due to breaking changes." /^> >> %prerelease_targets% | ||
echo ^</Target^> >> %prerelease_targets% | ||
echo ^</Project^> >> %prerelease_targets% | ||
# Build Tool | ||
- task: CmdLine@2 | ||
displayName: Build Tool | ||
inputs: | ||
workingDirectory: $(Build.SourcesDirectory)\src | ||
script: | | ||
if "%VSCMD_VER%"=="" ( | ||
pushd c: | ||
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" >nul 2>&1 | ||
popd | ||
) | ||
set cswinrt_echo=on | ||
set cswinrt_build_only=true | ||
rem PDBs being copied for each project reference are causing out of disk space issues in the pipeline. Making use of AllowedReferenceRelatedFileExtensions to avoid them being copied. | ||
set cswinrt_build_params=/bl:$(Build.SourcesDirectory)\cswinrt.binlog /p:CleanIntermediateDirs=true /p:AllowedReferenceRelatedFileExtensions=".xml;.pri;.dll.config;.exe.config" | ||
build.cmd $(BuildPlatform) $(BuildConfiguration) $(VersionNumber) $(Build.BuildNumber) $(WinRT.Runtime.AssemblyVersion) | ||
# Mask BuildConfiguration | ||
- task: CmdLine@2 | ||
displayName: Mask BuildConfiguration | ||
enabled: False | ||
inputs: | ||
script: | | ||
@echo off | ||
rem Although BuildConfiguration is PipelineRelease or PipelineDebug, the build outputs still go to Release or Debug | ||
rem change BuildConfiguration variable so staging succeeds | ||
rem the alternative would be to add configuration property for Pipeline* to every project in cswinrt.sln | ||
if "$(BuildConfiguration)"=="PipelineRelease" ( | ||
set NewBuildConfiguration=Release | ||
) else if "$(BuildConfiguration)"=="PipelineDebug" ( | ||
set NewBuildConfiguration=Debug | ||
) | ||
if "%NewBuildConfiguration%"!="" ( | ||
echo ##vso[task.setvariable variable=BuildConfiguration;]%NewBuildConfiguration% | ||
) | ||
# Component Detection | ||
- task: ComponentGovernanceComponentDetection@0 | ||
displayName: Component Detection | ||
|
||
# Stage BinLog | ||
- task: CopyFiles@2 | ||
displayName: Stage BinLog | ||
condition: always() | ||
inputs: | ||
SourceFolder: $(Build.SourcesDirectory) | ||
Contents: cswinrt.binlog | ||
TargetFolder: $(Build.ArtifactStagingDirectory)\binlog | ||
|
||
# Publish BinLog | ||
- task: PublishBuildArtifacts@1 | ||
displayName: Publish BinLog | ||
condition: always() | ||
inputs: | ||
PathtoPublish: $(Build.ArtifactStagingDirectory)\binlog | ||
ArtifactName: $(BuildConfiguration)_$(BuildPlatform)_binlog | ||
|
||
# Stage Windows projection | ||
- task: ArchiveFiles@2 | ||
displayName: Stage Windows projection | ||
enabled: False | ||
inputs: | ||
rootFolderOrFile: $(Build.SourcesDirectory)\Projections\Windows\Generated Files | ||
includeRootFolder: false | ||
sevenZipCompression: 5 | ||
archiveFile: $(Build.ArtifactStagingDirectory)\Windows\sources.zip | ||
|
||
# Publish Windows projection | ||
- task: PublishBuildArtifacts@1 | ||
displayName: Publish Windows projection | ||
enabled: False | ||
inputs: | ||
PathtoPublish: $(Build.ArtifactStagingDirectory)\Windows | ||
ArtifactName: $(BuildConfiguration)_$(BuildPlatform)_Windows | ||
|
||
# Stage CsWinRT | ||
- task: CopyFiles@2 | ||
displayName: Stage CsWinRT | ||
condition: and(succeeded(), or(eq(variables['BuildPlatform'], 'x86'), eq(variables['BuildPlatform'], 'x64'))) | ||
inputs: | ||
SourceFolder: $(Build.SourcesDirectory)\src\_build\$(BuildPlatform)\$(BuildConfiguration)\cswinrt\bin | ||
Contents: | | ||
cswinrt.exe | ||
cswinrt.pdb | ||
TargetFolder: $(Build.ArtifactStagingDirectory)\native | ||
|
||
# Stage WinRT.Interop.winmd | ||
- task: CopyFiles@2 | ||
displayName: Stage WinRT.Interop.winmd | ||
condition: and(succeeded(), or(eq(variables['BuildPlatform'], 'x86'), eq(variables['BuildPlatform'], 'x64'))) | ||
continueOnError: True | ||
inputs: | ||
SourceFolder: $(Build.SourcesDirectory)\src\_build\$(BuildPlatform)\$(BuildConfiguration)\cswinrt\bin | ||
Contents: WinRT.Interop.winmd | ||
TargetFolder: $(Build.ArtifactStagingDirectory)\native | ||
|
||
# Stage WinRT.Host | ||
- task: CopyFiles@2 | ||
displayName: Stage WinRT.Host | ||
continueOnError: True | ||
inputs: | ||
SourceFolder: $(Build.SourcesDirectory)\src\_build\$(BuildPlatform)\$(BuildConfiguration)\WinRT.Host\bin | ||
Contents: | | ||
WinRT.Host.dll | ||
WinRT.Host.pdb | ||
WinRT.Host.dll.mui | ||
TargetFolder: $(Build.ArtifactStagingDirectory)\native | ||
|
||
# Stage Unit Test | ||
- task: CopyFiles@2 | ||
displayName: Stage Unit Test | ||
condition: and(succeeded(), or(eq(variables['BuildPlatform'], 'x86'), eq(variables['BuildPlatform'], 'x64'))) | ||
inputs: | ||
SourceFolder: $(Build.SourcesDirectory)\src\Tests\UnitTest\bin\$(BuildPlatform)\$(BuildConfiguration)\net5.0 | ||
Contents: | | ||
unittest.dll | ||
unittest.pdb | ||
TargetFolder: $(Build.ArtifactStagingDirectory)\native | ||
|
||
# Publish Native | ||
- task: PublishBuildArtifacts@1 | ||
displayName: Publish Native | ||
inputs: | ||
PathtoPublish: $(Build.ArtifactStagingDirectory)\native | ||
ArtifactName: $(BuildConfiguration)_$(BuildPlatform) | ||
|
||
# Stage NetStandard 2.0 | ||
- task: CopyFiles@2 | ||
displayName: Stage NetStandard 2.0 | ||
condition: and(succeeded(), eq(variables['BuildPlatform'], 'x86'), eq(variables['BuildConfiguration'], 'release')) | ||
inputs: | ||
SourceFolder: $(Build.SourcesDirectory)\src\WinRT.Runtime\bin\$(BuildConfiguration)\netstandard2.0 | ||
Contents: | | ||
WinRT.Runtime.dll | ||
WinRT.Runtime.pdb | ||
TargetFolder: $(Build.ArtifactStagingDirectory)\release_netstandard2.0\ | ||
|
||
# Stage Source Generator | ||
- task: CopyFiles@2 | ||
displayName: Stage Source Generator | ||
condition: and(succeeded(), eq(variables['BuildPlatform'], 'x86'), eq(variables['BuildConfiguration'], 'release')) | ||
inputs: | ||
SourceFolder: $(Build.SourcesDirectory)\src\Authoring\WinRT.SourceGenerator\bin\$(BuildConfiguration)\netstandard2.0 | ||
Contents: | | ||
WinRT.SourceGenerator.dll | ||
WinRT.SourceGenerator.pdb | ||
TargetFolder: $(Build.ArtifactStagingDirectory)\release_netstandard2.0\ | ||
|
||
# Publish NetStandard 2.0 | ||
- task: PublishBuildArtifacts@1 | ||
displayName: Publish NetStandard 2.0 | ||
condition: and(succeeded(), eq(variables['BuildPlatform'], 'x86'), eq(variables['BuildConfiguration'], 'release')) | ||
inputs: | ||
PathtoPublish: $(Build.ArtifactStagingDirectory)\release_netstandard2.0 | ||
ArtifactName: netstandard2.0 | ||
|
||
# Stage Net5.0 | ||
- task: CopyFiles@2 | ||
displayName: Stage Net5.0 | ||
condition: and(succeeded(), eq(variables['BuildPlatform'], 'x86'), eq(variables['BuildConfiguration'], 'release')) | ||
inputs: | ||
SourceFolder: $(Build.SourcesDirectory)\src\WinRT.Runtime\bin\$(BuildConfiguration)\net5.0 | ||
Contents: | | ||
WinRT.Runtime.dll | ||
WinRT.Runtime.pdb | ||
TargetFolder: $(Build.ArtifactStagingDirectory)\release_net5.0 | ||
|
||
# Stage WinRT.Host.Shim | ||
- task: CopyFiles@2 | ||
displayName: Stage WinRT.Host.Shim | ||
condition: and(succeeded(), eq(variables['BuildPlatform'], 'x86'), eq(variables['BuildConfiguration'], 'release')) | ||
continueOnError: True | ||
inputs: | ||
SourceFolder: $(Build.SourcesDirectory)\src\Authoring\WinRT.Host.Shim\bin\$(BuildConfiguration)\net5.0 | ||
Contents: | | ||
WinRT.Host.Shim.dll | ||
WinRT.Host.Shim.pdb | ||
TargetFolder: $(Build.ArtifactStagingDirectory)\release_net5.0 | ||
|
||
# Stage IID Optimizer | ||
- task: CopyFiles@2 | ||
displayName: Stage IID Optimizer | ||
condition: and(succeeded(), eq(variables['BuildPlatform'], 'x86'), eq(variables['BuildConfiguration'], 'release')) | ||
continueOnError: True | ||
inputs: | ||
SourceFolder: $(Build.SourcesDirectory)\src\Perf\IIDOptimizer\bin\$(BuildConfiguration)\net5.0 | ||
Contents: | | ||
IIDOptimizer.exe | ||
IIDOptimizer.dll | ||
IIDOptimizer.deps.json | ||
IIDOptimizer.runtimeconfig.json | ||
Mono.Cecil.dll | ||
Mono.Cecil.Mdb.dll | ||
Mono.Cecil.Pdb.dll | ||
Mono.Cecil.Rocks.dll | ||
System.CommandLine.dll | ||
cs/System.CommandLine.resources.dll | ||
de/System.CommandLine.resources.dll | ||
es/System.CommandLine.resources.dll | ||
fr/System.CommandLine.resources.dll | ||
it/System.CommandLine.resources.dll | ||
ja/System.CommandLine.resources.dll | ||
ko/System.CommandLine.resources.dll | ||
pl/System.CommandLine.resources.dll | ||
pt-BR/System.CommandLine.resources.dll | ||
ru/System.CommandLine.resources.dll | ||
tr/System.CommandLine.resources.dll | ||
zh-Hans/System.CommandLine.resources.dll | ||
zh-Hant/System.CommandLine.resources.dll | ||
TargetFolder: $(Build.ArtifactStagingDirectory)\release_net5.0\IIDOptimizer | ||
|
||
# Stage WinRT.Runtime ResX | ||
- task: CopyFiles@2 | ||
displayName: Stage WinRT.Runtime ResX | ||
condition: succeeded() | ||
inputs: | ||
SourceFolder: $(Build.SourcesDirectory)\src\WinRT.Runtime | ||
Contents: | | ||
WinRTRuntimeErrorStrings.resx | ||
TargetFolder: $(Build.ArtifactStagingDirectory)\resx\WinRT.Runtime | ||
|
||
# Stage Authoring Diagnostics ResX | ||
- task: CopyFiles@2 | ||
displayName: Stage Authoring Diagnostics ResX | ||
condition: succeeded() | ||
inputs: | ||
SourceFolder: $(Build.SourcesDirectory)\src\Authoring\WinRT.SourceGenerator | ||
Contents: | | ||
CsWinRTDiagnosticStrings.resx | ||
TargetFolder: $(Build.ArtifactStagingDirectory)\resx\WinRT.SourceGenerator | ||
|
||
# Publish ResX | ||
- task: PublishBuildArtifacts@1 | ||
displayName: Publish ResX files | ||
condition: succeeded() | ||
inputs: | ||
PathtoPublish: $(Build.ArtifactStagingDirectory)\resx | ||
ArtifactName: ResX | ||
|
||
# Publish Net5.0 | ||
- task: PublishBuildArtifacts@1 | ||
displayName: Publish Net5.0 | ||
condition: and(succeeded(), eq(variables['BuildPlatform'], 'x86'), eq(variables['BuildConfiguration'], 'release')) | ||
inputs: | ||
PathtoPublish: $(Build.ArtifactStagingDirectory)\release_net5.0 | ||
ArtifactName: net5.0 | ||
|
||
# Generate SBOM | ||
- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0 | ||
displayName: 'SBOM Generator Task' | ||
condition: eq(variables['BuildConfiguration'],'Release') | ||
inputs: | ||
BuildDropPath: '$(Build.ArtifactStagingDirectory)' | ||
PackageName: 'Microsoft.Windows.CsWinRT' | ||
PackageVersion: '$(NugetVersion)' | ||
|
||
# Stage SBOM | ||
- task: PublishBuildArtifacts@1 | ||
displayName: 'Publish SBOM to build artifacts' | ||
condition: eq(variables['BuildConfiguration'],'Release') | ||
inputs: | ||
PathtoPublish: '$(Build.ArtifactStagingDirectory)\_manifest' | ||
ArtifactName: SBOM_$(BuildPlatform) |
Oops, something went wrong.