Skip to content

Commit 23c5840

Browse files
authored
Support for Visual Studio 2019 / MSBuild 16.0 (#23)
1 parent a3bccb2 commit 23c5840

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/MSBuildProjectCreator/MSBuildAssemblyResolver.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@ public static class MSBuildAssemblyResolver
1717
() =>
1818
{
1919
string visualStudioDirectory;
20+
string msbuildVersionDirectory = Environment.GetEnvironmentVariable("VISUALSTUDIOVERSION") ?? "15.0";
21+
22+
if (Version.TryParse(msbuildVersionDirectory, out Version visualStudioVersion) && visualStudioVersion.Major >= 16)
23+
{
24+
msbuildVersionDirectory = "Current";
25+
}
2026

2127
if (!String.IsNullOrWhiteSpace(visualStudioDirectory = Environment.GetEnvironmentVariable("VSINSTALLDIR")))
2228
{
23-
return Path.Combine(visualStudioDirectory, "MSBuild", "15.0", "Bin");
29+
return Path.Combine(visualStudioDirectory, "MSBuild", msbuildVersionDirectory, "Bin");
2430
}
2531

2632
if (!String.IsNullOrWhiteSpace(visualStudioDirectory = Environment.GetEnvironmentVariable("VSAPPIDDIR")))
2733
{
28-
return Path.Combine(visualStudioDirectory, "..", "..", "MSBuild", "15.0", "Bin");
34+
return Path.GetFullPath(Path.Combine(visualStudioDirectory, "..", "..", "MSBuild", msbuildVersionDirectory, "Bin"));
2935
}
3036

3137
foreach (string path in (Environment.GetEnvironmentVariable("PATH") ?? String.Empty).Split(PathSplitChars, StringSplitOptions.RemoveEmptyEntries))

0 commit comments

Comments
 (0)