@ -37,15 +37,13 @@
. PARAMETER SharedRuntime
. PARAMETER SharedRuntime
This parameter is obsolete and may be removed in a future version of this script .
This parameter is obsolete and may be removed in a future version of this script .
The recommended alternative is '-Runtime dotnet' .
The recommended alternative is '-Runtime dotnet' .
Default : false
Installs just the shared runtime bits , not the entire SDK .
Installs just the shared runtime bits , not the entire SDK .
This is equivalent to specifying `- Runtime dotnet ` .
. PARAMETER Runtime
. PARAMETER Runtime
Installs just a shared runtime , not the entire SDK .
Installs just a shared runtime , not the entire SDK .
Possible values :
Possible values :
- dotnet - the Microsoft . NETCore . App shared runtime
- dotnet - the Microsoft . NETCore . App shared runtime
- aspnetcore - the Microsoft . AspNetCore . App shared runtime
- aspnetcore - the Microsoft . AspNetCore . App shared runtime
- windowsdesktop - the Microsoft . WindowsDesktop . App shared runtime
. PARAMETER DryRun
. PARAMETER DryRun
If set it will not perform installation but instead display what command line to use to consistently install
If set it will not perform installation but instead display what command line to use to consistently install
currently requested version of dotnet cli . In example if you specify version 'latest' it will display a link
currently requested version of dotnet cli . In example if you specify version 'latest' it will display a link
@ -76,14 +74,18 @@
Skips installing non-versioned files if they already exist , such as dotnet . exe .
Skips installing non-versioned files if they already exist , such as dotnet . exe .
. PARAMETER NoCdn
. PARAMETER NoCdn
Disable downloading from the Azure CDN , and use the uncached feed directly .
Disable downloading from the Azure CDN , and use the uncached feed directly .
. PARAMETER JSonFile
Determines the SDK version from a user specified global . json file
Note : global . json must have a value for 'SDK:Version'
#>
#>
[ cmdletbinding ( ) ]
[ cmdletbinding ( ) ]
param (
param (
[ string ] $Channel = " LTS " ,
[ string ] $Channel = " LTS " ,
[ string ] $Version = " Latest " ,
[ string ] $Version = " Latest " ,
[ string ] $JSonFile ,
[ string ] $InstallDir = " <auto> " ,
[ string ] $InstallDir = " <auto> " ,
[ string ] $Architecture = " <auto> " ,
[ string ] $Architecture = " <auto> " ,
[ ValidateSet ( " dotnet " , " aspnetcore " , IgnoreCase = $false ) ]
[ ValidateSet ( " dotnet " , " aspnetcore " , " windowsdesktop " , IgnoreCase = $false ) ]
[ string ] $Runtime ,
[ string ] $Runtime ,
[ Obsolete ( " This parameter may be removed in a future version of this script. The recommended alternative is '-Runtime dotnet'. " ) ]
[ Obsolete ( " This parameter may be removed in a future version of this script. The recommended alternative is '-Runtime dotnet'. " ) ]
[ switch ] $SharedRuntime ,
[ switch ] $SharedRuntime ,
@ -257,7 +259,6 @@ function GetHTTPResponse([Uri] $Uri)
} )
} )
}
}
function Get-Latest-Version-Info([string]$AzureFeed , [ string ] $Channel , [ bool ] $Coherent ) {
function Get-Latest-Version-Info([string]$AzureFeed , [ string ] $Channel , [ bool ] $Coherent ) {
Say-Invocation $MyInvocation
Say-Invocation $MyInvocation
@ -268,6 +269,10 @@ function Get-Latest-Version-Info([string]$AzureFeed, [string]$Channel, [bool]$Co
elseif ( $Runtime -eq " aspnetcore " ) {
elseif ( $Runtime -eq " aspnetcore " ) {
$VersionFileUrl = " $UncachedFeed /aspnetcore/Runtime/ $Channel /latest.version "
$VersionFileUrl = " $UncachedFeed /aspnetcore/Runtime/ $Channel /latest.version "
}
}
# Currently, the WindowsDesktop runtime is manufactured with the .Net core runtime
elseif ( $Runtime -eq " windowsdesktop " ) {
$VersionFileUrl = " $UncachedFeed /Runtime/ $Channel /latest.version "
}
elseif ( -not $Runtime ) {
elseif ( -not $Runtime ) {
if ( $Coherent ) {
if ( $Coherent ) {
$VersionFileUrl = " $UncachedFeed /Sdk/ $Channel /latest.coherent.version "
$VersionFileUrl = " $UncachedFeed /Sdk/ $Channel /latest.coherent.version "
@ -299,10 +304,50 @@ function Get-Latest-Version-Info([string]$AzureFeed, [string]$Channel, [bool]$Co
return $VersionInfo
return $VersionInfo
}
}
function Parse-Jsonfile-For-Version([string]$JSonFile ) {
Say-Invocation $MyInvocation
If ( -Not ( Test-Path $JSonFile ) ) {
throw " Unable to find ' $JSonFile ' "
exit 0
}
try {
$JSonContent = Get-Content ( $JSonFile ) -Raw | ConvertFrom-Json | Select-Object -expand " sdk " -ErrorAction SilentlyContinue
}
catch {
throw " Json file unreadable: ' $JSonFile ' "
exit 0
}
if ( $JSonContent ) {
try {
$JSonContent . PSObject . Properties | ForEach-Object {
$PropertyName = $_ . Name
if ( $PropertyName -eq " version " ) {
$Version = $_ . Value
Say-Verbose " Version = $Version "
}
}
}
catch {
throw " Unable to parse the SDK node in ' $JSonFile ' "
exit 0
}
}
else {
throw " Unable to find the SDK node in ' $JSonFile ' "
exit 0
}
If ( $Version -eq $null ) {
throw " Unable to find the SDK:version node in ' $JSonFile ' "
exit 0
}
return $Version
}
function Get-Specific-Version-From-Version([string]$AzureFeed , [ string ] $Channel , [ string ] $Version ) {
function Get-Specific-Version-From-Version([string]$AzureFeed , [ string ] $Channel , [ string ] $Version , [ string ] $JSonFile ) {
Say-Invocation $MyInvocation
Say-Invocation $MyInvocation
if ( -not $JSonFile ) {
switch ( $Version . ToLower ( ) ) {
switch ( $Version . ToLower ( ) ) {
{ $_ -eq " latest " } {
{ $_ -eq " latest " } {
$LatestVersionInfo = Get-Latest -Version -Info -AzureFeed $AzureFeed -Channel $Channel -Coherent $False
$LatestVersionInfo = Get-Latest -Version -Info -AzureFeed $AzureFeed -Channel $Channel -Coherent $False
@ -315,6 +360,10 @@ function Get-Specific-Version-From-Version([string]$AzureFeed, [string]$Channel,
default { return $Version }
default { return $Version }
}
}
}
}
else {
return Parse-Jsonfile -For -Version $JSonFile
}
}
function Get-Download-Link([string]$AzureFeed , [ string ] $SpecificVersion , [ string ] $CLIArchitecture ) {
function Get-Download-Link([string]$AzureFeed , [ string ] $SpecificVersion , [ string ] $CLIArchitecture ) {
Say-Invocation $MyInvocation
Say-Invocation $MyInvocation
@ -325,6 +374,9 @@ function Get-Download-Link([string]$AzureFeed, [string]$SpecificVersion, [string
elseif ( $Runtime -eq " aspnetcore " ) {
elseif ( $Runtime -eq " aspnetcore " ) {
$PayloadURL = " $AzureFeed /aspnetcore/Runtime/ $SpecificVersion /aspnetcore-runtime- $SpecificVersion -win- $CLIArchitecture .zip "
$PayloadURL = " $AzureFeed /aspnetcore/Runtime/ $SpecificVersion /aspnetcore-runtime- $SpecificVersion -win- $CLIArchitecture .zip "
}
}
elseif ( $Runtime -eq " windowsdesktop " ) {
$PayloadURL = " $AzureFeed /Runtime/ $SpecificVersion /windowsdesktop-runtime- $SpecificVersion -win- $CLIArchitecture .zip "
}
elseif ( -not $Runtime ) {
elseif ( -not $Runtime ) {
$PayloadURL = " $AzureFeed /Sdk/ $SpecificVersion /dotnet-sdk- $SpecificVersion -win- $CLIArchitecture .zip "
$PayloadURL = " $AzureFeed /Sdk/ $SpecificVersion /dotnet-sdk- $SpecificVersion -win- $CLIArchitecture .zip "
}
}
@ -374,23 +426,6 @@ function Resolve-Installation-Path([string]$InstallDir) {
return $InstallDir
return $InstallDir
}
}
function Get-Version-Info-From-Version-File([string]$InstallRoot , [ string ] $RelativePathToVersionFile ) {
Say-Invocation $MyInvocation
$VersionFile = Join-Path -Path $InstallRoot -ChildPath $RelativePathToVersionFile
Say-Verbose " Local version file: $VersionFile "
if ( Test-Path $VersionFile ) {
$VersionText = cat $VersionFile
Say-Verbose " Local version file text: $VersionText "
return Get-Version -Info -From -Version -Text $VersionText
}
Say-Verbose " Local version file not found. "
return $null
}
function Is-Dotnet-Package-Installed([string]$InstallRoot , [ string ] $RelativePathToPackage , [ string ] $SpecificVersion ) {
function Is-Dotnet-Package-Installed([string]$InstallRoot , [ string ] $RelativePathToPackage , [ string ] $SpecificVersion ) {
Say-Invocation $MyInvocation
Say-Invocation $MyInvocation
@ -526,7 +561,7 @@ function Prepend-Sdk-InstallRoot-To-Path([string]$InstallRoot, [string]$BinFolde
}
}
$CLIArchitecture = Get-CLIArchitecture -From -Architecture $Architecture
$CLIArchitecture = Get-CLIArchitecture -From -Architecture $Architecture
$SpecificVersion = Get-Specific -Version -From -Version -AzureFeed $AzureFeed -Channel $Channel -Version $Version
$SpecificVersion = Get-Specific -Version -From -Version -AzureFeed $AzureFeed -Channel $Channel -Version $Version -JSonFile $JSonFile
$DownloadLink = Get-Download -Link -AzureFeed $AzureFeed -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture
$DownloadLink = Get-Download -Link -AzureFeed $AzureFeed -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture
$LegacyDownloadLink = Get-LegacyDownload -Link -AzureFeed $AzureFeed -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture
$LegacyDownloadLink = Get-LegacyDownload -Link -AzureFeed $AzureFeed -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture
@ -564,6 +599,10 @@ elseif ($Runtime -eq "aspnetcore") {
$assetName = " ASP.NET Core Runtime "
$assetName = " ASP.NET Core Runtime "
$dotnetPackageRelativePath = " shared\Microsoft.AspNetCore.App "
$dotnetPackageRelativePath = " shared\Microsoft.AspNetCore.App "
}
}
elseif ( $Runtime -eq " windowsdesktop " ) {
$assetName = " .NET Core Windows Desktop Runtime "
$dotnetPackageRelativePath = " shared\Microsoft.WindowsDesktop.App "
}
elseif ( -not $Runtime ) {
elseif ( -not $Runtime ) {
$assetName = " .NET Core SDK "
$assetName = " .NET Core SDK "
$dotnetPackageRelativePath = " sdk "
$dotnetPackageRelativePath = " sdk "