Skip to content

Commit

Permalink
Final Fix for OData#324
Browse files Browse the repository at this point in the history
  • Loading branch information
pbru87 committed Jan 29, 2024
1 parent 50ee737 commit 15f2067
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/Microsoft.OData.Cli/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.CommandLine;
using System.CommandLine;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
Expand All @@ -24,14 +23,18 @@ static async Task Main(string[] args)
/// </summary>
private static void RegisterMsBuild()
{
string pathToMsBuildExeInLatestVisualStudioVersion = string.Empty;
const string defaultInstallDirOfVisualStudio = @"C:\Program Files\Microsoft Visual Studio\";
var installDirOfLatestVisualStudio = Directory.GetDirectories(defaultInstallDirOfVisualStudio, "????", SearchOption.TopDirectoryOnly)
.Where(x => Path.GetFileName(x).All(char.IsDigit))
.MaxBy(x => Path.GetFileName(x));
if (Directory.Exists(defaultInstallDirOfVisualStudio))
{
var installDirOfLatestVisualStudio = Directory.GetDirectories(defaultInstallDirOfVisualStudio, "????", SearchOption.TopDirectoryOnly)
.Where(x => Path.GetFileName(x).All(char.IsDigit))
.MaxBy(x => Path.GetFileName(x));

string pathToMsBuildExeInLatestVisualStudioVersion = Path.Combine(
Directory.GetDirectories(installDirOfLatestVisualStudio, "*", SearchOption.TopDirectoryOnly).FirstOrDefault() ?? string.Empty,
"MSBuild", "Current", "Bin", "MSBuild.exe");
pathToMsBuildExeInLatestVisualStudioVersion = Path.Combine(
Directory.GetDirectories(installDirOfLatestVisualStudio, "*", SearchOption.TopDirectoryOnly).FirstOrDefault() ?? string.Empty,
"MSBuild", "Current", "Bin", "MSBuild.exe");
}

if (File.Exists(pathToMsBuildExeInLatestVisualStudioVersion))
{
Expand All @@ -43,4 +46,4 @@ private static void RegisterMsBuild()
}
}
}
}
}

0 comments on commit 15f2067

Please sign in to comment.