NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 252 forks source link

Add an IsRooted check for the plugin env vars such as NUGET_PLUGIN_PATHS #8698

Open SamMackrill opened 5 years ago

SamMackrill commented 5 years ago

Details about Problem

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe): NuGet.exe

NuGet version (x.x.x.xxx): 5.2.0.6090

dotnet.exe --version (if appropriate):

VS version (if appropriate): N/A

OS version (i.e. win10 v1607 (14393.321)): win10

Worked before? If so, with which NuGet version: Unknown

Detailed repro steps so we can see the same problem

Using NUGET_PLUGIN_PATHS with CredentialProvider.Microsoft.exe (ADO) it seem to only work with an absolute path

  1. cd c:\nuget
  2. SET NUGET_PLUGIN_PATHS=c:\nuget\plugins\CredentialProvider.Microsoft.exe
  3. .\nuget.exe install mypackage
  4. Works
  5. SET NUGET_PLUGIN_PATHS=.\plugins\CredentialProvider.Microsoft.exe
  6. .\nuget.exe install mypackage
  7. Fails with plugin not found
nkolev92 commented 5 years ago

Relative paths are not allowed in the environment variable overrides.

The specs at: https://github.com/NuGet/Home/wiki/NuGet-Package-Download-Plugin#plugin-discovery and https://github.com/NuGet/Home/wiki/NuGet-cross-plat-authentication-plugin#plugin-installation-and-discovery call that out, but the official docs don't seem to.

https://docs.microsoft.com/en-us/nuget/reference/extensibility/nuget-cross-platform-plugins#plugin-installation-and-discovery I will fix that.

As a general rule, all of the env var overrides in NuGet only allow absolute paths. I'd be ok with adding a rooted path check in the plugin discovery, if you think that would've saved you some time.

nkolev92 commented 5 years ago

There's already a pattern for this: https://github.com/NuGet/NuGet.Client/blob/840b09a4cecda6ae8fd1c07967874fe8061ece63/src/NuGet.Core/NuGet.Configuration/Utility/SettingsUtility.cs#L240

nkolev92 commented 5 years ago

just an update, docs have been addressed with https://github.com/NuGet/docs.microsoft.com-nuget/pull/1735