Skip to content

Commit a6931b4

Browse files
Speed up CI Windows metadata setup
1 parent 6d08698 commit a6931b4

File tree

3 files changed

+25
-34
lines changed

3 files changed

+25
-34
lines changed

.github/workflows/build-release.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ jobs:
8484
environment: ${{ needs.preflight.outputs.package-env }}
8585
permissions:
8686
contents: read
87+
env:
88+
NUGET_PACKAGES: ${{ github.workspace }}\.nuget\packages
8789
strategy:
8890
fail-fast: false
8991
matrix:
@@ -93,24 +95,19 @@ jobs:
9395
- name: Checkout
9496
uses: actions/checkout@v6
9597

96-
- name: Install Windows SDK UAP platform
97-
shell: pwsh
98-
run: |
99-
# CsWinRT in WindowsPackageManager.Interop requires UAP 10.0.19041.0 platform metadata
100-
$VsWhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
101-
$VsInstaller = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vs_installer.exe"
102-
$InstallPath = & $VsWhere -latest -property installationPath
103-
& $VsInstaller modify --installPath $InstallPath `
104-
--add Microsoft.VisualStudio.Component.UWP.Support `
105-
--add Microsoft.VisualStudio.Component.Windows10SDK.19041 `
106-
--quiet --norestart --nocache | Out-Default
107-
Write-Host "Windows SDK UAP platform installed"
108-
10998
- name: Install .NET
11099
uses: actions/setup-dotnet@v5
111100
with:
112101
dotnet-version: 8.0.x
113102

103+
- name: Cache NuGet packages
104+
uses: actions/cache@v4
105+
with:
106+
path: ${{ env.NUGET_PACKAGES }}
107+
key: ${{ runner.os }}-nuget-${{ hashFiles('src/**/*.csproj', 'src/**/*.props', 'src/**/*.targets', 'src/**/*.sln') }}
108+
restore-keys: |
109+
${{ runner.os }}-nuget-
110+
114111
- name: Install Python
115112
uses: actions/setup-python@v6
116113
with:

.github/workflows/dotnet-test.yml

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,43 +21,32 @@ on:
2121
jobs:
2222
test-codebase:
2323
runs-on: windows-latest
24+
env:
25+
NUGET_PACKAGES: ${{ github.workspace }}\.nuget\packages
2426

2527
steps:
2628
- name: Checkout the repository
2729
uses: actions/checkout@v6
2830
with:
2931
fetch-depth: 0
3032

31-
# Install the .NET Core workload
3233
- name: Install .NET Core
3334
uses: actions/setup-dotnet@v5
3435
with:
3536
dotnet-version: 8.0.x
3637

37-
- name: Install Windows SDK UAP platform
38-
shell: pwsh
39-
run: |
40-
# CsWinRT in WindowsPackageManager.Interop requires UAP 10.0.19041.0 platform metadata
41-
$VsWhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
42-
$VsInstaller = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vs_installer.exe"
43-
$InstallPath = & $VsWhere -latest -property installationPath
44-
& $VsInstaller modify --installPath $InstallPath `
45-
--add Microsoft.VisualStudio.Component.UWP.Support `
46-
--add Microsoft.VisualStudio.Component.Windows10SDK.19041 `
47-
--quiet --norestart --nocache | Out-Default
48-
Write-Host "Windows SDK UAP platform installed"
49-
50-
# - name: Install WinGet
51-
# uses: Cyberboss/install-winget@v1
38+
- name: Cache NuGet packages
39+
uses: actions/cache@v4
40+
with:
41+
path: ${{ env.NUGET_PACKAGES }}
42+
key: ${{ runner.os }}-nuget-${{ hashFiles('src/**/*.csproj', 'src/**/*.props', 'src/**/*.targets', 'src/**/*.sln') }}
43+
restore-keys: |
44+
${{ runner.os }}-nuget-
5245
5346
- name: Install dependencies
5447
working-directory: src
5548
run: dotnet restore UniGetUI.sln
5649

57-
# - name: Test build
58-
# working-directory: src
59-
# run: dotnet build --configuration Release
60-
6150
- name: Run Tests
6251
working-directory: src
6352
run: dotnet test UniGetUI.sln --no-restore --verbosity q --nologo

src/WindowsPackageManager.Interop/ExternalLibraries.WindowsPackageManager.Interop.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
https://github.com/microsoft/CsWinRT/blob/master/nuget/readme.md
1818
-->
1919
<PropertyGroup>
20-
<CsWinRTWindowsMetadata>10.0.19041.0</CsWinRTWindowsMetadata>
20+
<CsWinRTWindowsMetadata Condition="'$(PkgMicrosoft_Windows_SDK_Contracts)' != ''">$(PkgMicrosoft_Windows_SDK_Contracts)\ref\netstandard2.0</CsWinRTWindowsMetadata>
21+
<CsWinRTWindowsMetadata Condition="'$(PkgMicrosoft_Windows_SDK_Contracts)' == ''">10.0.26100.0</CsWinRTWindowsMetadata>
2122
<CsWinRTIncludes>Microsoft.Management.Deployment</CsWinRTIncludes>
2223
</PropertyGroup>
2324

@@ -29,6 +30,10 @@
2930

3031
<ItemGroup>
3132
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.2.0" />
33+
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.26100.4948">
34+
<GeneratePathProperty>true</GeneratePathProperty>
35+
<IncludeAssets>none</IncludeAssets>
36+
</PackageReference>
3237
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.183">
3338
<PrivateAssets>all</PrivateAssets>
3439
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>

0 commit comments

Comments
 (0)