Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 18 additions & 53 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2778,65 +2778,30 @@ function Install-Dotnet {
Remove-Item -ErrorAction SilentlyContinue -Recurse -Force ~\AppData\Local\Microsoft\dotnet
$installScript = "dotnet-install.ps1"
Invoke-WebRequest -Uri $installObtainUrl/$installScript -OutFile $installScript
if (-not $environment.IsCoreCLR) {
$installArgs = @{}
if ($Version) {
$installArgs += @{ Version = $Version }
} elseif ($Channel) {
$installArgs += @{ Quality = $Quality }
$installArgs += @{ Channel = $Channel }
}

if ($InstallDir) {
$installArgs += @{ InstallDir = $InstallDir }
}

if ($AzureFeed) {
$installArgs += @{AzureFeed = $AzureFeed}
}

if ($FeedCredential) {
$installArgs += @{FeedCredential = $FeedCredential}
}

$installArgs += @{ SkipNonVersionedFiles = $true }

$installArgs | Out-String | Write-Verbose -Verbose
& ./$installScript @installArgs
$installArgs = @{}
if ($Version) {
$installArgs.Version = $Version
}
elseif ($Channel) {
$installArgs.Channel = $Channel
$installArgs.Quality = $Quality
}
else {
# dotnet-install.ps1 uses APIs that are not supported in .NET Core, so we run it with Windows PowerShell
$fullPSPath = Join-Path -Path $env:windir -ChildPath "System32\WindowsPowerShell\v1.0\powershell.exe"
$fullDotnetInstallPath = Join-Path -Path (Convert-Path -Path $PWD.Path) -ChildPath $installScript

if ($Version) {
$psArgs = @('-NoLogo', '-NoProfile', '-File', $fullDotnetInstallPath, '-Version', $Version)
}
elseif ($Channel) {
$psArgs = @('-NoLogo', '-NoProfile', '-File', $fullDotnetInstallPath, '-Channel', $Channel, '-Quality', $Quality)
}

if ($InstallDir) {
$psArgs += @('-InstallDir', $InstallDir)
}

if ($AzureFeed) {
$psArgs += @('-AzureFeed', $AzureFeed)
}
if ($InstallDir) {
$installArgs.InstallDir = $InstallDir
}

if ($FeedCredential) {
$psArgs += @('-FeedCredential', $FeedCredential)
}
if ($AzureFeed) {
$installArgs.AzureFeed = $AzureFeed
}

$psArgs += @('-SkipNonVersionedFiles')
if ($FeedCredential) {
$installArgs.FeedCredential = $FeedCredential
}

# Removing the verbose message to not expose the secret
# $psArgs -join ' ' | Write-Verbose -Verbose
$installArgs.SkipNonVersionedFiles = $true

Start-NativeExecution {
& $fullPSPath @psArgs
}
}
& ./$installScript @installArgs
}
Write-LogGroupEnd -Title "Install .NET SDK $Version"
}
Expand Down
Loading