1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . IO ;
14using Nuke . Common ;
25using Nuke . Common . IO ;
36using Nuke . Common . ProjectModel ;
@@ -26,13 +29,15 @@ partial class Build
2629 ? new [ ] { MSBuildTargetPlatform . x64 , MSBuildTargetPlatform . x86 }
2730 : new [ ] { MSBuildTargetPlatform . x86 } ;
2831
32+ SupportVs2026IfAvailable ( ) ;
2933 foreach ( var project in Solution . GetNativeSrcProjects ( ) )
3034 {
3135 PerformLegacyRestoreIfNeeded ( project ) ;
3236
3337 var ( major , minor , patch ) = VersionHelper . GetVersionParts ( ) ;
3438
3539 // Can't use dotnet msbuild, as needs to use the VS version of MSBuild
40+
3641 MSBuild ( s => s
3742 . SetTargetPath ( project )
3843 . SetConfiguration ( BuildConfiguration )
@@ -44,6 +49,26 @@ partial class Build
4449 . CombineWith ( platforms , ( m , platform ) => m
4550 . SetTargetPlatform ( platform ) ) ) ;
4651 }
52+
53+ static void SupportVs2026IfAvailable ( )
54+ {
55+ // Typical installation folder: C:\Program Files\Microsoft Visual Studio\18\Enterprise\MSBuild\Current\Bin\amd64
56+ // Waiting for official support in Nuke package https://github.com/nuke-build/nuke/pull/1583
57+
58+ string [ ] editions = [ "Enterprise" , "Professional" , "Community" , "Preview" ] ;
59+
60+ foreach ( var edition in editions )
61+ {
62+ var msBuildPath = Path . Combine ( SpecialFolder ( SpecialFolders . ProgramFiles ) . NotNull ( ) ,
63+ $@ "Microsoft Visual Studio\18\{ edition } \MSBuild\Current\Bin\amd64\MSBuild.exe") ;
64+
65+ if ( File . Exists ( msBuildPath ) )
66+ {
67+ MSBuildPath = msBuildPath ;
68+ return ;
69+ }
70+ }
71+ }
4772 } ) ;
4873
4974 Target CompileNativeDependenciesForManagedTestsWindows => _ => _
0 commit comments