-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 将`cmd`替换为`powershell`以提升脚本的现代性和兼容性 - 引入`vswhere`自动定位Visual Studio,移除了硬编码的`vcvarsall.bat`路径 - 新增`setVsDev.ps1`脚本来自动化开发环境的设置,包括Visual Studio的定位和开发命令的执行 - 通过引入参数化的`setVsDev.ps1`脚本,增强了构建流程的灵活性,允许用户根据需要选择Visual Studio的版本和架构 - 保留了与旧流程的兼容性,确保现有工作流可以无缝迁移到新的构建系统 - 优化了`.github/workflows/cmake.yml`和`.github/workflows/qmake.yml`文件,以适应新的构建环境设置 - 在`scripts/windows/`目录下添加了新的PowerShell脚本`setVsDev.ps1`,用于更灵活地设置和进入Visual Studio开发环境
- Loading branch information
Showing
4 changed files
with
84 additions
and
23 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
param( | ||
[Parameter(Mandatory = $false)] | ||
[string]$VersionRange, | ||
[Parameter(Mandatory = $false)] | ||
[string]$Arch | ||
) | ||
|
||
|
||
$vswhereArgs = @() | ||
|
||
if ($VersionRange) { | ||
$vswhereArgs += "-version" | ||
$vswhereArgs += $VersionRange | ||
} | ||
else { | ||
$vswhereArgs += "-latest" | ||
} | ||
|
||
|
||
$vswhereArgs += "-property" | ||
$vswhereArgs += "installationPath" | ||
|
||
if ([string]::IsNullOrEmpty($Arch)) { | ||
$Arch = "x64" | ||
} | ||
|
||
Write-Host "Architecture: $Arch" | ||
Write-Host "VSWhere Args: $vswhereArgs" | ||
|
||
# 使用 vswhere 获取 Visual Studio 的安装路径 | ||
$vswherePath = "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" | ||
$vsInstallPath = & $vswherePath $vswhereArgs | ForEach-Object { $_ } | ||
# Output the results | ||
Write-Host "Visual Studio installation paths:" | ||
$vsInstallPath | ||
|
||
if ($null -ne $vsInstallPath) { | ||
$vsDevShell = Join-Path $vsInstallPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll" | ||
if (-not (Test-Path $vsDevShell)) { | ||
Write-Host "Failed to find Visual Studio DevShell DLL: $vsDevShell" | ||
exit 1 | ||
} | ||
Import-Module $vsDevShell | ||
Enter-VsDevShell -VsInstallPath $vsInstallPath -DevCmdArguments "-arch=$Arch -host_arch=$Arch" -SkipAutomaticLocation | ||
|
||
if ($LASTEXITCODE -eq 0) { | ||
Write-Host "Development environment set up successfully." | ||
} | ||
else { | ||
Write-Host "Failed to set up the development environment." | ||
} | ||
} | ||
else { | ||
Write-Host "Using Custom Visual Studio installation path." | ||
$vsInstallPath = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" | ||
if (-not (Test-Path $vsInstallPath)) { | ||
$vsInstallPath = "C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise" | ||
} | ||
$vsDevShell = Join-Path $vsInstallPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll" | ||
Import-Module $vsDevShell | ||
Enter-VsDevShell -VsInstallPath $vsInstallPath -DevCmdArguments "-arch=x64 -host_arch=x64" -SkipAutomaticLocation | ||
} |