Skip to content

Commit dbff880

Browse files
committed
Add build caches
1 parent 86e3790 commit dbff880

17 files changed

Lines changed: 84 additions & 17 deletions

File tree

azure-pipelines.yml

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ pool:
2020
variables:
2121
solution: 'src\AppInstallerCLI.sln'
2222
EnableDetectorVcpkg: true
23+
EnablePipelineCache: true
24+
VCPKG_BINARY_SOURCES: "clear;nuget,https://pkgs.dev.azure.com/shine-oss/winget-cli/_packaging/WinGetDependencies/nuget/v3/index.json,readwrite"
2325

2426
# Do not set the build version for a PR build.
2527

@@ -67,6 +69,22 @@ jobs:
6769
- task: NuGetToolInstaller@1
6870
displayName: Install Nuget
6971

72+
- task: NuGetAuthenticate@1
73+
displayName: Authenticate to NuGet Feed
74+
75+
- task: PowerShell@2
76+
displayName: Configure vcpkg NuGet binary cache credentials
77+
inputs:
78+
targetType: inline
79+
script: |
80+
$nugetExe = (& "$(VCPKG_INSTALLATION_ROOT)\vcpkg.exe" fetch nuget) | Select-Object -Last 1
81+
$feedUrl = "https://pkgs.dev.azure.com/shine-oss/winget-cli/_packaging/WinGetDependencies/nuget/v3/index.json"
82+
& $nugetExe sources remove -Name "WinGetDependencies" 2>&1 | Out-Null
83+
& $nugetExe sources add -Name "WinGetDependencies" -Source $feedUrl -Username "AzureDevOps" -Password "$env:SYSTEM_ACCESSTOKEN" -StorePasswordInClearText
84+
& $nugetExe setapikey "AzureDevOps" -Source $feedUrl
85+
env:
86+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
87+
7088
# Restores all projects, including native (vcxproj) projects
7189
- task: NuGetCommand@2
7290
displayName: Restore Solution
@@ -114,13 +132,16 @@ jobs:
114132
platform: '$(buildPlatform)'
115133
solution: '$(solution)'
116134
configuration: '$(buildConfiguration)'
117-
msbuildArgs: '/bl:$(artifactsDir)\msbuild.binlog
135+
msbuildArgs: '/reportfileaccesses
136+
/bl:$(artifactsDir)\msbuild.binlog
118137
/p:AppxBundlePlatforms="$(buildPlatform)"
119138
/p:AppxPackageDir="$(appxPackageDir)"
120139
/p:AppxBundle=Always
121140
/p:UapAppxPackageBuildMode=SideloadOnly
122-
/p:WingetCleanIntermediateFiles=true'
141+
/p:WingetCleanIntermediateFiles=false'
123142
maximumCpuCount: true
143+
env:
144+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
124145

125146
- task: MSBuild@1
126147
displayName: Build MSIX Test Installer File
@@ -672,6 +693,22 @@ jobs:
672693
- task: NuGetToolInstaller@1
673694
displayName: Install Nuget
674695

696+
- task: NuGetAuthenticate@1
697+
displayName: Authenticate to NuGet Feed
698+
699+
- task: PowerShell@2
700+
displayName: Configure vcpkg NuGet binary cache credentials
701+
inputs:
702+
targetType: inline
703+
script: |
704+
$nugetExe = (& "$(VCPKG_INSTALLATION_ROOT)\vcpkg.exe" fetch nuget) | Select-Object -Last 1
705+
$feedUrl = "https://pkgs.dev.azure.com/shine-oss/winget-cli/_packaging/WinGetDependencies/nuget/v3/index.json"
706+
& $nugetExe sources remove -Name "WinGetDependencies" 2>&1 | Out-Null
707+
& $nugetExe sources add -Name "WinGetDependencies" -Source $feedUrl -Username "AzureDevOps" -Password "$env:SYSTEM_ACCESSTOKEN" -StorePasswordInClearText
708+
& $nugetExe setapikey "AzureDevOps" -Source $feedUrl
709+
env:
710+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
711+
675712
- task: NuGetCommand@2
676713
displayName: Restore Solution
677714
inputs:
@@ -690,7 +727,7 @@ jobs:
690727
platform: '$(buildPlatform)'
691728
solution: '$(solution)'
692729
configuration: '$(buildConfiguration)'
693-
msbuildArgs: '/bl:$(artifactsDir)\msbuild.binlog'
730+
msbuildArgs: '/bl:$(artifactsDir)\msbuild.binlog /p:MSBuildCacheEnabled=false'
694731
maximumCpuCount: true
695732

696733
- task: CopyFiles@2
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<packages>
2+
<packages>
3+
<package id="Microsoft.MSBuildCache.AzurePipelines" version="0.1.328-preview" targetFramework="native" developmentDependency="true" />
34
<package id="Microsoft.Windows.CppWinRT" version="2.0.250303.1" targetFramework="native" />
45
</packages>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<packages>
2+
<packages>
3+
<package id="Microsoft.MSBuildCache.AzurePipelines" version="0.1.328-preview" targetFramework="native" developmentDependency="true" />
34
<package id="Microsoft.Windows.CppWinRT" version="2.0.250303.1" targetFramework="native" />
45
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.250325.1" targetFramework="native" />
56
</packages>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<packages>
2+
<packages>
3+
<package id="Microsoft.MSBuildCache.AzurePipelines" version="0.1.328-preview" targetFramework="native" developmentDependency="true" />
34
<package id="Microsoft.Windows.CppWinRT" version="2.0.250303.1" targetFramework="native" />
45
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.250325.1" targetFramework="native" />
56
</packages>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<packages>
2+
<packages>
3+
<package id="Microsoft.MSBuildCache.AzurePipelines" version="0.1.328-preview" targetFramework="native" developmentDependency="true" />
34
<package id="Microsoft.Windows.CppWinRT" version="2.0.250303.1" targetFramework="native" />
45
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.250325.1" targetFramework="native" />
56
</packages>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<packages>
2+
<packages>
3+
<package id="Microsoft.MSBuildCache.AzurePipelines" version="0.1.328-preview" targetFramework="native" developmentDependency="true" />
34
<package id="Microsoft.Windows.CppWinRT" version="2.0.250303.1" targetFramework="native" />
45
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.250325.1" targetFramework="native" />
56
</packages>

src/Directory.Build.props

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@
4545
<DefineConstants>$(WinGetMacros)$(DefineConstants)</DefineConstants>
4646
</PropertyGroup>
4747

48+
<!-- MSBuildCache for C++ projects: props must be imported first. -->
49+
<!-- The package is restored via packages.config; Directory.Build.targets imports the corresponding .targets file. -->
50+
<PropertyGroup Condition="'$(MSBuildProjectExtension)' == '.vcxproj'">
51+
<MSBuildCachePackageName>Microsoft.MSBuildCache.AzurePipelines</MSBuildCachePackageName>
52+
<MSBuildCachePackageVersion>0.1.328-preview</MSBuildCachePackageVersion>
53+
<MSBuildCachePackageRoot>$(SolutionDir)\packages\$(MSBuildCachePackageName).$(MSBuildCachePackageVersion)</MSBuildCachePackageRoot>
54+
</PropertyGroup>
55+
<Import Project="$(MSBuildCachePackageRoot)\build\$(MSBuildCachePackageName).props"
56+
Condition="'$(MSBuildProjectExtension)' == '.vcxproj' and Exists('$(MSBuildCachePackageRoot)\build\$(MSBuildCachePackageName).props')" />
57+
4858
<!-- To prevent build agents from running out of disk space, clean as we go. -->
4959
<Target Name="CleanIntermediateFiles" AfterTargets="Build" Condition="'$(WingetCleanIntermediateFiles)'=='true'">
5060
<RemoveDir Directories="$(IntDir)" />

src/Directory.Build.targets

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<!-- MSBuildCache for C++ projects: targets must be imported last. -->
4+
<Import Project="$(MSBuildCachePackageRoot)\build\$(MSBuildCachePackageName).targets"
5+
Condition="'$(MSBuildProjectExtension)' == '.vcxproj' and Exists('$(MSBuildCachePackageRoot)\build\$(MSBuildCachePackageName).targets')" />
6+
</Project>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<packages>
2+
<packages>
3+
<package id="Microsoft.MSBuildCache.AzurePipelines" version="0.1.328-preview" targetFramework="native" developmentDependency="true" />
34
<package id="Microsoft.Windows.CppWinRT" version="2.0.250303.1" targetFramework="native" />
45
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.250325.1" targetFramework="native" />
56
</packages>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<packages>
2+
<packages>
3+
<package id="Microsoft.MSBuildCache.AzurePipelines" version="0.1.328-preview" targetFramework="native" developmentDependency="true" />
34
<package id="Microsoft.Windows.CppWinRT" version="2.0.250303.1" targetFramework="native" />
45
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.250325.1" targetFramework="native" />
56
</packages>

0 commit comments

Comments
 (0)