在尝试在仅知道 Visual Studio 2017 的机器上使用 Cake v0.19.1 构建解决方案时,我似乎无法NuGetRestore
接受MSBuildVersion = NuGetMSBuildVersion.MSBuild15
.
是否有一些神奇的步骤可以让NuGetRestore
我缺少特定的 MSBuild 版本?
输出
...
========================================
RestoreNuGet
========================================
Executing task: RestoreNuGet
Failed to load msbuild Toolset
Could not load file or assembly 'Microsoft.Build, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
An error occurred when executing task 'RestoreNuGet'.
Error: NuGet: Process returned an error (exit code 1).
精简的 build.cake
var target = Argument("target", "Default");
var solution = "./some-random.sln";
Task("Default")
.Does(() => {
NuGetRestore(
solution,
new NuGetRestoreSettings {
MSBuildVersion = NuGetMSBuildVersion.MSBuild15,
}
);
});
RunTarget(target);
更新:获取 NuGet v4
根据@devlead 的回答,我将 build.ps1 文件指向 NuGet 的 v4.0.0 并得到了这个输出。
Cannot find the specified version of msbuild: '15'
An error occurred when executing task 'RestoreNuGet'.
Error: NuGet: Process returned an error (exit code 1).
在我的完整 build.cake 中,我vswhere
稍后使用MSBuildSettings
它可以转储它找到的 MSBuild 路径(并且我确认 exe 存在于资源管理器中)。
C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/MSBuild/15.0/Bin/amd64/MSBuild.exe