PowerShellGetv2
PowerShellGetv2 copied to clipboard
Get-CredsFromCredentialProvider Option 1b) Find User-location - The NuGet Home location
Steps to reproduce
- Environment variable NUGET_PLUGIN_PATHS is not set.
- Windows : file $env:UserProfile/.nuget/plugins/netcore/CredentialProvider.Microsoft/CredentialProvider.Microsoft.dll exists.
- GNU/Linux, MacOS : file $HOME/.nuget/plugins/netcore/CredentialProvider.Microsoft/CredentialProvider.Microsoft.dll exists.
if(-not (Test-Path env:NUGET_PLUGIN_PATHS) -and
(Test-Path "$env:UserProfile/.nuget/plugins/netcore/CredentialProvider.Microsoft/CredentialProvider.Microsoft.dll")
) {
Get-CredsFromCredentialProvider "http://someNuGetUrl.com/api/v2"
} else {
Write-Warning "Test conditions not met"
}
Expected behavior
We should either :
- be prompted with a device flow url which will allow you to authenticate the repository, o
- fetch the credential
- or if dotnet SDK is not yet installed (as explained here) get an error message.
Indeed, as the environment variable NUGET_PLUGIN_PATHS is not set, we should use the default dll (option 1b in code of Get-CredsFromCredentialProvider).
UserName Password
-------- --------
VssSessionToken System.Security.SecureString
Actual behavior
The function does nothing, because option 1b fails.
My opinion
The quotes in the definition of path variable of option 1b should be removed, because they are useless and cause the Test-Path command to return $false all the time.
$path = "`"$env:UserProfile/.nuget/plugins/netcore/CredentialProvider.Microsoft/CredentialProvider.Microsoft.dll`"";
if ($script:IsLinux -or $script:IsMacOS) {
$path = "`"$HOME/.nuget/plugins/netcore/CredentialProvider.Microsoft/CredentialProvider.Microsoft.dll`"";
}
if (Test-Path $path -PathType Leaf) {
$credProviderPath = $path
}
For example option 2 defines credProviderPath like this :
$credProviderPath = ($vsInstallationPath + '\Common7\IDE\CommonExtensions\Microsoft\NuGet\Plugins\CredentialProvider.Microsoft\CredentialProvider.Microsoft.exe')
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.17134.858
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17134.858
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
> Get-Module -ListAvailable PowerShellGet,PackageManagement
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.4.3 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Script 2.2 PowerShellGet {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability...}
Script 1.0.0.1 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module...}
> Get-PackageProvider -ListAvailable
Name Version DynamicOptions
---- ------- --------------
msi 3.0.0.0 AdditionalArguments
msu 3.0.0.0
nuget 2.8.5.208
NuGet 3.0.0.1 Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrereleaseVersions, ConfigFile, SkipValidate
PowerShellGet 2.2.0.0 PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate, AllowPrereleaseVersions, Filter, ...
PowerShellGet 1.0.0.1
Programs 3.0.0.0 IncludeWindowsInstaller, IncludeSystemComponent
Thanks @clientFDJ for the detailed repro/system information and for opening the issue. Also apologize for the delayed response! We were able to reproduce this and @alerickson is looking into a fix.