PowerShellGetv2
PowerShellGetv2 copied to clipboard
NuGetApiKey is required for nuget based gallery service
Hey, I would like to submit my attempt at fixing the problem described in issue #143
I removed the ValidateNotNullOrEmpty check from the NugetApiKey parameter and implemented if statements checking for the parameter in Publish-Module and Publish-PSArtifactUtility when constructing parameters, in the same way credentials are added conditionally.
I ran tests on my machine after making the changes and got the following results:
Tests Passed: 348, Failed: 10, Skipped: 53
Most of the failures were related to the dotnet cli tool, I have version 3.0.0 preview installed and imagine that might be conflicting.
With this change the cmdlet fails if no apikey is passed, in the same way as if an invalid apikey is passed, with a 403 status code from the API.
@heidarj I'm pretty sure the argument to nuget.exe I call out above is wrong, but otherwise this should be fine. Let us know if you have time to update?
@edyoung I implemented the localized NuGetApiKeyIsRequiredForNuGetBasedGalleryService error message for when an API key is not specified so that it now throws the same error as before, if the repo you are pushing to requires an API key. Please let me know if any further changes are needed, otherwise I am good with this as is.
Thanks! I think it's still a problem to pass --api-key when calling nuget, because it doesn't support the -- based parameter form. Also looks like the branch needs to be rebased or merged to match what's currently in development. If it's possible to fix that will happily merge.