Skip to content

Commit 758a3f4

Browse files
committed
Install only one dotnet SDK
But also install all the necessary runtimes.
1 parent 2905fbb commit 758a3f4

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

PowerShellEditorServices.build.ps1

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,16 @@ if (Get-Command git -ErrorAction SilentlyContinue) {
5252

5353
function Install-Dotnet {
5454
param (
55-
[string[]]$Channel
55+
[string[]]$Channel,
56+
[switch]$Runtime
5657
)
5758

5859
$env:DOTNET_INSTALL_DIR = "$PSScriptRoot/.dotnet"
5960

60-
Write-Host "Installing .NET channels $Channel" -ForegroundColor Green
61+
$components = if ($Runtime) { "Runtime " } else { "SDK and Runtime " }
62+
$components += $Channel -join ', '
63+
64+
Write-Host "Installing .NET $components" -ForegroundColor Green
6165

6266
# The install script is platform-specific
6367
$installScriptExt = if ($script:IsNix) { "sh" } else { "ps1" }
@@ -70,18 +74,13 @@ function Install-Dotnet {
7074
# Download and install the different .NET channels
7175
foreach ($dotnetChannel in $Channel)
7276
{
73-
Write-Host "`n### Installing .NET CLI $Version...`n"
74-
7577
if ($script:IsNix) {
7678
chmod +x $installScriptPath
7779
}
7880

79-
$params = if ($script:IsNix)
80-
{
81+
$params = if ($script:IsNix) {
8182
@('-Channel', $dotnetChannel, '-InstallDir', $env:DOTNET_INSTALL_DIR, '-NoPath', '-Verbose')
82-
}
83-
else
84-
{
83+
} else {
8584
@{
8685
Channel = $dotnetChannel
8786
InstallDir = $env:DOTNET_INSTALL_DIR
@@ -90,9 +89,13 @@ function Install-Dotnet {
9089
}
9190
}
9291

93-
& $installScriptPath @params
92+
# Install just the runtime, not the SDK
93+
if ($Runtime) {
94+
if ($script:IsNix) { $params += @('-Runtime', 'dotnet') }
95+
else { $params['Runtime'] = 'dotnet' }
96+
}
9497

95-
Write-Host "`n### Installation complete for version $Version."
98+
exec { & $installScriptPath @params }
9699
}
97100

98101
$env:PATH = $env:DOTNET_INSTALL_DIR + [System.IO.Path]::PathSeparator + $env:PATH
@@ -107,7 +110,8 @@ task SetupDotNet -Before Clean, Build, TestServerWinPS, TestServerPS7, TestServe
107110

108111
if (!(Test-Path $dotnetExePath)) {
109112
# TODO: Test .NET 5 with PowerShell 7.1
110-
Install-Dotnet -Channel '3.1','5.0','6.0'
113+
Install-Dotnet -Channel '6.0' # SDK and runtime
114+
Install-Dotnet -Channel '3.1','5.0' -Runtime # Runtime only
111115
}
112116

113117
# This variable is used internally by 'dotnet' to know where it's installed
@@ -119,6 +123,8 @@ task SetupDotNet -Before Clean, Build, TestServerWinPS, TestServerPS7, TestServe
119123
$env:DOTNET_INSTALL_DIR = $dotnetExeDir
120124
}
121125

126+
# Disable dev certificate generation
127+
$env:DOTNET_GENERATE_ASPNET_CERTIFICATE = 'false'
122128
Write-Host "`n### Using dotnet v$(& $script:dotnetExe --version) at path $script:dotnetExe`n" -ForegroundColor Green
123129
}
124130

global.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"sdk": {
3+
"version": "6.0",
4+
"rollForward": "latestFeature",
5+
"allowPrerelease": true
6+
}
7+
}

0 commit comments

Comments
 (0)