msbuild fix #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: .NET Test π | |
on: [push, pull_request] | |
jobs: | |
build: | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
framework: | |
- 9.0.x | |
- 8.0.x | |
- v4.8.1 | |
- v4.5.2 | |
steps: | |
# 1. Checkout repository | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
# 2. Setup .NET SDK (for .NET Core / Modern .NET) | |
- name: Setup .NET SDK | |
if: "!startsWith(matrix.framework, 'v')" | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ matrix.framework }} | |
# 3. Install NuGet CLI (for .NET Framework) | |
- name: Install NuGet CLI | |
if: startsWith(matrix.framework, 'v') | |
uses: NuGet/setup-nuget@v2 | |
with: | |
nuget-version: '5.x' | |
# 4. Set MSBuild Path (for .NET Framework) | |
- name: Set MSBuild Path | |
if: contains(matrix.framework, 'v') | |
shell: pwsh | |
run: | | |
Write-Host "π§ Setting MSBuild path for .NET Framework..." | |
$msbuildPath = &"C:\Program Files\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe | |
if (-not $msbuildPath) { | |
Write-Error "β MSBuild not found!" | |
exit 1 | |
} | |
Write-Host "β MSBuild found at: $msbuildPath" | |
echo "MSBUILD_PATH=$msbuildPath" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 | |
# 5. Restore Dependencies | |
- name: Restore Dependencies | |
shell: pwsh | |
run: | | |
Write-Host "π Restoring dependencies for: ${{ matrix.framework }}" | |
if ("${{ matrix.framework }}" -notlike "v*") { dotnet restore } | |
if ("${{ matrix.framework }}" -like "v*") { nuget.exe restore CloudinaryDotNet.sln } | |
# 6. Build Solution | |
- name: Build Solution | |
shell: pwsh | |
run: | | |
Write-Host "βοΈ Building for: ${{ matrix.framework }}" | |
if ("${{ matrix.framework }}" -notlike "v*") { dotnet build --configuration Release --no-restore } | |
if ("${{ matrix.framework }}" -like "v*") { & $env:MSBUILD_PATH CloudinaryDotNet.sln /p:Configuration=Release /p:TargetFrameworkVersion=${{ matrix.framework }} } | |
# 7. Run before_build.ps1 | |
- name: Run before_build.ps1 | |
shell: pwsh | |
run: . ./before_build.ps1 | |
# 8. Run Unit Tests | |
- name: Run Unit Tests | |
shell: pwsh | |
run: | | |
Write-Host "π§ͺ Running Unit Tests for: ${{ matrix.framework }}" | |
if ("${{ matrix.framework }}" -notlike "v*") { dotnet test "./CloudinaryDotNet.Tests/CloudinaryDotNet.Tests.csproj" --configuration Release --no-build } | |
if ("${{ matrix.framework }}" -like "v*") { vstest.console.exe "./CloudinaryDotNet.Tests/bin/Release/${{ matrix.framework }}/CloudinaryDotNet.Tests.dll" /Framework:${{ matrix.framework }} } | |
# 9. Run Integration Tests | |
- name: Run Integration Tests | |
shell: pwsh | |
run: | | |
Write-Host "π§ͺ Running Integration Tests for: ${{ matrix.framework }}" | |
if ("${{ matrix.framework }}" -notlike "v*") { dotnet test "./CloudinaryDotNet.IntegrationTests/CloudinaryDotNet.IntegrationTests.csproj" --configuration Release --no-build } | |
if ("${{ matrix.framework }}" -like "v*") { vstest.console.exe "./CloudinaryDotNet.IntegrationTests/bin/Release/${{ matrix.framework }}/CloudinaryDotNet.IntegrationTests.dll" /Framework:${{ matrix.framework }} } |