@@ -134,7 +134,9 @@ pub fn find_vs_version() -> Result<VsVers, String> {
134134 _ => {
135135 // Check for the presence of a specific registry key
136136 // that indicates visual studio is installed.
137- if impl_:: has_msbuild_version ( "16.0" ) {
137+ if impl_:: has_msbuild_version ( "17.0" ) {
138+ Ok ( VsVers :: Vs17 )
139+ } else if impl_:: has_msbuild_version ( "16.0" ) {
138140 Ok ( VsVers :: Vs16 )
139141 } else if impl_:: has_msbuild_version ( "15.0" ) {
140142 Ok ( VsVers :: Vs15 )
@@ -250,27 +252,31 @@ mod impl_ {
250252 }
251253 }
252254
255+ fn find_msbuild_vs17 ( target : & str ) -> Option < Tool > {
256+ find_tool_in_vs16plus_path ( r"MSBuild\Current\Bin\MSBuild.exe" , target, "17" )
257+ }
258+
253259 #[ allow( bare_trait_objects) ]
254- fn vs16_instances ( target : & str ) -> Box < Iterator < Item = PathBuf > > {
260+ fn vs16plus_instances ( target : & str , version : & ' static str ) -> Box < Iterator < Item = PathBuf > > {
255261 let instances = if let Some ( instances) = vs15plus_instances ( target) {
256262 instances
257263 } else {
258264 return Box :: new ( iter:: empty ( ) ) ;
259265 } ;
260- Box :: new ( instances. into_iter ( ) . filter_map ( |instance| {
266+ Box :: new ( instances. into_iter ( ) . filter_map ( move |instance| {
261267 let installation_name = instance. installation_name ( ) ?;
262- if installation_name. starts_with ( "VisualStudio/16." ) {
268+ if installation_name. starts_with ( & format ! ( "VisualStudio/{}." , version ) ) {
263269 Some ( instance. installation_path ( ) ?)
264- } else if installation_name. starts_with ( "VisualStudioPreview/16." ) {
270+ } else if installation_name. starts_with ( & format ! ( "VisualStudioPreview/{}." , version ) ) {
265271 Some ( instance. installation_path ( ) ?)
266272 } else {
267273 None
268274 }
269275 } ) )
270276 }
271277
272- fn find_tool_in_vs16_path ( tool : & str , target : & str ) -> Option < Tool > {
273- vs16_instances ( target)
278+ fn find_tool_in_vs16plus_path ( tool : & str , target : & str , version : & ' static str ) -> Option < Tool > {
279+ vs16plus_instances ( target, version )
274280 . filter_map ( |path| {
275281 let path = path. join ( tool) ;
276282 if !path. is_file ( ) {
@@ -289,7 +295,7 @@ mod impl_ {
289295 }
290296
291297 fn find_msbuild_vs16 ( target : & str ) -> Option < Tool > {
292- find_tool_in_vs16_path ( r"MSBuild\Current\Bin\MSBuild.exe" , target)
298+ find_tool_in_vs16plus_path ( r"MSBuild\Current\Bin\MSBuild.exe" , target, "16" )
293299 }
294300
295301 // In MSVC 15 (2017) MS once again changed the scheme for locating
@@ -816,6 +822,11 @@ mod impl_ {
816822
817823 pub fn has_msbuild_version ( version : & str ) -> bool {
818824 match version {
825+ "17.0" => {
826+ find_msbuild_vs17 ( "x86_64-pc-windows-msvc" ) . is_some ( )
827+ || find_msbuild_vs17 ( "i686-pc-windows-msvc" ) . is_some ( )
828+ || find_msbuild_vs17 ( "aarch64-pc-windows-msvc" ) . is_some ( )
829+ }
819830 "16.0" => {
820831 find_msbuild_vs16 ( "x86_64-pc-windows-msvc" ) . is_some ( )
821832 || find_msbuild_vs16 ( "i686-pc-windows-msvc" ) . is_some ( )
0 commit comments