@@ -232,6 +232,82 @@ public void Should_Get_Correct_Path_To_MSBuild_Version_17Preview_When_Preview_Is
232232 }
233233 }
234234
235+ [ Theory ]
236+ [ InlineData ( MSBuildToolVersion . VS2026 , PlatformTarget . x64 , PlatformFamily . Windows , false , "/Program/Microsoft Visual Studio/18/Enterprise/MSBuild/Current/Bin/amd64/MSBuild.exe" ) ]
237+ [ InlineData ( MSBuildToolVersion . VS2026 , PlatformTarget . x86 , PlatformFamily . Windows , false , "/Program/Microsoft Visual Studio/18/Enterprise/MSBuild/Current/Bin/MSBuild.exe" ) ]
238+ [ InlineData ( MSBuildToolVersion . VS2026 , PlatformTarget . x64 , PlatformFamily . Linux , false , "/usr/bin/msbuild" ) ]
239+ [ InlineData ( MSBuildToolVersion . VS2026 , PlatformTarget . x64 , PlatformFamily . OSX , false , "/Library/Frameworks/Mono.framework/Versions/Current/Commands/msbuild" ) ]
240+ public void Should_Get_Correct_Path_To_MSBuild_Version_18 ( MSBuildToolVersion version , PlatformTarget target , PlatformFamily family , bool is64BitOperativeSystem , string expected )
241+ {
242+ // Given
243+ var fixture = new MSBuildRunnerFixture ( is64BitOperativeSystem , family ) ;
244+ fixture . Settings . ToolVersion = version ;
245+ fixture . Settings . PlatformTarget = target ;
246+
247+ // When
248+ var result = fixture . Run ( ) ;
249+
250+ // Then
251+ Assert . Equal ( expected , result . Path . FullPath ) ;
252+ }
253+
254+ [ Theory ]
255+ [ InlineData ( MSBuildToolVersion . VS2026 , PlatformTarget . x64 , PlatformFamily . Windows , false , "/Program86/Microsoft Visual Studio/18/BuildTools/MSBuild/Current/Bin/amd64/MSBuild.exe" ) ]
256+ [ InlineData ( MSBuildToolVersion . VS2026 , PlatformTarget . x86 , PlatformFamily . Windows , false , "/Program86/Microsoft Visual Studio/18/BuildTools/MSBuild/Current/Bin/MSBuild.exe" ) ]
257+ public void Should_Get_Correct_Path_To_MSBuild_Version_18_When_Only_Build_Tools_Are_Installed ( MSBuildToolVersion version , PlatformTarget target , PlatformFamily family , bool is64BitOperativeSystem , string expected )
258+ {
259+ // Given
260+ var fixture = new MSBuildRunnerFixture ( is64BitOperativeSystem , family ) ;
261+ fixture . Settings . ToolVersion = version ;
262+ fixture . Settings . PlatformTarget = target ;
263+
264+ fixture . GivenDefaultToolDoNotExist ( ) ;
265+ fixture . GivenMSBuildIsNotInstalled ( ) ;
266+ fixture . FileSystem . CreateFile ( "/Program86/Microsoft Visual Studio/18/BuildTools/MSBuild/Current/Bin/amd64/MSBuild.exe" ) ;
267+ fixture . FileSystem . CreateFile ( "/Program86/Microsoft Visual Studio/18/BuildTools/MSBuild/Current/Bin/MSBuild.exe" ) ;
268+
269+ // When
270+ var result = fixture . Run ( ) ;
271+
272+ // Then
273+ Assert . Equal ( expected , result . Path . FullPath ) ;
274+ }
275+
276+ [ Theory ]
277+ [ InlineData ( MSBuildToolVersion . VS2026 , PlatformTarget . x64 , PlatformFamily . Windows , true ) ]
278+ [ InlineData ( MSBuildToolVersion . VS2026 , PlatformTarget . x86 , PlatformFamily . Windows , true ) ]
279+ [ InlineData ( MSBuildToolVersion . VS2026 , PlatformTarget . x64 , PlatformFamily . Windows , false ) ]
280+ [ InlineData ( MSBuildToolVersion . VS2026 , PlatformTarget . x86 , PlatformFamily . Windows , false ) ]
281+ public void Should_Get_Correct_Path_To_MSBuild_Version_18Insider_When_Preview_Is_Set ( MSBuildToolVersion version , PlatformTarget target , PlatformFamily family , bool allowPreview )
282+ {
283+ // Given
284+ var is64BitOperativeSystem = target == PlatformTarget . x64 ;
285+ var fixture = new MSBuildRunnerFixture ( is64BitOperativeSystem , family ) ;
286+ fixture . Settings . ToolVersion = version ;
287+ fixture . Settings . PlatformTarget = target ;
288+ fixture . Settings . AllowPreviewVersion = allowPreview ;
289+
290+ fixture . GivenDefaultToolDoNotExist ( ) ;
291+ fixture . GivenMSBuildIsNotInstalled ( ) ;
292+ fixture . FileSystem . CreateFile ( "/Program/Microsoft Visual Studio/18/Enterprise/MSBuild/Current/Bin/amd64/MSBuild.exe" ) ;
293+ fixture . FileSystem . CreateFile ( "/Program/Microsoft Visual Studio/18/Enterprise/MSBuild/Current/Bin/MSBuild.exe" ) ;
294+ fixture . FileSystem . CreateFile ( "/Program/Microsoft Visual Studio/18/Insiders/MSBuild/Current/Bin/amd64/MSBuild.exe" ) ;
295+ fixture . FileSystem . CreateFile ( "/Program/Microsoft Visual Studio/18/Insiders/MSBuild/Current/Bin/MSBuild.exe" ) ;
296+
297+ // When
298+ var result = fixture . Run ( ) ;
299+
300+ // Then
301+ if ( allowPreview )
302+ {
303+ Assert . Contains ( "18/Insiders" , result . Path . FullPath ) ;
304+ }
305+ else
306+ {
307+ Assert . DoesNotContain ( "18/Insiders" , result . Path . FullPath ) ;
308+ }
309+ }
310+
235311 [ Theory ]
236312 [ InlineData ( MSBuildToolVersion . NET40 , PlatformTarget . MSIL , true , "/Windows/Microsoft.NET/Framework64/v4.0.30319/MSBuild.exe" ) ]
237313 [ InlineData ( MSBuildToolVersion . NET40 , PlatformTarget . MSIL , false , "/Windows/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe" ) ]
0 commit comments