-
Notifications
You must be signed in to change notification settings - Fork 237
Fix .NET installation #1320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix .NET installation #1320
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,28 +55,52 @@ function Invoke-WithCreateDefaultHook { | |
|
||
function Install-Dotnet { | ||
param ( | ||
$Channel | ||
[string[]]$Channel | ||
) | ||
|
||
Write-Host "`n### Installing .NET CLI $Version...`n" -ForegroundColor Green | ||
$env:DOTNET_INSTALL_DIR = "$PSScriptRoot/.dotnet" | ||
|
||
Write-Host "Installing .NET channels $Channel" -ForegroundColor Green | ||
|
||
# The install script is platform-specific | ||
$installScriptExt = if ($script:IsUnix) { "sh" } else { "ps1" } | ||
$installScript = "dotnet-install.$installScriptExt" | ||
|
||
# Download the official installation script and run it | ||
$installScriptPath = "$([System.IO.Path]::GetTempPath())dotnet-install.$installScriptExt" | ||
Invoke-WebRequest "https://dot.net/v1/dotnet-install.$installScriptExt" -OutFile $installScriptPath | ||
$env:DOTNET_INSTALL_DIR = "$PSScriptRoot/.dotnet" | ||
$installScriptPath = Join-Path ([System.IO.Path]::GetTempPath()) $installScript | ||
Invoke-WebRequest "https://dot.net/v1/$installScript" -OutFile $installScriptPath | ||
|
||
# Download and install the different .NET channels | ||
foreach ($dotnetChannel in $Channel) | ||
{ | ||
Write-Host "`n### Installing .NET CLI $Version...`n" | ||
|
||
if ($script:IsUnix) { | ||
chmod +x $installScriptPath | ||
} | ||
|
||
$params = if ($script:IsUnix) | ||
{ | ||
@('-Channel', $dotnetChannel, '-InstallDir', $env:DOTNET_INSTALL_DIR, '-NoPath', '-Verbose') | ||
} | ||
else | ||
{ | ||
@{ | ||
Channel = $dotnetChannel | ||
InstallDir = $env:DOTNET_INSTALL_DIR | ||
NoPath = $true | ||
Verbose = $true | ||
} | ||
} | ||
Comment on lines
+82
to
+94
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why did you do this instead of what I had before with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Broke with my path which has spaces in it. Needing to fix it and wanting to avoid There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fine I guess... annoying having a platform check for the same thing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @daxian-dbw There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I totally believe you... I just had exactly this code once and wanted to not have to do this, which is why I used iex in the first place. I would guess that if we wrapped InstallDir in quotes in might work... but seems hacky. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, fixing it I didnt' want to get into a quote escaping tarpit. Ideally install-dotnet.ps1 would work cross-platform. Frankly that script could use some improvement anyway |
||
|
||
& $installScriptPath @params | ||
|
||
if ($script:IsUnix) { | ||
chmod +x $installScriptPath | ||
Write-Host "`n### Installation complete for version $Version." | ||
} | ||
|
||
$paramArr = @('-Channel', $Channel, '-InstallDir', "'$env:DOTNET_INSTALL_DIR'", '-NoPath') | ||
Invoke-Expression "$installScriptPath $paramArr" | ||
$env:PATH = $env:DOTNET_INSTALL_DIR + [System.IO.Path]::PathSeparator + $env:PATH | ||
|
||
Write-Host "`n### Installation complete." -ForegroundColor Green | ||
Write-Host '.NET installation complete' -ForegroundColor Green | ||
} | ||
|
||
task SetupDotNet -Before Clean, Build, TestHost, TestServerWinPS, TestServerPS7, TestServerPS71, TestE2E { | ||
|
@@ -85,9 +109,7 @@ task SetupDotNet -Before Clean, Build, TestHost, TestServerWinPS, TestServerPS7, | |
$dotnetExePath = if ($script:IsUnix) { "$dotnetPath/dotnet" } else { "$dotnetPath/dotnet.exe" } | ||
|
||
if (!(Test-Path $dotnetExePath)) { | ||
Install-Dotnet -Channel '2.1' | ||
Install-Dotnet -Channel '3.1' | ||
Install-Dotnet -Channel 'release/5.0.1xx-preview6' | ||
Install-Dotnet -Channel '2.1','3.1','release/5.0.1xx-preview6' | ||
} | ||
|
||
# This variable is used internally by 'dotnet' to know where it's installed | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need this extra variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gets used twice below