When I try to install a build solution using Cake v0.19.1 on a machine that only ever knew Visual Studio 2017, I cannot get NuGetRestore
to accept the parameter MSBuildVersion = NuGetMSBuildVersion.MSBuild15
.
Is there any magic step to getting a specific version of MSBuild in NuGetRestore
that I am missing?
Exit
...
========================================
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).
Trimmed-down build.cake
var target = Argument("target", "Default");
var solution = "./some-random.sln";
Task("Default")
.Does(() => {
NuGetRestore(
solution,
new NuGetRestoreSettings {
MSBuildVersion = NuGetMSBuildVersion.MSBuild15,
}
);
});
RunTarget(target);
Update: getting NuGet v4
Per @devlead answer , I pointed the build.ps1 file to v4.0.0 from NuGet and got this output.
Cannot find the specified version of msbuild: '15'
An error occurred when executing task 'RestoreNuGet'.
Error: NuGet: Process returned an error (exit code 1).
In my complete build.cake, I use vswhere
for later MSBuildSettings
, which I can get to unload the found MSBuild path (and I confirmed that exe exists in Explorer).
C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/MSBuild/15.0/Bin/amd64/MSBuild.exe