Skip to content

Commit 00df5b4

Browse files
committed
[Infra] try to add all sdk in path.
1 parent eebaaff commit 00df5b4

File tree

2 files changed

+64
-5
lines changed

2 files changed

+64
-5
lines changed

.nuke/build.schema.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
"Pack",
7878
"PackCoreOnly",
7979
"Restore",
80+
"SdkInstallation",
8081
"Test",
8182
"TestCoreOnly"
8283
]
@@ -98,6 +99,7 @@
9899
"Pack",
99100
"PackCoreOnly",
100101
"Restore",
102+
"SdkInstallation",
101103
"Test",
102104
"TestCoreOnly"
103105
]

Build/Nuke/Build.cs

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
using System;
12
using System.Collections.Generic;
23
using System.IO;
34
using System.Linq;
45
using System.Net;
56
using System.Net.Http;
67
using System.Runtime.InteropServices;
8+
using System.Threading.Channels;
79
using Nuke.Common;
810
using Nuke.Common.CI;
911
using 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

Comments
 (0)