Skip to content

Commit

Permalink
idempotency
Browse files Browse the repository at this point in the history
  • Loading branch information
ami-GS committed Jul 3, 2024
1 parent 681aab6 commit 40c9082
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions scripts/prepare-machine.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,20 @@ function Install-Dotnet {
}

Write-Host "Installing dotnet"
# known issue https://learn.microsoft.com/en-us/dotnet/core/install/linux-package-mixup?pivots=os-linux-ubuntu
sudo bash -c "echo 'Package: dotnet* aspnet* netstandard*' >> /etc/apt/preferences"
sudo bash -c "echo 'Pin: origin packages.microsoft.com' >> /etc/apt/preferences"
sudo bash -c "echo 'Pin-Priority: -10' >> /etc/apt/preferences"

# Check /etc/apt/preperences whether it has the known issue workaround
if (Test-Path /etc/apt/preferences) {
$hasKnownIssueWorkaround = (Get-Content /etc/apt/preferences | Select-String -Pattern "Package: dotnet* aspnet* netstandard*") -ne $null
if (!$hasKnownIssueWorkaround) {
# known issue https://learn.microsoft.com/en-us/dotnet/core/install/linux-package-mixup?pivots=os-linux-ubuntu
sudo bash -c "echo 'Package: dotnet* aspnet* netstandard*' >> /etc/apt/preferences"
sudo bash -c "echo 'Pin: origin packages.microsoft.com' >> /etc/apt/preferences"
sudo bash -c "echo 'Pin-Priority: -10' >> /etc/apt/preferences"
} else {
Write-Host "Known issue workaround already applied"
}
}

sudo apt-get update -y
sudo apt-get install dotnet-sdk-6.0 aspnetcore-runtime-6.0 dotnet-runtime-6.0
}
Expand Down

0 comments on commit 40c9082

Please sign in to comment.