install-scripts icon indicating copy to clipboard operation
install-scripts copied to clipboard

Path assembly bug in dotnet-install.ps1

Open InteXX opened this issue 1 year ago • 2 comments
trafficstars

On line 770, $InstallRoot is set to the value of the DOTNET_INSTALL_DIR environment variable (C:\Program Files\dotnet\sdk in my case). This results in the creation of a duplicate sdk folder name in the Is-Dotnet-Package-Installed() function at line 789.

$DotnetPackagePath is incorrectly set to C:\Program Files\dotnet\sdk\sdk\8.0.303.

This results in the script attempting to proceed with the installation instead of failing gracefully (at line 1234), which in turn results in an inappropriate error:

dotnet-install: Failed to extract package. Exception: Exception calling "ExtractToFile" with "3" argument(s): "Access to the path 'C:\Program Files\dotnet\sdk\dotnet.exe' is denied."
Exception calling "ExtractToFile" with "3" argument(s): "Access to the path 'C:\Program Files\dotnet\sdk\dotnet.exe' is denied."
At E:\Users\Work\Downloads\dotnet-install.ps1:864 char:21
+ ...             [System.IO.Compression.ZipFileExtensions]::ExtractToFile( ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnauthorizedAccessException

I'm running the script non-elevated and with no parameters.

InteXX avatar Jul 22 '24 11:07 InteXX