From 86299f8f76ac817d638cddb41c198f837c2d4a16 Mon Sep 17 00:00:00 2001 From: Meera Ruxmohan Date: Tue, 18 Feb 2025 18:39:07 -0800 Subject: [PATCH] Use msbuild dll path where applicable for obtaining appropriate version (#665) --- src/Microsoft.VisualStudio.SlnGen/Program.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.VisualStudio.SlnGen/Program.cs b/src/Microsoft.VisualStudio.SlnGen/Program.cs index 307128b..e34efee 100644 --- a/src/Microsoft.VisualStudio.SlnGen/Program.cs +++ b/src/Microsoft.VisualStudio.SlnGen/Program.cs @@ -145,7 +145,13 @@ internal static int Execute(ProgramArguments arguments, IConsole console) bool useSimpleCache = true; - var msbuildVersion = FileVersionInfo.GetVersionInfo(CurrentDevelopmentEnvironment.MSBuildExe.FullName); +#if NETFRAMEWORK + string msBuildPath = CurrentDevelopmentEnvironment.MSBuildExe.FullName; +#else + string msBuildPath = CurrentDevelopmentEnvironment.MSBuildDll.FullName; +#endif + + var msbuildVersion = FileVersionInfo.GetVersionInfo(msBuildPath); // Work around https://github.com/dotnet/msbuild/issues/11394 by falling back to the slower PRE cache // on known-affected MSBuild versions (this should be much more tightly scoped after that bug is fixed). @@ -159,11 +165,7 @@ internal static int Execute(ProgramArguments arguments, IConsole console) CacheFileEnumerations = true, LoadAllFilesAsReadOnly = true, UseSimpleProjectRootElementCacheConcurrency = useSimpleCache, -#if NETFRAMEWORK - MSBuildExePath = CurrentDevelopmentEnvironment.MSBuildExe.FullName, -#else - MSBuildExePath = CurrentDevelopmentEnvironment.MSBuildDll.FullName, -#endif + MSBuildExePath = msBuildPath, }; LoggerVerbosity verbosity = ForwardingLogger.ParseLoggerVerbosity(arguments.Verbosity?.LastOrDefault());