17
17
- uses : actions/checkout@v4
18
18
name : Checkout the repository
19
19
20
- # Step 2: Setup Visual Studio Build Tools
21
- - name : Setup Visual Studio Build Tools
22
- uses : microsoft/setup-msbuild@v1.3.1
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
+ }
23
39
24
40
# Step 3: Setup CMake
25
41
- name : Setup CMake
@@ -40,20 +56,28 @@ jobs:
40
56
41
57
# Step 5: Verify tools availability
42
58
- name : Verify tools
59
+ shell : cmd
43
60
run : |
61
+ call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
44
62
cmake --version
45
63
ninja --version
46
64
cl
47
- echo " Using Visual Studio compiler:"
48
- cl 2>&1 | Select-String "Microsoft"
65
+ echo Using Visual Studio compiler:
66
+ cl
49
67
50
68
# Step 6: Configure CMake with Visual Studio
51
69
- 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
53
74
54
75
# Step 7: Build with CMake
55
76
- 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
57
81
58
82
# Step 8: Verify if build files are generated
59
83
- name : List build directory contents
@@ -96,9 +120,25 @@ jobs:
96
120
- uses : actions/checkout@v4
97
121
name : Checkout the repository
98
122
99
- # Step 2: Setup Visual Studio Build Tools
100
- - name : Setup Visual Studio Build Tools
101
- uses : microsoft/setup-msbuild@v1.3.1
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
+ }
102
142
103
143
# Step 3: Create a GitHub release using the version tag (e.g., v1.0.0, v1.0.1)
104
144
- name : Create Release
0 commit comments