1- name : Test .NET Package Integration
1+ name : Test package integration
22
33run-name : TestPackageIntegration_Net_${{ github.ref_name }}_${{ vars.LIBRARY_VERSION }}_${{ github.run_number }}
44
4343 include :
4444 # - os: windows-11-arm
4545 # framework: Net
46+ # rid: win-arm64
4647 - os : macos-latest
4748 framework : Net
49+ rid : osx-arm64
4850
4951 steps :
5052 - name : Checkout
6668 netframework-tfm : ${{ vars.BUILD_FRAMEWORK_NETFRAMEWORK_TFM || 'net48' }}
6769 netframework-sdk-version : ${{ vars.BUILD_FRAMEWORK_NETFRAMEWORK_SDK_VERSION || '8.0.x' }}
6870
71+ - name : Add package to the project
72+ shell : pwsh
73+ run : |
74+ Write-Host "Adding local NuGet source with the package..."
75+ dotnet nuget add source "${{ github.workspace }}/NuGetPackage"
76+
77+ Write-Host "Adding Melanchall.DryWetMidi.${{ vars.LIBRARY_VERSION }} package reference to the project..."
78+ $path = Resolve-Path 'Resources/PackageIntegrationTestUtilities/DwmNetConsoleApp/DwmNetConsoleApp/DwmNetConsoleApp.csproj'
79+ dotnet add "$path" package Melanchall.DryWetMidi -v ${{ vars.LIBRARY_VERSION }} -s "${{ github.workspace }}/NuGetPackage"
80+
81+ - name : Check csproj package reference
82+ shell : pwsh
83+ run : |
84+ $path = "Resources/PackageIntegrationTestUtilities/DwmNetConsoleApp/DwmNetConsoleApp/DwmNetConsoleApp.csproj"
85+ $expected = '<PackageReference Include="Melanchall.DryWetMidi" Version="${{ vars.LIBRARY_VERSION }}" />'
86+ Write-Host "Expecting: $expected"
87+ $found = Select-String -Path $path -Pattern $expected -SimpleMatch -Quiet
88+ if (-not $found) {
89+ Write-Error "Package reference not found: $expected"
90+ exit 1
91+ }
92+ Write-Host "Package reference found."
93+
6994 - name : Create MIDI ports (Windows)
7095 if : runner.os == 'Windows'
7196 uses : ./.github/actions/create-ports-windows
@@ -79,38 +104,75 @@ jobs:
79104 with :
80105 enabled : ' true'
81106
82- - name : Add package to the project
83- shell : pwsh
84- run : |
85- $path = Resolve-Path 'Resources/PackageIntegrationTestUtilities/DwmNetConsoleApp/DwmNetConsoleApp/DwmNetConsoleApp.csproj'
86- dotnet add "$path" package Melanchall.DryWetMidi -v ${{ vars.LIBRARY_VERSION }} -s "${{ github.workspace }}/NuGetPackage"
87-
88- - name : Set csproj elements
89- shell : pwsh
90- run : |
91- Write-Host "Parsing csproj..."
92- [xml]$xml = Get-Content -Path 'Resources/PackageIntegrationTestUtilities/DwmNetConsoleApp/DwmNetConsoleApp/DwmNetConsoleApp.csproj'
93-
94- Write-Host "Setting TFM ${{ steps.framework.outputs.tfm }}..."
95- $xml.Project.PropertyGroup.TargetFramework = '${{ steps.framework.outputs.tfm }}'
96-
97- Write-Host "Saving csproj..."
98- $path = Resolve-Path 'Resources/PackageIntegrationTestUtilities/DwmNetConsoleApp/DwmNetConsoleApp/DwmNetConsoleApp.csproj'
99- $xml.Save($path)
100-
101- Write-Host "Displaying csproj content..."
102- $content = Get-Content -Path 'Resources/PackageIntegrationTestUtilities/DwmNetConsoleApp/DwmNetConsoleApp/DwmNetConsoleApp.csproj'
103- Write-Host $content
104-
105- - name : Restore packages
107+ - name : Run app via dotnet
106108 shell : pwsh
107109 run : |
108110 $path = Resolve-Path 'Resources/PackageIntegrationTestUtilities/DwmNetConsoleApp/DwmNetConsoleApp/DwmNetConsoleApp.csproj'
109- dotnet nuget add source "${{ github.workspace }}/NuGetPackage"
110- dotnet restore "$path"
111-
112- - name : Run test program
111+ dotnet run --project "$path" --configuration ${{ vars.BUILD_CONFIGURATION }}
112+
113+ - name : Run app after publish
113114 shell : pwsh
114115 run : |
115- $path = Resolve-Path 'Resources/PackageIntegrationTestUtilities/DwmNetConsoleApp/DwmNetConsoleApp/DwmNetConsoleApp.csproj'
116- dotnet run --project "$path" --no-restore
116+ $projectPath = "Resources/PackageIntegrationTestUtilities/DwmNetConsoleApp/DwmNetConsoleApp/DwmNetConsoleApp.csproj"
117+
118+ foreach ($psf in @('true', 'false')) {
119+ foreach ($prtr in @('true', 'false')) {
120+ foreach ($inlfse in @('true', 'false')) {
121+ foreach ($sc in @('true', 'false')) {
122+ foreach ($pt in @('true', 'false')) {
123+ $publishOptions = @"
124+ SelfContained = $sc
125+ PublishSingleFile = $psf
126+ PublishReadyToRun = $prtr
127+ IncludeNativeLibrariesForSelfExtract = $inlfse
128+ PublishTrimmed = $pt
129+ " @
130+ Write-Host " $publishOptions"
131+
132+ $outputPath = "${{ runner.temp }}/publish/$rid/sc-$sc-psf-$psf-prtr-$prtr-inlfse-$inlfse-pt-$pt"
133+ Write-Host "Output path set to '$outputPath'"
134+
135+ Write-Host "Publishing the app..."
136+ dotnet publish `
137+ --configuration ${{ vars.BUILD_CONFIGURATION }} `
138+ --runtime ${{ matrix.rid }} `
139+ --self-contained=$sc `
140+ -p:PublishSingleFile=$psf `
141+ -p:PublishReadyToRun=$prtr `
142+ -p:IncludeNativeLibrariesForSelfExtract=$inlfse `
143+ -p:PublishTrimmed=$pt `
144+ -p:SolutionDir="${{ github.workspace }}/" `
145+ --output $outputPath `
146+ $projectPath
147+
148+ if ($LASTEXITCODE -ne 0) {
149+ Write-Error "Publish failed with exit code $LASTEXITCODE"
150+ exit $LASTEXITCODE
151+ }
152+
153+ Write-Host "Listing published files..."
154+ Write-Host ""
155+ Get-ChildItem -Recurse -Force -Path "$outputPath" | Format-Table @{Label="File Name"; Expression={$_.Name}}, @{Label="Size (KB)"; Expression={"{0:N2}" -f ($_.Length / 1KB)}}
156+ Write-Host ""
157+
158+ Write-Host "Running the app..."
159+ Write-Host ""
160+ if ($IsWindows) {
161+ & "$outputPath/DwmNetConsoleApp.exe"
162+ } else {
163+ & "$outputPath/DwmNetConsoleApp"
164+ }
165+
166+ if ($LASTEXITCODE -ne 0) {
167+ Write-Error "App execution failed with exit code $LASTEXITCODE"
168+ exit $LASTEXITCODE
169+ }
170+
171+ Write-Host ""
172+ Write-Host "Configuration test completed successfully"
173+ Write-Host ""
174+ }
175+ }
176+ }
177+ }
178+ }
0 commit comments