1+ using System ;
12using System . Collections . Generic ;
23using System . IO ;
34using System . Linq ;
45using System . Net ;
56using System . Net . Http ;
67using System . Runtime . InteropServices ;
8+ using System . Threading . Channels ;
79using Nuke . Common ;
810using Nuke . Common . CI ;
911using Nuke . Common . CI . AzurePipelines ;
@@ -78,16 +80,32 @@ partial class Build : Nuke.Common.NukeBuild
7880 {
7981 if ( ! RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
8082 return ;
81- if ( AzurePipelines == null && GitHubActions == null )
82- return ;
8383 Directory . CreateDirectory ( ResultDirectory ) ;
8484 var ps1File = ResultDirectory / "donet-install.ps1" ;
8585 using ( var client = new HttpClient ( ) )
8686 {
8787 var bytes = client . GetByteArrayAsync ( @"https://dot.net/v1/dotnet-install.ps1" ) . Result ;
8888 File . WriteAllBytes ( ps1File , bytes ) ;
8989 }
90- PowerShellTasks . PowerShell ( $ " { ps1File } -Channel 3.0 -Architecture x86") ;
90+
91+ var channels = new [ ] { "2.1" , "3.0" , "3.1" , "5.0" } ;
92+ var architectures = new [ ] { "x86" , "x64" } ;
93+ var list = new List < ( string chan , string arch ) > ( ) ;
94+
95+ foreach ( var channel in channels )
96+ {
97+ foreach ( var arch in architectures )
98+ {
99+ list . Add ( ( channel , arch ) ) ;
100+ }
101+ }
102+
103+ list . AsParallel ( )
104+ . ForAll ( x =>
105+ {
106+ var folder = ResultDirectory / x . chan / x . arch ;
107+ PowerShellTasks . PowerShell ( $ " { ps1File } -Channel { x . chan } -Architecture { x . arch } -InstallDir { folder } ") ;
108+ } ) ;
91109 } ) ;
92110
93111 Target Clean => _ => _
@@ -101,16 +119,40 @@ partial class Build : Nuke.Common.NukeBuild
101119 . DependsOn ( SdkInstallation )
102120 . Executes ( ( ) =>
103121 {
122+ var path = Environment . GetEnvironmentVariable ( "PATH" ) ;
123+ var channels = new [ ] { "2.1" , "3.0" , "3.1" , "5.0" } ;
124+ var architectures = new [ ] { "x86" , "x64" } ;
125+ foreach ( var channel in channels )
126+ {
127+ foreach ( var architecture in architectures )
128+ {
129+ path += $ ";{ ResultDirectory / channel / architecture } ";
130+ }
131+ }
132+
104133 DotNetRestore ( s => s
105- . SetProjectFile ( Solution ) ) ;
134+ . SetProjectFile ( Solution )
135+ . AddProcessEnvironmentVariable ( "PATH" , path ) ) ;
106136 } ) ;
107137
108138 Target Compile => _ => _
109139 . DependsOn ( Restore )
110- . Executes ( ( ) => ExecutesCompile ( false ) ) ;
140+ . Executes ( ( ) =>
141+ ExecutesCompile ( false ) ) ;
111142
112143 void ExecutesCompile ( bool excludeNetFramework )
113144 {
145+ var path = Environment . GetEnvironmentVariable ( "PATH" ) ;
146+ var channels = new [ ] { "2.1" , "3.0" , "3.1" , "5.0" } ;
147+ var architectures = new [ ] { "x86" , "x64" } ;
148+ foreach ( var channel in channels )
149+ {
150+ foreach ( var architecture in architectures )
151+ {
152+ path += $ ";{ ResultDirectory / channel / architecture } ";
153+ }
154+ }
155+
114156
115157 Serilog . Log . Information ( excludeNetFramework ? "Exclude net framework" : "Include net framework" ) ;
116158 if ( excludeNetFramework )
@@ -128,6 +170,7 @@ from platform in project.GetPlatforms()
128170 . SetAssemblyVersion ( GitVersion . AssemblySemVer )
129171 . SetFileVersion ( GitVersion . AssemblySemFileVer )
130172 . SetInformationalVersion ( GitVersion . InformationalVersion )
173+ . AddProcessEnvironmentVariable ( "PATH" , path )
131174 . CombineWith ( projectWithFrameworkAndPlatform , ( s , f ) => s
132175 . SetFramework ( f . framework )
133176 . SetProperty ( "Platform" , f . platform )
@@ -138,6 +181,7 @@ from platform in project.GetPlatforms()
138181 DotNetBuild ( s => s
139182 . SetProjectFile ( Solution )
140183 . SetConfiguration ( Configuration )
184+ . AddProcessEnvironmentVariable ( "PATH" , path )
141185 . EnableNoRestore ( )
142186 . SetAssemblyVersion ( GitVersion . AssemblySemVer )
143187 . SetFileVersion ( GitVersion . AssemblySemFileVer )
@@ -157,6 +201,18 @@ void ExecutesTest(bool excludeNetFramework)
157201 {
158202 Serilog . Log . Information ( excludeNetFramework ? "Exclude net framework" : "Include net framework" ) ;
159203
204+ var path = Environment . GetEnvironmentVariable ( "PATH" ) ;
205+ var channels = new [ ] { "2.1" , "3.0" , "3.1" , "5.0" } ;
206+ var architectures = new [ ] { "x86" , "x64" } ;
207+ foreach ( var channel in channels )
208+ {
209+ foreach ( var architecture in architectures )
210+ {
211+ path += $ ";{ ResultDirectory / channel / architecture } ";
212+ }
213+ }
214+
215+
160216 var groupTestConfigurations =
161217 ( from project in TestProjects
162218 from framework in project . GetTargetFrameworks ( excludeNetFramework )
@@ -177,6 +233,7 @@ from platform in project.GetPlatformsForTests()
177233 . SetConfiguration ( Configuration )
178234 . SetNoRestore ( InvokedTargets . Contains ( Restore ) )
179235 . SetNoBuild ( InvokedTargets . Contains ( Compile ) )
236+ . AddProcessEnvironmentVariable ( "PATH" , path )
180237 . ResetVerbosity ( )
181238 . SetResultsDirectory ( TestResultDirectory )
182239 . CombineWith ( testConfigurations , ( _ , v ) => _
0 commit comments