Skip to content

Commit

Permalink
finding msbuild with a pure vs preview installation
Browse files Browse the repository at this point in the history
  • Loading branch information
ovebastiansen committed Dec 1, 2019
1 parent 9cdae50 commit d3d7160
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,20 @@ Task("Clean")
Task("Build")
.Does(() =>
{
// Find MSBuild for Visual Studio 2019 and newer
DirectoryPath vsLatest = VSWhereLatest();
FilePath msBuildPath = vsLatest?.CombineWithFilePath("./MSBuild/Current/Bin/MSBuild.exe");
// Find MSBuild for Visual Studio 2017
if (msBuildPath != null && !FileExists(msBuildPath))
msBuildPath = vsLatest.CombineWithFilePath("./MSBuild/15.0/Bin/MSBuild.exe");
// Have we found MSBuild yet?
if ( !FileExists(msBuildPath) )
// Workaround for https://github.com/cake-build/cake/issues/2128
// cannot find pure preview installations of visual studio
var vsInstallation =
VSWhereLatest(new VSWhereLatestSettings { Requires = "Microsoft.Component.MSBuild" })
?? VSWhereLatest(new VSWhereLatestSettings { Requires = "Microsoft.Component.MSBuild", IncludePrerelease = true });
if(vsInstallation == null)
{
throw new Exception($"Failed to find any Visual Studio version");
}
FilePath msBuildPath = vsInstallation.CombineWithFilePath(@"MSBuild\Current\Bin\MSBuild.exe");
if (!FileExists(msBuildPath))
{
throw new Exception($"Failed to find MSBuild: {msBuildPath}");
msBuildPath = vsInstallation.CombineWithFilePath(@"MSBuild\15.0\Bin\MSBuild.exe");
}
Information("Building using MSBuild at " + msBuildPath);
Expand Down

0 comments on commit d3d7160

Please sign in to comment.