Skip to content

Commit

Permalink
Merge pull request #680 from ovebastiansen/issue-679-vspreviewbuild
Browse files Browse the repository at this point in the history
finding msbuild with a pure vs preview installation
  • Loading branch information
OsirisTerje authored Dec 1, 2019
2 parents 9cdae50 + d3d7160 commit 32666d8
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 32666d8

Please sign in to comment.