徐州市政建设集团公司网站,某某公司电子商务网站建设与维护,做的公司网站风格跟样式和别人一样,网件路由器无线中继缘由
需要使用vcpkg中低版本的第三方库#xff0c;下载vcpkg后#xff0c;回退至指定版本#xff0c;运行bootstrap-vcpkg.bat生成vcpkg.exe时#xff0c;命令行窗口总是一闪而过#xff0c;但是vcpkg.exe却没有生成。
添加pause#xff0c;查看错误
编辑bootstrap-vc…缘由
需要使用vcpkg中低版本的第三方库下载vcpkg后回退至指定版本运行bootstrap-vcpkg.bat生成vcpkg.exe时命令行窗口总是一闪而过但是vcpkg.exe却没有生成。
添加pause查看错误
编辑bootstrap-vcpkg.bat在末尾添加pause使之暂停显示错误
问题1网络问题
下载失败多尝试几遍或者使用其他魔法
问题2编译失败 继续查看bootstrap-vcpkg.bat
echo off
powershell.exe -NoProfile -ExecutionPolicy Bypass { %~dp0scripts\bootstrap.ps1}
pause打开scripts\bootstrap.ps1查看调试并分析MSBuild.exe目录可能与以下代码有关
$msbuildExeWithPlatformToolset $scriptsDir\findAnyMSBuildWithCppPlatformToolset.ps1 $withVSPath
$msbuildExe $msbuildExeWithPlatformToolset[0]
$platformToolset $msbuildExeWithPlatformToolset[1]
$windowsSDK $scriptsDir\getWindowsSDK.ps1继续打开findAnyMSBuildWithCppPlatformToolset.ps1
[CmdletBinding()]
param([Parameter(Mandatory$False)][string]$withVSPath
)Set-StrictMode -Version Latest
$scriptsDir split-path -parent $script:MyInvocation.MyCommand.Definition$withVSPath $withVSPath -replace \\$ # Remove potential trailing backslash$VisualStudioInstallationInstances $scriptsDir\findVisualStudioInstallationInstances.ps1
if ($VisualStudioInstallationInstances -eq $null)
{throw Could not find Visual Studio. VS2015 or VS2017 (with C) needs to be installed.
}Write-Verbose VS Candidates:nr$([system.String]::Join([Environment]::NewLine, $VisualStudioInstallationInstances))
foreach ($instanceCandidateWithEOL in $VisualStudioInstallationInstances)
{$instanceCandidate $instanceCandidateWithEOL -replace sol:: -replace ::eolWrite-Verbose Inspecting: $instanceCandidate$split $instanceCandidate -split ::# $preferenceWeight $split[0]# $releaseType $split[1]$version $split[2]$path $split[3]if ($withVSPath -ne -and $withVSPath -ne $path){Write-Verbose Skipping: $instanceCandidatecontinue}$majorVersion $version.Substring(0,2);if ($majorVersion -eq 15){$VCFolder $path\VC\Tools\MSVC\if (Test-Path $VCFolder){Write-Verbose Picking: $instanceCandidatereturn $path\MSBuild\15.0\Bin\MSBuild.exe, v141}}if ($majorVersion -eq 14){$clExe $path\VC\bin\cl.exeif (Test-Path $clExe){Write-Verbose Picking: $instanceCandidate$programFilesPath $scriptsDir\getProgramFiles32bit.ps1return $programFilesPath\MSBuild\14.0\Bin\MSBuild.exe, v140}}
}throw Could not find MSBuild version with C support. VS2015 or VS2017 (with C) needs to be installed.可以看到由于版本较旧只支持了VS2015 和 VS2017但是我的机子安装的是VS2022所以导致了MSBuild.exe目录查找失败
尝试修改返回值
修改成自己机子上的VS安装目录
[CmdletBinding()]
param([Parameter(Mandatory$False)][string]$withVSPath
)return D:\CodingTools\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe, v143以下省略...运行编译失败可能是编译器太新使用的C版本不兼容继续修改 这里我修改成了2017的编译器版本如果没有安装2015或者2017可能需要在已安装的机子上运行后拷贝过来或者修改VS安装对应的编译器
return D:\CodingTools\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe, v141编译成功成功生成vcpkg.exe
注意
这个方法只试用与刚clone的vcpkg如果克隆后有安装过第三方库再使用改方法可能会导致vcpkg报错版本不兼容