@@ -25,17 +25,8 @@ $DotnetSDKVersionRequirements = @{
2525$GrpcToolsVersion = ' 2.27.0' # grpc.tools
2626$GoogleProtobufToolsVersion = ' 3.11.4' # google.protobuf.tools
2727
28- function AddLocalDotnetDirPath {
29- $LocalDotnetDirPath = if ($IsWindowsEnv ) { " $env: LocalAppData \Microsoft\dotnet" } else { " $env: HOME /.dotnet" }
30- if (($env: PATH -split [IO.Path ]::PathSeparator) -notcontains $LocalDotnetDirPath ) {
31- $env: PATH = $LocalDotnetDirPath + [IO.Path ]::PathSeparator + $env: PATH
32- }
33- }
34-
3528function Find-Dotnet
3629{
37- AddLocalDotnetDirPath
38-
3930 $listSdksOutput = dotnet -- list- sdks
4031 $installedDotnetSdks = $listSdksOutput | ForEach-Object { $_.Split (" " )[0 ] }
4132 Write-Log " Detected dotnet SDKs: $ ( $installedDotnetSdks -join ' , ' ) "
@@ -65,7 +56,7 @@ function Install-Dotnet {
6556 return # Simply return if we find dotnet SDk with the correct version
6657 } catch { }
6758
68- $obtainUrl = " https://raw.githubusercontent.com/dotnet/cli/master/ scripts/obtain "
59+ $obtainUrl = " https://raw.githubusercontent.com/dotnet/install- scripts/main/src "
6960
7061 try {
7162 $installScript = if ($IsWindowsEnv ) { " dotnet-install.ps1" } else { " dotnet-install.sh" }
@@ -75,13 +66,12 @@ function Install-Dotnet {
7566 $version = " $majorMinorVersion .$ ( $DotnetSDKVersionRequirements [$majorMinorVersion ].DefaultPatch) "
7667 Write-Log " Installing dotnet SDK version $version " - Warning
7768 if ($IsWindowsEnv ) {
78- & .\$installScript - Channel $Channel - Version $Version
69+ & .\$installScript - Channel $Channel - Version $Version - InstallDir " $ env: ProgramFiles /dotnet "
7970 } else {
80- bash ./ $installScript - c $Channel - v $Version
71+ bash ./ $installScript - c $Channel - v $Version -- install-dir / usr / share / dotnet
8172 }
8273 }
8374
84- AddLocalDotnetDirPath
8575 }
8676 finally {
8777 Remove-Item $installScript - Force - ErrorAction SilentlyContinue
0 commit comments