Skip to content

Commit 1e48d4e

Browse files
fix msbuild
1 parent 492f859 commit 1e48d4e

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

.github/workflows/test.yaml

+22-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: .NET Test 🚀
22

3-
on: [push, pull_request]
3+
on: [ push, pull_request ]
44

55
jobs:
66
build:
@@ -33,19 +33,10 @@ jobs:
3333
with:
3434
nuget-version: '5.x'
3535

36-
# 4. Set MSBuild Path (for .NET Framework)
37-
- name: Set MSBuild Path
36+
# 4. Add MSBuild to PATH (for .NET Framework)
37+
- name: Add MSBuild to PATH
3838
if: contains(matrix.framework, 'v')
39-
shell: pwsh
40-
run: |
41-
Write-Host "🔧 Setting MSBuild path for .NET Framework..."
42-
$msbuildPath = &"C:\Program Files\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe
43-
if (-not $msbuildPath) {
44-
Write-Error "❌ MSBuild not found!"
45-
exit 1
46-
}
47-
Write-Host "✅ MSBuild found at: $msbuildPath"
48-
echo "MSBUILD_PATH=$msbuildPath" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8
39+
uses: microsoft/setup-msbuild@v2
4940

5041
# 5. Restore Dependencies
5142
- name: Restore Dependencies
@@ -60,8 +51,12 @@ jobs:
6051
shell: pwsh
6152
run: |
6253
Write-Host "⚒️ Building for: ${{ matrix.framework }}"
63-
if ("${{ matrix.framework }}" -notlike "v*") { dotnet build --configuration Release --no-restore }
64-
if ("${{ matrix.framework }}" -like "v*") { & $env:MSBUILD_PATH CloudinaryDotNet.sln /p:Configuration=Release /p:TargetFrameworkVersion=${{ matrix.framework }} }
54+
if ("${{ matrix.framework }}" -notlike "v*") {
55+
dotnet build --configuration Release --no-restore
56+
}
57+
if ("${{ matrix.framework }}" -like "v*") {
58+
msbuild CloudinaryDotNet.sln /p:Configuration=Release /p:TargetFrameworkVersion=${{ matrix.framework }}
59+
}
6560
6661
# 7. Run before_build.ps1
6762
- name: Run before_build.ps1
@@ -73,13 +68,21 @@ jobs:
7368
shell: pwsh
7469
run: |
7570
Write-Host "🧪 Running Unit Tests for: ${{ matrix.framework }}"
76-
if ("${{ matrix.framework }}" -notlike "v*") { dotnet test "./CloudinaryDotNet.Tests/CloudinaryDotNet.Tests.csproj" --configuration Release --no-build }
77-
if ("${{ matrix.framework }}" -like "v*") { vstest.console.exe "./CloudinaryDotNet.Tests/bin/Release/${{ matrix.framework }}/CloudinaryDotNet.Tests.dll" /Framework:${{ matrix.framework }} }
71+
if ("${{ matrix.framework }}" -notlike "v*") {
72+
dotnet test "./CloudinaryDotNet.Tests/CloudinaryDotNet.Tests.csproj" --configuration Release --no-build
73+
}
74+
if ("${{ matrix.framework }}" -like "v*") {
75+
vstest.console.exe "./CloudinaryDotNet.Tests/bin/Release/${{ matrix.framework }}/CloudinaryDotNet.Tests.dll" /Framework:${{ matrix.framework }}
76+
}
7877
7978
# 9. Run Integration Tests
8079
- name: Run Integration Tests
8180
shell: pwsh
8281
run: |
8382
Write-Host "🧪 Running Integration Tests for: ${{ matrix.framework }}"
84-
if ("${{ matrix.framework }}" -notlike "v*") { dotnet test "./CloudinaryDotNet.IntegrationTests/CloudinaryDotNet.IntegrationTests.csproj" --configuration Release --no-build }
85-
if ("${{ matrix.framework }}" -like "v*") { vstest.console.exe "./CloudinaryDotNet.IntegrationTests/bin/Release/${{ matrix.framework }}/CloudinaryDotNet.IntegrationTests.dll" /Framework:${{ matrix.framework }} }
83+
if ("${{ matrix.framework }}" -notlike "v*") {
84+
dotnet test "./CloudinaryDotNet.IntegrationTests/CloudinaryDotNet.IntegrationTests.csproj" --configuration Release --no-build
85+
}
86+
if ("${{ matrix.framework }}" -like "v*") {
87+
vstest.console.exe "./CloudinaryDotNet.IntegrationTests/bin/Release/${{ matrix.framework }}/CloudinaryDotNet.IntegrationTests.dll" /Framework:${{ matrix.framework }}
88+
}

0 commit comments

Comments
 (0)