1717 - uses : actions/checkout@v4
1818 name : Checkout the repository
1919
20- # Step 2: Setup Visual Studio Build Tools
21- - name : Setup Visual Studio Build Tools
22- 20+ # Step 2: Setup Visual Studio Environment
21+ - name : Setup Visual Studio Environment
22+ run : |
23+ # Find Visual Studio installation
24+ $vsPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
25+ if ($vsPath) {
26+ Write-Host "Found Visual Studio at: $vsPath"
27+ # Set up environment variables
28+ & "$vsPath\VC\Auxiliary\Build\vcvars64.bat" | Out-String
29+ $env:PATH = "$vsPath\VC\Tools\MSVC\14.37.32822\bin\Hostx64\x64;$env:PATH"
30+ } else {
31+ Write-Host "Visual Studio not found, trying to install build tools..."
32+ # Download and install Visual Studio Build Tools
33+ $vsInstaller = "vs_buildtools.exe"
34+ Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vs_buildtools.exe" -OutFile $vsInstaller
35+ Start-Process -FilePath $vsInstaller -ArgumentList "--quiet", "--wait", "--norestart", "--nocache", "--installPath", "C:\BuildTools", "--add", "Microsoft.VisualStudio.Workload.VCTools" -Wait
36+ Remove-Item $vsInstaller
37+ $env:PATH = "C:\BuildTools\VC\Tools\MSVC\14.37.32822\bin\Hostx64\x64;$env:PATH"
38+ }
2339
2440 # Step 3: Setup CMake
2541 - name : Setup CMake
@@ -40,20 +56,28 @@ jobs:
4056
4157 # Step 5: Verify tools availability
4258 - name : Verify tools
59+ shell : cmd
4360 run : |
61+ call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
4462 cmake --version
4563 ninja --version
4664 cl
47- echo " Using Visual Studio compiler:"
48- cl 2>&1 | Select-String "Microsoft"
65+ echo Using Visual Studio compiler:
66+ cl
4967
5068 # Step 6: Configure CMake with Visual Studio
5169 - name : Configure CMake
52- run : cmake -S . -G "Ninja Multi-Config" -B build -DCMAKE_CXX_FLAGS="/W3" -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl
70+ shell : cmd
71+ run : |
72+ call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
73+ cmake -S . -G "Ninja Multi-Config" -B build -DCMAKE_CXX_FLAGS="/W3" -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl
5374
5475 # Step 7: Build with CMake
5576 - name : Build with CMake
56- run : cmake --build build --config Release
77+ shell : cmd
78+ run : |
79+ call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
80+ cmake --build build --config Release
5781
5882 # Step 8: Verify if build files are generated
5983 - name : List build directory contents
@@ -96,9 +120,25 @@ jobs:
96120 - uses : actions/checkout@v4
97121 name : Checkout the repository
98122
99- # Step 2: Setup Visual Studio Build Tools
100- - name : Setup Visual Studio Build Tools
101- 123+ # Step 2: Setup Visual Studio Environment
124+ - name : Setup Visual Studio Environment
125+ run : |
126+ # Find Visual Studio installation
127+ $vsPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
128+ if ($vsPath) {
129+ Write-Host "Found Visual Studio at: $vsPath"
130+ # Set up environment variables
131+ & "$vsPath\VC\Auxiliary\Build\vcvars64.bat" | Out-String
132+ $env:PATH = "$vsPath\VC\Tools\MSVC\14.37.32822\bin\Hostx64\x64;$env:PATH"
133+ } else {
134+ Write-Host "Visual Studio not found, trying to install build tools..."
135+ # Download and install Visual Studio Build Tools
136+ $vsInstaller = "vs_buildtools.exe"
137+ Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vs_buildtools.exe" -OutFile $vsInstaller
138+ Start-Process -FilePath $vsInstaller -ArgumentList "--quiet", "--wait", "--norestart", "--nocache", "--installPath", "C:\BuildTools", "--add", "Microsoft.VisualStudio.Workload.VCTools" -Wait
139+ Remove-Item $vsInstaller
140+ $env:PATH = "C:\BuildTools\VC\Tools\MSVC\14.37.32822\bin\Hostx64\x64;$env:PATH"
141+ }
102142
103143 # Step 3: Create a GitHub release using the version tag (e.g., v1.0.0, v1.0.1)
104144 - name : Create Release
0 commit comments