@@ -134,7 +134,9 @@ pub fn find_vs_version() -> Result<VsVers, String> {
134
134
_ => {
135
135
// Check for the presence of a specific registry key
136
136
// 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" ) {
138
140
Ok ( VsVers :: Vs16 )
139
141
} else if impl_:: has_msbuild_version ( "15.0" ) {
140
142
Ok ( VsVers :: Vs15 )
@@ -250,27 +252,31 @@ mod impl_ {
250
252
}
251
253
}
252
254
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
+
253
259
#[ 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 > > {
255
261
let instances = if let Some ( instances) = vs15plus_instances ( target) {
256
262
instances
257
263
} else {
258
264
return Box :: new ( iter:: empty ( ) ) ;
259
265
} ;
260
- Box :: new ( instances. into_iter ( ) . filter_map ( |instance| {
266
+ Box :: new ( instances. into_iter ( ) . filter_map ( move |instance| {
261
267
let installation_name = instance. installation_name ( ) ?;
262
- if installation_name. starts_with ( "VisualStudio/16." ) {
268
+ if installation_name. starts_with ( & format ! ( "VisualStudio/{}." , version ) ) {
263
269
Some ( instance. installation_path ( ) ?)
264
- } else if installation_name. starts_with ( "VisualStudioPreview/16." ) {
270
+ } else if installation_name. starts_with ( & format ! ( "VisualStudioPreview/{}." , version ) ) {
265
271
Some ( instance. installation_path ( ) ?)
266
272
} else {
267
273
None
268
274
}
269
275
} ) )
270
276
}
271
277
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 )
274
280
. filter_map ( |path| {
275
281
let path = path. join ( tool) ;
276
282
if !path. is_file ( ) {
@@ -289,7 +295,7 @@ mod impl_ {
289
295
}
290
296
291
297
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" )
293
299
}
294
300
295
301
// In MSVC 15 (2017) MS once again changed the scheme for locating
@@ -816,6 +822,11 @@ mod impl_ {
816
822
817
823
pub fn has_msbuild_version ( version : & str ) -> bool {
818
824
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
+ }
819
830
"16.0" => {
820
831
find_msbuild_vs16 ( "x86_64-pc-windows-msvc" ) . is_some ( )
821
832
|| find_msbuild_vs16 ( "i686-pc-windows-msvc" ) . is_some ( )
0 commit comments