【发布时间】:2017-03-31 06:46:51
【问题描述】:
在尝试在仅知道 Visual Studio 2017 的机器上使用 Cake v0.19.1 构建解决方案时,我似乎无法让 NuGetRestore 接受 MSBuildVersion = NuGetMSBuildVersion.MSBuild15 的设置。
是否有一些神奇的步骤可以将特定的 MSBuild 版本导入我缺少的 NuGetRestore?
输出
...
========================================
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's answer,我将 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
【问题讨论】:
标签: cakebuild