dotnet / install-scripts

MIT License
145 stars 76 forks source link

Check if user has write access to the install root #513

Closed GangWang01 closed 2 months ago

GangWang01 commented 2 months ago

Fix

496

Solution

Add the check that tests if user has write access to install root. If user doesn't have, fail the installation with an error telling running as administrator. Additionally, if user specifies the install root via environment variable DOTNET_INSTALL_DIR to the sub folder of $env:ProgramFiles\dotnet, warn that it's better to keep aligned with .NET SDK installer.

YuliiaKovalova commented 2 months ago

@GangWang01 , thank you for handling this! It is possible to cover this case with UTs?

nlsdg commented 2 months ago

As the stated purpose of these scripts is "perform a non-admin installation", I think the message to the user shouldn't just be to try running as administrator. (Also: if they had admin access they could also just run a normal install.) The possibility to use/change the -InstallDir parameter could be added to the message to make theuser aware it exists or might be wrong.

GangWang01 commented 2 months ago

It is possible to cover this case with UTs?

Running in CI it's a little difficult to get a normal user with general permission for the test. I just did testing locally.