Skip to content

Commit 98011e4

Browse files
Powershell: changed the location of windows desktop runtime starting 5.0 (#120)
* Powershell: changed the location of windows desktop runtime starting 5.0 * removed semicolons * added comments, simplified the code * tests
1 parent e4f6983 commit 98011e4

File tree

2 files changed

+60
-5
lines changed

2 files changed

+60
-5
lines changed

src/dotnet-install.ps1

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,8 @@ function Get-Latest-Version-Info([string]$AzureFeed, [string]$Channel) {
340340
elseif ($Runtime -eq "aspnetcore") {
341341
$VersionFileUrl = "$UncachedFeed/aspnetcore/Runtime/$Channel/latest.version"
342342
}
343-
# Currently, the WindowsDesktop runtime is manufactured with the .Net core runtime
344343
elseif ($Runtime -eq "windowsdesktop") {
345-
$VersionFileUrl = "$UncachedFeed/Runtime/$Channel/latest.version"
344+
$VersionFileUrl = "$UncachedFeed/WindowsDesktop/$Channel/latest.version"
346345
}
347346
elseif (-not $Runtime) {
348347
$VersionFileUrl = "$UncachedFeed/Sdk/$Channel/latest.version"
@@ -438,7 +437,16 @@ function Get-Download-Link([string]$AzureFeed, [string]$SpecificVersion, [string
438437
$PayloadURL = "$AzureFeed/aspnetcore/Runtime/$SpecificVersion/aspnetcore-runtime-$SpecificProductVersion-win-$CLIArchitecture.zip"
439438
}
440439
elseif ($Runtime -eq "windowsdesktop") {
440+
# The windows desktop runtime is part of the core runtime layout prior to 5.0
441441
$PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/windowsdesktop-runtime-$SpecificProductVersion-win-$CLIArchitecture.zip"
442+
if ($SpecificVersion -match '^(\d+)\.(.*)$')
443+
{
444+
$majorVersion = [int]$Matches[1]
445+
if ($majorVersion -ge 5)
446+
{
447+
$PayloadURL = "$AzureFeed/WindowsDesktop/$SpecificVersion/windowsdesktop-runtime-$SpecificProductVersion-win-$CLIArchitecture.zip"
448+
}
449+
}
442450
}
443451
elseif (-not $Runtime) {
444452
$PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-sdk-$SpecificProductVersion-win-$CLIArchitecture.zip"
@@ -480,7 +488,16 @@ function Get-Product-Version([string]$AzureFeed, [string]$SpecificVersion) {
480488
$ProductVersionTxtURL = "$AzureFeed/aspnetcore/Runtime/$SpecificVersion/productVersion.txt"
481489
}
482490
elseif ($Runtime -eq "windowsdesktop") {
491+
# The windows desktop runtime is part of the core runtime layout prior to 5.0
483492
$ProductVersionTxtURL = "$AzureFeed/Runtime/$SpecificVersion/productVersion.txt"
493+
if ($SpecificVersion -match '^(\d+)\.(.*)')
494+
{
495+
$majorVersion = [int]$Matches[1]
496+
if ($majorVersion -ge 5)
497+
{
498+
$ProductVersionTxtURL = "$AzureFeed/WindowsDesktop/$SpecificVersion/productVersion.txt"
499+
}
500+
}
484501
}
485502
elseif (-not $Runtime) {
486503
$ProductVersionTxtURL = "$AzureFeed/Sdk/$SpecificVersion/productVersion.txt"

tests/Install-Scripts.Test/GivenThatIWantToInstallTheSdkFromAScript.cs

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,36 @@ public void WhenRuntimeParametersArePassedToInstallScripts(string runtime, strin
109109
// [InlineData("release/5.0", "dotnet")] - Broken
110110
[InlineData("Current", "aspnetcore")]
111111
[InlineData("LTS", "aspnetcore")]
112+
//[InlineData("1.0", "aspnetcore")] - Broken
113+
//[InlineData("1.1", "aspnetcore")] - Broken
114+
//[InlineData("2.0", "aspnetcore")] - Broken
115+
[InlineData("2.2", "aspnetcore")]
116+
[InlineData("3.0", "aspnetcore")]
117+
[InlineData("3.1", "aspnetcore")]
118+
[InlineData("5.0", "aspnetcore")]
112119
[InlineData("master", "aspnetcore")]
113120
[InlineData("2.2", "aspnetcore")]
114121
[InlineData("3.0", "aspnetcore")]
115122
[InlineData("3.1", "aspnetcore")]
116123
[InlineData("5.0", "aspnetcore")]
117124
[InlineData("release/2.1", "aspnetcore")]
118125
[InlineData("release/2.2", "aspnetcore")]
119-
// [InlineData("release/3.0", "aspnetcore")] - Broken
120-
// [InlineData("release/3.1", "aspnetcore")] - Broken
121-
// [InlineData("release/5.0", "aspnetcore")] - Broken
126+
//[InlineData("release/3.0", "aspnetcore")] - Broken
127+
//[InlineData("release/3.1", "aspnetcore")] - Broken
128+
//[InlineData("release/5.0", "aspnetcore")] - Broken
129+
[InlineData("Current", "windowsdesktop")]
130+
[InlineData("LTS", "windowsdesktop")]
131+
[InlineData("3.0", "windowsdesktop")]
132+
[InlineData("3.1", "windowsdesktop")]
133+
[InlineData("5.0", "windowsdesktop")]
134+
[InlineData("master", "windowsdesktop")]
122135
public void WhenChannelResolvesToASpecificRuntimeVersion(string channel, string runtimeType)
123136
{
137+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && runtimeType == "windowsdesktop")
138+
{
139+
//do not run windowsdesktop test on Linux environment
140+
return;
141+
}
124142
var args = new string[] { "-dryrun", "-channel", channel, "-runtime", runtimeType };
125143

126144
var commandResult = CreateInstallCommand(args)
@@ -193,6 +211,26 @@ public void WhenChannelResolvesToASpecificSDKVersion(string channel)
193211
commandResult.Should().HaveStdOutContainingIgnoreCase("-version");
194212
}
195213

214+
[Theory]
215+
[InlineData("5.0.1", "WindowsDesktop")]
216+
[InlineData("3.1.10", "Runtime")]
217+
public void CanResolveCorrectLocationBasedOnVersion(string version, string location)
218+
{
219+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
220+
{
221+
//do not run windowsdesktop test on Linux environment
222+
return;
223+
}
224+
string expectedLinkLog = $"Constructed primary named payload URL: {Environment.NewLine}https://dotnetcli.azureedge.net/dotnet/{location}/{version}";
225+
var args = new string[] { "-version", version, "-runtime", "windowsdesktop", "-verbose", "-dryrun"};
226+
var commandResult = CreateInstallCommand(args)
227+
.CaptureStdOut()
228+
.CaptureStdErr()
229+
.Execute();
230+
231+
commandResult.Should().Pass().And.HaveStdOutContaining(expectedLinkLog);
232+
}
233+
196234
private static Command CreateInstallCommand(IEnumerable<string> args)
197235
{
198236
string path;

0 commit comments

Comments
 (0)