11
11
https://github.com/SamErde/PowerShell/General
12
12
#>
13
13
14
+ [CmdletBinding ()]
15
+ param ()
16
+
14
17
# Download the .NET CLI install script if it is not found.
15
18
if ( (Get-Command - Name ' dotnet' - ErrorAction SilentlyContinue) ) {
16
- Write-Verbose " dotnet is already installed."
19
+ Write-Verbose ' dotnet is already installed.'
17
20
} else {
18
21
$DownloadPath = Join-Path - Path $env: TEMP - ChildPath ' dotnet-install.ps1'
19
22
try {
@@ -26,7 +29,6 @@ if ( (Get-Command -Name 'dotnet' -ErrorAction SilentlyContinue) ) {
26
29
27
30
# Install the dotnet tool. The script installs the latest LTS release by default.
28
31
# The current stable release is required for PowerShell 7.5, which depends on .NET 9.
29
- # Need to add a check for the appropriate version of .NET.
30
32
try {
31
33
.$DownloadPath - InstallDir ' ~/.dotnet' - Channel ' STS' # use of 'Current' is deprecated.
32
34
} catch {
@@ -35,10 +37,7 @@ if ( (Get-Command -Name 'dotnet' -ErrorAction SilentlyContinue) ) {
35
37
36
38
}
37
39
38
- dotnet dev- certs https -- trust
39
-
40
40
# Install PowerShell and add $HOME\.dotnet\tools to the PATH.
41
- # Need to add error handling for when the required version of .NET is missing.
42
41
try {
43
42
dotnet tool install -- global PowerShell
44
43
$env: PATH += ' ;' + [System.IO.Path ]::Combine($HOME , ' .dotnet' , ' tools' )
47
46
}
48
47
49
48
# Clean up.
50
- Remove-Variable - Name DownloadPath
51
- if (Test-Path - Path DownloadPath) {
49
+ if (Test-Path - Path $DownloadPath ) {
52
50
Remove-Item - Path $DownloadPath - Confirm:$false
53
51
}
52
+ Remove-Variable - Name DownloadPath
0 commit comments