Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for MSBuild 16 / VS 2019 #2274

Merged
merged 2 commits into from
Mar 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions src/app/Fake.DotNet.MSBuild/MSBuild.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ open Fake.Core
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
open Fake.Core

/// A type to represent MSBuild project files.
type MSBuildProject = XDocument
Expand Down Expand Up @@ -90,22 +89,23 @@ type MSBuildLoggerConfig = MSBuildDistributedLoggerConfig
#if !NO_VSWHERE // legacy fakelib
module private MSBuildExeFromVsWhere =
open BlackFox.VsWhere
open System.Text.RegularExpressions
open System.Diagnostics

let private getAllVsPath () =
VsInstances.getWithPackage "Microsoft.Component.MSBuild" false
|> List.map (fun vs -> vs.InstallationPath)

let private re = lazy(Regex(@"^\d+\.\d+$", RegexOptions.Compiled))

let private getAllMsBuildPaths vsPath =
let versionsDir = Path.Combine(vsPath, "MSBuild")
if Directory.Exists(versionsDir) then
Directory.EnumerateDirectories(versionsDir)
|> Seq.map (fun d -> Path.GetFileName(d), d)
|> Seq.filter (fun (v, _) -> re.Value.IsMatch v)
|> Seq.map (fun (v, d) -> v, Path.Combine(d, "Bin"))
|> Seq.filter (fun (_, f) -> Directory.Exists(f))
let msBuildDir = Path.Combine(vsPath, "MSBuild")
if Directory.Exists(msBuildDir) then
Directory.EnumerateDirectories(msBuildDir)
|> Seq.map (fun dir -> Path.Combine(dir, "Bin", "MSBuild.exe"))
|> Seq.choose(fun exe ->
if File.Exists(exe) then
let v = FileVersionInfo.GetVersionInfo(exe)
Some (sprintf "%d.0" v.FileMajorPart, Path.GetDirectoryName(exe))
else
None)
|> List.ofSeq
else
[]
Expand Down Expand Up @@ -245,6 +245,8 @@ module private MSBuildExe =
Trace.traceFAKE "If you encounter msbuild errors make sure you have copied the required SDKs, see https://github.com/Microsoft/msbuild/issues/1697"
elif foundExe.Contains @"\2017\" then
Trace.logVerbosefn "Using msbuild of VS2017 (%s), if you encounter build errors make sure you have installed the necessary workflows!" foundExe
elif foundExe.Contains @"\2019\" then
Trace.logVerbosefn "Using msbuild of VS2019 (%s), if you encounter build errors make sure you have installed the necessary workflows!" foundExe
foundExe

/// A type for MSBuild task parameters
Expand Down Expand Up @@ -984,4 +986,4 @@ module MSBuild =
module internal MSBuildParamExtensions =
type MSBuildParams with
member internal x.CliArguments = MSBuild.asCliArguments x
member internal oldObj.WithCliArguments (x:MSBuild.CliArguments) = MSBuild.withCliArguments oldObj x
member internal oldObj.WithCliArguments (x:MSBuild.CliArguments) = MSBuild.withCliArguments oldObj x