@@ -174,6 +174,16 @@ private static async Task<string> FindMsBuildPathAsync()
174174 // have VS2017 or VS2019 installed.
175175 foreach ( VSWhereFindOption findOption in VSWhereFindOptions )
176176 {
177+ string version = "" ;
178+ if ( string . IsNullOrWhiteSpace ( EditorUserBuildSettings . wsaUWPVisualStudioVersion ) )
179+ {
180+ version = "-latest" ;
181+ }
182+ else
183+ {
184+ version = $ "-version { EditorUserBuildSettings . wsaUWPVisualStudioVersion } ";
185+ }
186+
177187 var result = await new Process ( ) . StartProcessAsync (
178188 new ProcessStartInfo
179189 {
@@ -182,7 +192,7 @@ private static async Task<string> FindMsBuildPathAsync()
182192 UseShellExecute = false ,
183193 RedirectStandardOutput = true ,
184194 RedirectStandardError = true ,
185- Arguments = findOption . arguments ,
195+ Arguments = string . Format ( findOption . arguments , version ) ,
186196 WorkingDirectory = @"C:\Program Files (x86)\Microsoft Visual Studio\Installer"
187197 } ) ;
188198
@@ -623,12 +633,12 @@ public VSWhereFindOption(string args, string suffix)
623633 {
624634 // This find option corresponds to the version of vswhere that ships with VS2019.
625635 new VSWhereFindOption (
626- $ @ "/C vswhere -all -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe",
636+ @"/C vswhere -all -products * {0} -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe" ,
627637 "" ) ,
628638 // This find option corresponds to the version of vswhere that ships with VS2017 - this doesn't have
629639 // support for the -find command switch.
630640 new VSWhereFindOption (
631- $ @ "/C vswhere -all -products * -requires Microsoft.Component.MSBuild -property installationPath",
641+ @"/C vswhere -all -products * -requires Microsoft.Component.MSBuild -property installationPath" ,
632642 "\\ MSBuild\\ 15.0\\ Bin\\ MSBuild.exe" ) ,
633643 } ;
634644 }
0 commit comments