I am using Artifactory as NuGet repository to store all the nuget packages.
When we use this Artifactory link as source, the package Manager in Visual Studio prompts for credentials and worked very fine.
As soon as we moved to build machine (with out VS) and try to build application it is throwing error :
.nugetNuGet.targets(100,9): error : Key not valid for use in specified state.
I added source with -user -password and put config at local user location. I tried with ClearText password and encrypted password both are throwing same error.
Am I missing anything here? Please advice.
what's the nuget version and visual studio version you are using?
NuGet Package manager : 2.8.50926.663
Visual Studio 12.0
your config file looks right, Can you provide your NuGet.target file? I can't repro on my machine
I checked NuGet.target file, looks like line(100,9) is calling nuget restore command. I can't find where the error message come from. Can you use nuget.exe to restore your package in your build machine?
if there is any error, send the error message to me. thanks
Thanks for reply zhili1208. Yes , I am able to restore everything using nugget.exe on build machine. But again it is restoring from nugget.org instead of Artifactory location.
that's good if nuget.org works for you. I can't figure out what's the issue from your description. If you still want to restore from Artifactory location, I can help.
First, make sure you can connect to Artifactory location from your build machine with your username and password, And use nuget config command to set user name and password, then try to use nuget.exe restore package from Artifactory location. if there is any error message, send to me. I can debug it. Thanks.
Yup , I did the same thing as you mentioned. I can connect to artifactory using my user name and Password from build server. I added them into nugget config using command line as shown in above image.
But still it is restoring from nugget instead of artifactory.
Yes , I want to restore from Artifactory.
you can disable the nuget.org source, just left the artifactory source. Then can you restore package?
then I got this error : .nugetNuGet.targets(100,9): error : Key not valid for use in specified state.
for me, it looks like a CryptographicException exception. so if you use clearText password, it still has this error?
yes. I tried with clearText too . it throws the same error. Do need to check anything on artifactory side?
so if it still has this problem. I think this error comes from your server side. http client send the request to your server with the encoded username and password, but the server can't decode it. so got this error. Since I can't repro this on my side, I only can guess what's the issue.
Because googling Key not valid for use in specified state brought you here:
You might see this error when copying a nuget.config file with an encrypted password already stored in it, like into a windows container for example. Always run the nuget sources add or nuget sources update command on the same machine that you're planning to use nuget on.
Using the example above, after adding the nuget.config file to the container try running nuget sources update -Name Artifact -UserName %ARTIFACTORY_USER% -Password %ARTIFACTORY_API_KEY% to fix up the nuget file.
Facing the same problem when copying a nuget.config file to a windows container to build it. If I need to run nuget sources add on it, what is the purpose of that file?
I constantly have issues with nuget package feed authentication. I have removed the source, and re-added it using nuget sources add with a brand new PAT, and arbitrary username (does not matter??? documentation is HIGHLY ambiguous...) - and I am still getting Unable to load the service index for source <feed_url> Key not valid for use in specified state.
Is someone at Microsoft turning off my access to my software that I have created?
And as soon as I write my stupid comment, I find my stupid answer: nuget install <source_name> -NonInteractive -Source <source_name> -SolutionDirectory "<my_solution_directory>"
Most helpful comment
Because googling
Key not valid for use in specified statebrought you here:You might see this error when copying a nuget.config file with an encrypted password already stored in it, like into a windows container for example. Always run the
nuget sources addornuget sources updatecommand on the same machine that you're planning to use nuget on.Using the example above, after adding the nuget.config file to the container try running
nuget sources update -Name Artifact -UserName %ARTIFACTORY_USER% -Password %ARTIFACTORY_API_KEY%to fix up the nuget file.