Skip to content

Update NuGet packages to latest stable #4143

Update NuGet packages to latest stable

Update NuGet packages to latest stable #4143

Workflow file for this run

name: .NET
on: [push, pull_request]
env:
EXCLUDE_RUN_ID_FROM_PACKAGE: false
EXCLUDE_SUFFIX_FROM_VERSION: false
jobs:
# Build the whole ComputeSharp solution
build-solution:
strategy:
matrix:
configuration: [Debug, Release]
platform: [x64, arm64]
runs-on: windows-2022
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
- name: Build
run: msbuild -t:restore,build /p:Configuration=${{matrix.configuration}} /p:Platform=${{matrix.platform}} /bl
- name: Upload MSBuild binary log
uses: actions/upload-artifact@v3
with:
name: msbuild_log_${{matrix.configuration}}_${{matrix.platform}}
path: msbuild.binlog
if-no-files-found: error
# Pack all projects with dotnet/MSBuild to generate NuGet packages.
# This workflow also uploads the resulting packages as artifacts.
build-packages:
runs-on: windows-2022
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
- name: Build ComputeSharp.Core package
run: dotnet pack src\ComputeSharp.Core\ComputeSharp.Core.csproj -c Release
- name: Build ComputeSharp package
run: dotnet pack src\ComputeSharp\ComputeSharp.csproj -c Release
- name: Build ComputeSharp.Dynamic package
run: dotnet pack src\ComputeSharp.Dynamic\ComputeSharp.Dynamic.csproj -c Release
- name: Build ComputeSharp.D3D12MemoryAllocator package
run: dotnet pack src\ComputeSharp.D3D12MemoryAllocator\ComputeSharp.D3D12MemoryAllocator.csproj -c Release
- name: Build ComputeSharp.D2D1 package
run: dotnet pack src\ComputeSharp.D2D1\ComputeSharp.D2D1.csproj -c Release
- name: Build ComputeSharp.Pix package
run: dotnet pack src\ComputeSharp.Pix\ComputeSharp.Pix.csproj -c Release
- name: Build ComputeSharp.Uwp package
run: msbuild src\ComputeSharp.Uwp\ComputeSharp.Uwp.csproj -t:restore,build,pack /p:Configuration=Release
- name: Build ComputeSharp.D2D1.Uwp package
run: msbuild src\ComputeSharp.D2D1.Uwp\ComputeSharp.D2D1.Uwp.csproj -t:restore,build,pack /p:Configuration=Release
# WinUI 3 packaging needs to be done separately and with no previous build target for it to work correctly
- name: Build ComputeSharp.WinUI package
run: >
msbuild src\ComputeSharp.WinUI\ComputeSharp.WinUI.csproj -t:restore /p:Configuration=Release;
msbuild src\ComputeSharp.WinUI\ComputeSharp.WinUI.csproj -t:pack /p:Configuration=Release
- name: Build ComputeSharp.D2D1.WinUI package
run: >
msbuild src\ComputeSharp.D2D1.WinUI\ComputeSharp.D2D1.WinUI.csproj -t:restore /p:Configuration=Release;
msbuild src\ComputeSharp.D2D1.WinUI\ComputeSharp.D2D1.WinUI.csproj -t:pack /p:Configuration=Release
# Upload the packages to the pipeline artifacts
- name: Upload package artifacts
uses: actions/upload-artifact@v3
with:
name: nuget_packages
path: artifacts\*.nupkg
if-no-files-found: error
# Run all unit tests referencing the ComputeSharp projects directly
run-tests:
needs: [build-solution]
strategy:
matrix:
framework: [net7.0, net6.0, net472]
runs-on: windows-2022
# Set the environment variable which is then looked up in ComputeSharp.Dynamic.
# This is a workaround for https://github.com/actions/runner-images/issues/6531.
env:
CI_RUNNER_DOTNET_TEST_PLATFORM: x64
steps:
- name: Git checkout
uses: actions/checkout@v3
# DirectX 12 unit tests
- name: Run ComputeSharp.Tests
run: dotnet test tests\ComputeSharp.Tests\ComputeSharp.Tests.csproj -c Release -f ${{matrix.framework}} /p:Platform=x64 -v n -l "console;verbosity=detailed"
- name: Run ComputeSharp.Tests.DisableDynamicCompilation
run: dotnet test tests\ComputeSharp.Tests.DisableDynamicCompilation\ComputeSharp.Tests.DisableDynamicCompilation.csproj -c Release -f ${{matrix.framework}} /p:Platform=x64 -v n -l "console;verbosity=detailed"
- name: Run ComputeSharp.Tests.GlobalStatements
run: dotnet test tests\ComputeSharp.Tests.GlobalStatements\ComputeSharp.Tests.GlobalStatements.csproj -c Release -f ${{matrix.framework}} /p:Platform=x64 -v n -l "console;verbosity=detailed"
- name: Run ComputeSharp.Tests.Internals
run: dotnet test tests\ComputeSharp.Tests.Internals\ComputeSharp.Tests.Internals.csproj -c Release -f ${{matrix.framework}} /p:Platform=x64 -v n -l "console;verbosity=detailed"
# Only run the source generators tests once, as they're not runtime specific
- if: matrix.framework == 'net6.0'
name: Run ComputeSharp.Tests.SourceGenerators
run: dotnet test tests\ComputeSharp.Tests.SourceGenerators\ComputeSharp.Tests.SourceGenerators.csproj -v n -l "console;verbosity=detailed"
# DirectX 12 device lost unit tests.
# These tests are run one class at a time to ensure there's no accidental conflicts between any of them. This is because
# the code paths being tested in this project are heavily dependent on process-wide mutable state (ie. DirectX 12 devices).
- name: Run ComputeSharp.Tests.DeviceLost "DeviceDisposal"
run: dotnet test tests\ComputeSharp.Tests.DeviceLost\ComputeSharp.Tests.DeviceLost.csproj --filter "TestCategory=DeviceDisposal" -c Release -f ${{matrix.framework}} -v n -l "console;verbosity=detailed"
# These tests are failing randomly in the CI on .NET Framework, disabling them just for now
- if: matrix.framework != 'net472'
name: Run ComputeSharp.Tests.DeviceLost "DeviceLost"
run: dotnet test tests\ComputeSharp.Tests.DeviceLost\ComputeSharp.Tests.DeviceLost.csproj --filter "TestCategory=DeviceLost" -c Release -f ${{matrix.framework}} -v n -l "console;verbosity=detailed"
- if: matrix.framework != 'net472'
name: Run ComputeSharp.Tests.DeviceLost "GetDefaultDevice"
run: dotnet test tests\ComputeSharp.Tests.DeviceLost\ComputeSharp.Tests.DeviceLost.csproj --filter "TestCategory=GetDefaultDevice" -c Release -f ${{matrix.framework}} -v n -l "console;verbosity=detailed"
# D2D1 unit tests
- name: Run ComputeSharp.D2D1.Tests
run: dotnet test tests\ComputeSharp.D2D1.Tests\ComputeSharp.D2D1.Tests.csproj -c Release -f ${{matrix.framework}} -v n -l "console;verbosity=detailed"
- name: Run ComputeSharp.D2D1.Tests.AssemblyLevelAttributes
run: dotnet test tests\ComputeSharp.D2D1.Tests.AssemblyLevelAttributes\ComputeSharp.D2D1.Tests.AssemblyLevelAttributes.csproj -c Release -f ${{matrix.framework}} -v n -l "console;verbosity=detailed"
# Run all unit tests using D3D12MA
run-tests-d3d12ma:
needs: [build-solution]
strategy:
matrix:
framework: [net7.0, net6.0]
runs-on: windows-2022
env:
CI_RUNNER_DOTNET_TEST_PLATFORM: x64
steps:
- name: Git checkout
uses: actions/checkout@v3
# D3D12MA tests (main ComputeSharp tests, as well as the device lost ones)
- name: Run ComputeSharp.Tests
run: dotnet test tests\ComputeSharp.Tests\ComputeSharp.Tests.csproj -c Release -f ${{matrix.framework}} /p:Platform=x64 /p:UseD3D12MemoryAllocator=true -v n -l "console;verbosity=detailed"
- name: Run ComputeSharp.Tests.DeviceLost "DeviceDisposal"
run: dotnet test tests\ComputeSharp.Tests.DeviceLost\ComputeSharp.Tests.DeviceLost.csproj --filter "TestCategory=DeviceDisposal" -c Release -f ${{matrix.framework}} /p:UseD3D12MemoryAllocator=true -v n -l "console;verbosity=detailed"
- name: Run ComputeSharp.Tests.DeviceLost "DeviceLost"
run: dotnet test tests\ComputeSharp.Tests.DeviceLost\ComputeSharp.Tests.DeviceLost.csproj --filter "TestCategory=DeviceLost" -c Release -f ${{matrix.framework}} /p:UseD3D12MemoryAllocator=true -v n -l "console;verbosity=detailed"
- name: Run ComputeSharp.Tests.DeviceLost "GetDefaultDevice"
run: dotnet test tests\ComputeSharp.Tests.DeviceLost\ComputeSharp.Tests.DeviceLost.csproj --filter "TestCategory=GetDefaultDevice" -c Release -f ${{matrix.framework}} /p:UseD3D12MemoryAllocator=true -v n -l "console;verbosity=detailed"
# Run all Win2D tests (separately, as they need VS Test)
run-tests-win2d:
needs: [build-solution]
strategy:
matrix:
configuration: [Debug, Release]
framework: [uwp, wasdk]
runs-on: windows-2022
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
# Build the D2D1 UWP unit tests (need to restore and build separately for it to build correctly)
- if: matrix.framework == 'uwp'
name: Build ComputeSharp.D2D1.Uwp.Tests
run: >
msbuild tests\ComputeSharp.D2D1.Uwp.Tests\ComputeSharp.D2D1.Uwp.Tests.csproj -t:restore /p:Configuration=${{matrix.configuration}} /p:Platform=x64;
msbuild tests\ComputeSharp.D2D1.Uwp.Tests\ComputeSharp.D2D1.Uwp.Tests.csproj -t:build /p:Configuration=${{matrix.configuration}} /p:Platform=x64
# Run the D2D1 UWP unit tests with VS Test (need to use vswhere to find the VS Test runner)
- if: matrix.framework == 'uwp'
name: Run ComputeSharp.D2D1.Uwp.Tests
run: >
$vs_path = vswhere -latest -products * -requires Microsoft.VisualStudio.Workload.ManagedDesktop -requiresAny -property installationPath;
$vstest_path = join-path $vs_path 'Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe';
& $vstest_path /Platform:x64 /framework:frameworkuap10 tests\ComputeSharp.D2D1.Uwp.Tests\bin\x64\${{matrix.configuration}}\ComputeSharp.D2D1.Uwp.Tests.build.appxrecipe
# Build the D2D1 WinAppSDK unit tests (this also needs two steps, or the entry point won't be generated)
- if: matrix.framework == 'wasdk'
name: Build ComputeSharp.D2D1.WinUI.Tests
run: >
msbuild tests\ComputeSharp.D2D1.WinUI.Tests\ComputeSharp.D2D1.WinUI.Tests.csproj -t:restore /p:Configuration=${{matrix.configuration}} /p:Platform=x64;
msbuild tests\ComputeSharp.D2D1.WinUI.Tests\ComputeSharp.D2D1.WinUI.Tests.csproj -t:build /p:Configuration=${{matrix.configuration}} /p:Platform=x64
# Run the D2D1 WinAppSDK unit tests with VS Test again
- if: matrix.framework == 'wasdk'
name: Run ComputeSharp.D2D1.WinUI.Tests
run: >
$vs_path = vswhere -latest -products * -requires Microsoft.VisualStudio.Workload.ManagedDesktop -requiresAny -property installationPath;
$vstest_path = join-path $vs_path 'Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe';
& $vstest_path /Platform:x64 tests\ComputeSharp.D2D1.WinUI.Tests\bin\x64\${{matrix.configuration}}\net6.0-windows10.0.22621.0\win10-x64\ComputeSharp.D2D1.WinUI.Tests.build.appxrecipe
# Run all the local samples to ensure they build and run with no errors
run-samples:
needs: [build-solution]
strategy:
matrix:
framework: [net7.0, net6.0, net472]
runs-on: windows-2022
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Build and run ComputeSharp.Sample
run: >
dotnet build samples\ComputeSharp.Sample\ComputeSharp.Sample.csproj -c Release -f ${{matrix.framework}} -r win-x64 --no-self-contained -p:Platform=x64 -v n;
samples\ComputeSharp.Sample\bin\x64\Release\${{matrix.framework}}\win-x64\ComputeSharp.Sample.exe
- name: Build and run ComputeSharp.Sample.FSharp
run: >
dotnet build samples\ComputeSharp.Sample.FSharp\ComputeSharp.Sample.FSharp.fsproj -c Release -f ${{matrix.framework}} -r win-x64 --no-self-contained -p:Platform=x64 -v n;
samples\ComputeSharp.Sample.FSharp\bin\x64\Release\${{matrix.framework}}\win-x64\ComputeSharp.Sample.FSharp.exe
- name: Build and run ComputeSharp.ImageProcessing.csproj
run: >
dotnet build samples\ComputeSharp.ImageProcessing\ComputeSharp.ImageProcessing.csproj -c Release -f ${{matrix.framework}} -r win-x64 --no-self-contained -p:Platform=x64 -v n;
samples\ComputeSharp.ImageProcessing\bin\x64\Release\${{matrix.framework}}\win-x64\ComputeSharp.ImageProcessing.exe
# Run the NativeAOT samples as well
run-samples-aot:
needs: [build-solution]
strategy:
matrix:
platform: [x64, arm64]
runs-on: windows-2022
env:
CI_RUNNER_SAMPLES_INTEGRATION_TESTS: true
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
# Publish the NativeAOT CLI sample (optimized for speed)
- name: Publish ComputeSharp.SwapChain.Cli with NativeAOT (speed)
run: >
$env:COMPUTESHARP_SWAPCHAIN_CLI_PUBLISH_AOT='true';
dotnet publish samples\ComputeSharp.SwapChain.Cli\ComputeSharp.SwapChain.Cli.csproj -c Release -f net7.0 -r win-${{matrix.platform}} -v n
# If on x64, also run it (this script will launch it and let it run for 2 seconds, before closing it)
- if: matrix.platform == 'x64'
name: Run ComputeSharp.SwapChain.Cli (speed)
run: >
$process = (Start-Process samples\ComputeSharp.SwapChain.Cli\bin\Release\net7.0\win-x64\publish\computesharp.cli.exe -PassThru);
sleep -Seconds 2;
$process.CloseMainWindow() | Out-Null;
$process.WaitForExit();
$process.ExitCode
# Upload the binary (to track binary size trends)
- if: matrix.platform == 'x64'
name: Upload NativeAOT CLI sample (speed)
uses: actions/upload-artifact@v3
with:
name: computesharp.cli.opt-speed.exe
path: samples\ComputeSharp.SwapChain.Cli\bin\Release\net7.0\win-x64\publish\computesharp.cli.exe
if-no-files-found: error
# Publish the NativeAOT CLI sample (optimized for size, and reflection-free)
- name: Publish ComputeSharp.SwapChain.Cli with NativeAOT (size)
run: >
$env:COMPUTESHARP_SWAPCHAIN_CLI_PUBLISH_AOT='true';
$env:COMPUTESHARP_SWAPCHAIN_CLI_SIZE_OPTIMIZED='true';
$env:COMPUTESHARP_SWAPCHAIN_CLI_DISABLE_REFLECTION='true';
git clean -fdx;
dotnet publish samples\ComputeSharp.SwapChain.Cli\ComputeSharp.SwapChain.Cli.csproj -c Release -f net7.0 -r win-${{matrix.platform}} -v n
# Again only on x64, also run the sample and validate it works correctly
- if: matrix.platform == 'x64'
name: Run ComputeSharp.SwapChain.Cli (size)
run: >
$process = (Start-Process samples\ComputeSharp.SwapChain.Cli\bin\Release\net7.0\win-x64\publish\computesharp.cli.exe -PassThru);
sleep -Seconds 2;
$process.CloseMainWindow() | Out-Null;
$process.WaitForExit();
$process.ExitCode
# Upload the binary again (with a different name)
- if: matrix.platform == 'x64'
name: Upload NativeAOT CLI sample (size)
uses: actions/upload-artifact@v3
with:
name: computesharp.cli.opt-size.exe
path: samples\ComputeSharp.SwapChain.Cli\bin\Release\net7.0\win-x64\publish\computesharp.cli.exe
if-no-files-found: error
# Also publish the Win2D sample on .NET 7 (without NativeAOT, see https://github.com/dotnet/runtime/issues/84908).
- if: matrix.platform == 'x64'
name: Publish ComputeSharp.SwapChain.D2D1.Cli
run: >
msbuild samples\ComputeSharp.SwapChain.D2D1.Cli\ComputeSharp.SwapChain.D2D1.Cli.csproj -t:restore,publish /p:Configuration=Release
/p:Platform=${{matrix.platform}} /p:RuntimeIdentifier=win10-${{matrix.platform}} /p:PublishSingleFile=True /p:SelfContained=True /p:PublishTrimmed=True
# Just like for the DX12 sample, run it on x64 to validate it works correctly
- if: matrix.platform == 'x64'
name: Run ComputeSharp.SwapChain.D2D1.Cli
run: >
$process = (Start-Process samples\ComputeSharp.SwapChain.D2D1.Cli\bin\x64\Release\net7.0-windows10.0.22621\win10-x64\publish\computesharp.d2d1.cli.exe -PassThru);
sleep -Seconds 2;
$process.CloseMainWindow() | Out-Null;
$process.WaitForExit();
$process.ExitCode
# Download the NuGet packages generated in the previous job and use them
# to build and run the sample project referencing them. This is used as
# a test to ensure the NuGet packages work in a consuming project.
verify-packages:
needs: [build-packages]
strategy:
matrix:
framework: [net7.0, net6.0, net472]
runs-on: windows-2022
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Create local NuGet feed
run: mkdir artifacts
- name: Download package artifacts
uses: actions/download-artifact@v3
with:
name: nuget_packages
path: artifacts
- name: Build and run ComputeSharp.NuGet
run: dotnet run --project tests\ComputeSharp.NuGet\ComputeSharp.NuGet.csproj -c Release -f ${{matrix.framework}} -r win-x64 --no-self-contained -v n
- name: Build and run ComputeSharp.Dynamic.NuGet
run: dotnet run --project tests\ComputeSharp.Dynamic.NuGet\ComputeSharp.Dynamic.NuGet.csproj -c Release -f ${{matrix.framework}} -r win-x64 --no-self-contained -v n
- name: Build and run ComputeSharp.Pix.NuGet
run: dotnet run --project tests\ComputeSharp.Pix.NuGet\ComputeSharp.Pix.NuGet.csproj -c Release -f ${{matrix.framework}} -r win-x64 --no-self-contained -v n
# Run the extra tests to validate a number of build and publishing configurations.
# This is used to ensure the native dependencies can always be loaded correctly
# regardless of whether the app is shipping with R2R, self-contained, etc.
# Like with the source generator tests, only run these once on the .NET 6 target.
- if: matrix.framework == 'net6.0'
name: Run ComputeSharp.Tests.NativeLibrariesResolver
run: dotnet test tests\ComputeSharp.Tests.NativeLibrariesResolver\ComputeSharp.Tests.NativeLibrariesResolver.csproj -v n -l "console;verbosity=detailed"
# If on .NET 7, also run the NativeAOT publishing tests
- if: matrix.framework == 'net7.0'
name: Publish and run ComputeSharp.NuGet with NativeAOT
run: >
dotnet publish tests\ComputeSharp.NuGet\ComputeSharp.NuGet.csproj -c Release -f net7.0 -r win-x64 -v n;
tests\ComputeSharp.NuGet\bin\Release\net7.0\win-x64\publish\ComputeSharp.NuGet.exe
- if: matrix.framework == 'net7.0'
name: Publish and run ComputeSharp.Dynamic.NuGet with NativeAOT
run: >
dotnet publish tests\ComputeSharp.Dynamic.NuGet\ComputeSharp.Dynamic.NuGet.csproj -c Release -f net7.0 -r win-x64 -v n;
tests\ComputeSharp.Dynamic.NuGet\bin\Release\net7.0\win-x64\publish\ComputeSharp.Dynamic.NuGet.exe
- if: matrix.framework == 'net7.0'
name: Publish and run ComputeSharp.Pix.NuGet with NativeAOT
run: >
dotnet publish tests\ComputeSharp.Pix.NuGet\ComputeSharp.Pix.NuGet.csproj -c Release -f net7.0 -r win-x64 -v n;
tests\ComputeSharp.Pix.NuGet\bin\Release\net7.0\win-x64\publish\ComputeSharp.Pix.NuGet.exe
# Publish the packages to GitHub packages
publish-nightlies-github:
needs: [run-tests, run-tests-d3d12ma, run-tests-win2d, run-samples, run-samples-aot, verify-packages]
runs-on: windows-2022
if: ${{github.event_name == 'push'}}
steps:
- uses: actions/download-artifact@v3
with:
name: nuget_packages
path: artifacts
- run: dotnet nuget push "artifacts\*.nupkg" --source "https://nuget.pkg.github.com/${{github.repository_owner}}/index.json" --api-key ${{secrets.GITHUB_TOKEN}} --skip-duplicate
# Publish the packages to Azure DevOps
publish-nightlies-azure-devops:
needs: [run-tests, run-tests-d3d12ma, run-tests-win2d, run-samples, run-samples-aot, verify-packages]
runs-on: windows-2022
if: ${{github.event_name == 'push'}}
steps:
- uses: actions/download-artifact@v3
with:
name: nuget_packages
path: artifacts
- uses: actions/setup-dotnet@v3
with:
source-url: "https://sergio0694.pkgs.visualstudio.com/ComputeSharp/_packaging/ComputeSharp/nuget/v3/index.json"
env:
NUGET_AUTH_TOKEN: ${{ secrets.ADO_FEED_PERSONAL_ACCESS_TOKEN }}
- run: dotnet nuget push "artifacts\*.nupkg" --api-key AzureDevOps --skip-duplicate