Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Save symbol files (pdbs) to the pipeline artifacts #316

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 28 additions & 6 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pool:
variables:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
BuildConfiguration: Release
RepositoryLocalPath : $(Build.Repository.LocalPath)

steps:

Expand All @@ -36,19 +37,13 @@ steps:
- script: nbgv cloud
displayName: Set Version

- powershell: .\build\Install-WindowsSdkISO.ps1 18362
displayName: Insider SDK

- task: BatchScript@1
inputs:
filename: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\Common7\\Tools\\VsDevCmd.bat"
arguments: -no_logo
modifyEnvironment: true
displayName: Setup Environment Variables

#- powershell: .\build\build.ps1 -target=Package
# displayName: Build

- task: NuGetCommand@2
displayName: NuGet restore Native projects
inputs:
Expand Down Expand Up @@ -76,6 +71,9 @@ steps:
msbuildArguments: /target:Build
restoreNugetPackages: false # Optional

- powershell: "& 'C:\\Program Files (x86)\\Windows Kits\\10\\Debuggers\\x64\\pdbcopy.exe' $env:RepositoryLocalPath\\x64\\Release\\Microsoft.Toolkit.Win32.UI.XamlApplication\\Microsoft.Toolkit.Win32.UI.XamlHost.pdb $env:RepositoryLocalPath\\x64\\Release\\Microsoft.Toolkit.Win32.UI.XamlApplication\\Microsoft.Toolkit.Win32.UI.XamlHost_stripped.pdb -p"
displayName: Strip x64

- task: MSBuild@1
displayName: Build x86 Restore
inputs:
Expand All @@ -94,6 +92,9 @@ steps:
msbuildArguments: /target:Build
restoreNugetPackages: false # Optional

- powershell: "& 'C:\\Program Files (x86)\\Windows Kits\\10\\Debuggers\\x64\\pdbcopy.exe' $env:RepositoryLocalPath\\Win32\\Release\\Microsoft.Toolkit.Win32.UI.XamlApplication\\Microsoft.Toolkit.Win32.UI.XamlHost.pdb $env:RepositoryLocalPath\\Win32\\Release\\Microsoft.Toolkit.Win32.UI.XamlApplication\\Microsoft.Toolkit.Win32.UI.XamlHost_stripped.pdb -p"
displayName: Strip x86

- task: MSBuild@1
displayName: Build ARM Restore
inputs:
Expand All @@ -112,6 +113,9 @@ steps:
msbuildArguments: /target:Build
restoreNugetPackages: false # Optional

- powershell: "& 'C:\\Program Files (x86)\\Windows Kits\\10\\Debuggers\\x64\\pdbcopy.exe' $env:RepositoryLocalPath\\ARM\\Release\\Microsoft.Toolkit.Win32.UI.XamlApplication\\Microsoft.Toolkit.Win32.UI.XamlHost.pdb $env:RepositoryLocalPath\\ARM\\Release\\Microsoft.Toolkit.Win32.UI.XamlApplication\\Microsoft.Toolkit.Win32.UI.XamlHost_stripped.pdb -p"
displayName: Strip ARM

- task: MSBuild@1
displayName: Build ARM64 Restore
inputs:
Expand All @@ -130,6 +134,9 @@ steps:
msbuildArguments: /target:Build
restoreNugetPackages: false # Optional

- powershell: "& 'C:\\Program Files (x86)\\Windows Kits\\10\\Debuggers\\x64\\pdbcopy.exe' $env:RepositoryLocalPath\\ARM64\\Release\\Microsoft.Toolkit.Win32.UI.XamlApplication\\Microsoft.Toolkit.Win32.UI.XamlHost.pdb $env:RepositoryLocalPath\\ARM64\\Release\\Microsoft.Toolkit.Win32.UI.XamlApplication\\Microsoft.Toolkit.Win32.UI.XamlHost_stripped.pdb -p"
displayName: Strip ARM64

- task: MSBuild@1
displayName: Build Pack
inputs:
Expand All @@ -155,3 +162,18 @@ steps:
pathToPublish: .\bin\nupkg
artifactType: container
artifactName: Packages

# Publish stripped pdbs to artifacts
- task: CopyFiles@2
inputs:
Contents: |
x64\$(Configuration)\Microsoft.Toolkit.Win32.UI.XamlApplication\Microsoft.Toolkit.Win32.UI.XamlHost_stripped.pdb
Win32\$(Configuration)\Microsoft.Toolkit.Win32.UI.XamlApplication\Microsoft.Toolkit.Win32.UI.XamlHost_stripped.pdb
arm\$(Configuration)\Microsoft.Toolkit.Win32.UI.XamlApplication\Microsoft.Toolkit.Win32.UI.XamlHost_stripped.pdb
arm64\$(Configuration)\Microsoft.Toolkit.Win32.UI.XamlApplication\Microsoft.Toolkit.Win32.UI.XamlHost_stripped.pdb
TargetFolder: '$(Build.ArtifactStagingDirectory)\symbols\'

- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)\symbols'
artifactName: 'symbols'
174 changes: 59 additions & 115 deletions build/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ string Version = null;
var inheritDoc = toolsDir + "/InheritDoc/tools/InheritDoc.exe";
var inheritDocExclude = "Foo.*";

var pdbcopyPath = Context.Environment.GetSpecialPath(SpecialPath.ProgramFilesX86).Combine(@"Windows Kits\10\Debuggers\x64").CombineWithFilePath("pdbcopy.exe");

//////////////////////////////////////////////////////////////////////
// METHODS
//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -91,6 +93,59 @@ void VerifyHeaders(bool Replace)
}
}

void Build(PlatformTarget platformTarget)
{
var buildSettings = new MSBuildSettings
{
PlatformTarget = platformTarget,
MaxCpuCount = 1,
}
.SetConfiguration("Release")
.UseToolVersion(MSBuildToolVersion.VS2019)
.WithTarget("Restore");

Information($"\nRestore {platformTarget} Step");
MSBuild(win32Solution, buildSettings);

// Build once with normal dependency ordering
buildSettings = new MSBuildSettings
{
PlatformTarget = platformTarget,
MaxCpuCount = 1,
}
.SetConfiguration("Release")
.UseToolVersion(MSBuildToolVersion.VS2019)
.WithTarget("Build");

Information($"\nBuild {platformTarget} Step");
MSBuild(win32Solution, buildSettings);

Information($"\nStripping {platformTarget} PDB");

string arch;
switch(platformTarget)
{
case PlatformTarget.x86:
arch = "Win32";
break;
default:
arch = platformTarget.ToString();
break;
}

var args = new ProcessArgumentBuilder()
.AppendQuoted(baseDir + $"/{arch}/Release/Microsoft.Toolkit.Win32.UI.XamlApplication/Microsoft.Toolkit.Win32.UI.XamlHost.pdb")
.AppendQuoted(baseDir + $"/{arch}/Release/Microsoft.Toolkit.Win32.UI.XamlApplication/Microsoft.Toolkit.Win32.UI.XamlHost_stripped.pdb")
.AppendSwitch("-p", "");

var result = StartProcess(pdbcopyPath, new ProcessSettings { Arguments = args });

if (result != 0)
{
throw new InvalidOperationException($"PDBCopy stripping for '{arch}' failed!");
}
}

//////////////////////////////////////////////////////////////////////
// DEFAULT TASK
//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -157,121 +212,10 @@ Task("Build")
NuGetRestore(solution, nugetRestoreSettings);
}

{
var buildSettings = new MSBuildSettings
{
PlatformTarget = PlatformTarget.x64,
MaxCpuCount = 1,
}
.SetConfiguration("Release")
.UseToolVersion(MSBuildToolVersion.VS2019)
.WithTarget("Restore");

Information("\nRestore x64 Step");
MSBuild(win32Solution, buildSettings);
}

{
// Build once with normal dependency ordering
var buildSettings = new MSBuildSettings
{
PlatformTarget = PlatformTarget.x64,
MaxCpuCount = 1,
}
.SetConfiguration("Release")
.UseToolVersion(MSBuildToolVersion.VS2019)
.WithTarget("Build");

Information("\nBuild x64 Step");
MSBuild(win32Solution, buildSettings);
}

{
var buildSettings = new MSBuildSettings
{
PlatformTarget = PlatformTarget.x86,
MaxCpuCount = 1,
}
.SetConfiguration("Release")
.UseToolVersion(MSBuildToolVersion.VS2019)
.WithTarget("Restore");

Information("\nRestore x86 Step");
MSBuild(win32Solution, buildSettings);
}

{
// Build once with normal dependency ordering
var buildSettings = new MSBuildSettings
{
PlatformTarget = PlatformTarget.x86,
MaxCpuCount = 1,
}
.SetConfiguration("Release")
.UseToolVersion(MSBuildToolVersion.VS2019)
.WithTarget("Build");

Information("\nBuild x86 Step");
MSBuild(win32Solution, buildSettings);
}

{
var buildSettings = new MSBuildSettings
{
PlatformTarget = PlatformTarget.ARM,
MaxCpuCount = 1,
}
.SetConfiguration("Release")
.UseToolVersion(MSBuildToolVersion.VS2019)
.WithTarget("Restore");

Information("\nRestore ARM Step");
MSBuild(win32Solution, buildSettings);
}

{
// Build once with normal dependency ordering
var buildSettings = new MSBuildSettings
{
PlatformTarget = PlatformTarget.ARM,
MaxCpuCount = 1,
}
.SetConfiguration("Release")
.UseToolVersion(MSBuildToolVersion.VS2019)
.WithTarget("Build");

Information("\nBuild ARM Step");
MSBuild(win32Solution, buildSettings);
}

{
var buildSettings = new MSBuildSettings
{
PlatformTarget = PlatformTarget.ARM64,
MaxCpuCount = 1,
}
.SetConfiguration("Release")
.UseToolVersion(MSBuildToolVersion.VS2019)
.WithTarget("Restore");

Information("\nRestore ARM64 Step");
MSBuild(win32Solution, buildSettings);
}

{
// Build once with normal dependency ordering
var buildSettings = new MSBuildSettings
{
PlatformTarget = PlatformTarget.ARM64,
MaxCpuCount = 1,
}
.SetConfiguration("Release")
.UseToolVersion(MSBuildToolVersion.VS2019)
.WithTarget("Build");

Information("\nBuild ARM64 Step");
MSBuild(win32Solution, buildSettings);
}
Build(PlatformTarget.x64);
Build(PlatformTarget.x86);
Build(PlatformTarget.ARM);
Build(PlatformTarget.ARM64);

});

Expand Down