@@ -174,6 +174,17 @@ private static async Task<string> FindMsBuildPathAsync()
174174 // have VS2017 or VS2019 installed.
175175 foreach ( VSWhereFindOption findOption in VSWhereFindOptions )
176176 {
177+ string arguments = findOption . arguments ;
178+ if ( string . IsNullOrWhiteSpace ( EditorUserBuildSettings . wsaUWPVisualStudioVersion ) )
179+ {
180+ arguments += " -latest" ;
181+ }
182+ else
183+ {
184+ // Add version number with brackets to find only the specified version
185+ arguments += $ " -version [{ EditorUserBuildSettings . wsaUWPVisualStudioVersion } ]";
186+ }
187+
177188 var result = await new Process ( ) . StartProcessAsync (
178189 new ProcessStartInfo
179190 {
@@ -182,7 +193,7 @@ private static async Task<string> FindMsBuildPathAsync()
182193 UseShellExecute = false ,
183194 RedirectStandardOutput = true ,
184195 RedirectStandardError = true ,
185- Arguments = findOption . arguments ,
196+ Arguments = arguments ,
186197 WorkingDirectory = @"C:\Program Files (x86)\Microsoft Visual Studio\Installer"
187198 } ) ;
188199
@@ -623,12 +634,12 @@ public VSWhereFindOption(string args, string suffix)
623634 {
624635 // This find option corresponds to the version of vswhere that ships with VS2019.
625636 new VSWhereFindOption (
626- $ @ "/C vswhere -all -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe",
637+ @"/C vswhere -all -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe" ,
627638 "" ) ,
628639 // This find option corresponds to the version of vswhere that ships with VS2017 - this doesn't have
629640 // support for the -find command switch.
630641 new VSWhereFindOption (
631- $ @ "/C vswhere -all -products * -requires Microsoft.Component.MSBuild -property installationPath",
642+ @"/C vswhere -all -products * -requires Microsoft.Component.MSBuild -property installationPath" ,
632643 "\\ MSBuild\\ 15.0\\ Bin\\ MSBuild.exe" ) ,
633644 } ;
634645 }
0 commit comments