INT_PKG_BUILDER/apps/dotNET/install.ps1

26 lines
1.2 KiB
PowerShell
Raw Normal View History

2025-02-05 16:48:44 +00:00
# array of uninstall args
2025-02-05 17:45:52 +00:00
$uninstallArgs = "/uninstall"," ","/quiet", "IGNOREDEPENDENCIES=ALL"
2025-02-05 16:48:44 +00:00
$dotnetVersions = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -like "Microsoft .NET*" }
foreach ($version in $dotnetVersions) {
# update array index 1 with version id
2025-02-05 17:45:52 +00:00
$uninstallArgs[1] = '"' + $version.IdentifyingNumber + '"'
Write-Host "Uninstalling $($version.Name)... $("$uninstallArgs")"
2025-02-05 16:48:44 +00:00
Start-Process -FilePath "msiexec.exe" -ArgumentList "$uninstallArgs" -Wait
}
Write-Host "All Microsoft .NET versions uninstalled."
2025-02-05 17:45:52 +00:00
#$uri = "https://download.visualstudio.microsoft.com/download/pr/f1e7ffc8-c278-4339-b460-517420724524/f36bb75b2e86a52338c4d3a90f8dac9b/windowsdesktop-runtime-8.0.12-win-x64.exe"
$uri = "https://download.visualstudio.microsoft.com/download/pr/136f4593-e3cd-4d52-bc25-579cdf46e80c/8b98c1347293b48c56c3a68d72f586a1/dotnet-runtime-8.0.12-win-x64.exe"
2025-02-05 16:48:44 +00:00
$installerName =($uri -split "/")[-1]
$installerPath = ('./bin/' + $installerName)
if (-not (Test-Path -Path $installerPath)){
Invoke-WebRequest -Uri $uri -OutFile $installerPath
}
2025-02-05 17:45:52 +00:00
$installArgs = "/install","/quiet","/norestart"
2025-02-05 16:48:44 +00:00
Start-Process -FilePath $installerPath -ArgumentList "$installArgs" -Wait
Write-Host ("Microsoft .NET versions installed: " + $installerName)