6

I have installed VS 2019 today removing all other versions of VS (over come space crunch). Am trying to use nuget package manager but keep getting below exception. Nothing loads. I tried to install packages from console and ended up with same error as below. Any help would be appreciated.

PM> Install-Package Microsoft.Azure.Devices -Version 1.21.0 Install-Package : '' is not a valid version string. At line:1 char:1 + Install-Package Microsoft.Azure.Devices -Version 1.21.0 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Install-Package], Exception + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Time Elapsed: 00:00:00.6338016

2
  • First, did you use a new nuget.config file in your solution? Besides, please check whether you can access nuget.org. Right-click on your project-->Manage nuget packages and check whether you can see packages under nuget.org package source. Second, clean nuget caches. Third, run Install-Package Microsoft.Azure.Devices -Version 1.21.0 under package manager console. Commented Jun 18, 2020 at 8:48
  • If these does not work, please close VS Instance, delete C:\Users\xxx\AppData\Roaming\NuGet\NuGet.Config, then restart VS to test again. Commented Jun 18, 2020 at 8:49

4 Answers 4

1

'' is not a valid version string." exception in nuget for VS2019

You can try these steps:

1) first, check whether you can access the nuget package on Nuget Package Manager UI(Right-click on your project-->Manage Nuget Packages)

2) clean all nuget caches or delete all files under C:\Users\(user name)xxx\.nuget\packages

3) close VS Instance, delete .vs hidden folder under your solution folder ,bin and obj folder, delete C:\Users\xxx\AppData\Roaming\NuGet\NuGet.Config and then restart VS to test again.

4) add a new nuget package source and then add this in it as nuget.org path:

http://packages.nuget.org/v1/FeedService.svc/.

Enable it and test again.

5) please run this command on Package Manager Console:

Install-Package Microsoft.Azure.Devices -Version 1.21.0

Also, please make sure that you select the right project to install this package.

enter image description here

6) check if there is a firewall policy or other proxy settings that block the nuget installation package

In addition, you could try to create a new project to test whether this issue persists in it.

=======================================

Update 1 Solution

First, thanks to you for trying the method for creating a new project.

Just create a project and then migrate all the old project files into the the new project. This solves the issue.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for replying. i was was getting this issue over specific project. I just deleted the project and created new adding all the existing files to new project . Not really certain what was the issue but , it worked this way, not ideal though. To answer your question i was not able to loan nugets from neuget packet mgr. Will try out deleting nuget cache and hidden folder incase i encounter the issue next time.
1

I tried the solution above (deleting all the installed Nuget packages, .vm folder, etc) but it didn't work for me. I was on Visual Studio 2019 v 16.8.4. Updating to Version 16.8.5 solved this issue for me.

Comments

0

For me this error occurred when running dotnet list package --vulnerable --include-transitive (a check for vulnerable packages), but the root cause was our private package repository which we use next to nuget.org.

Temporarily disabling this did the trick:

  1. Run dotnet list package --vulnerable --include-transitive, this should output mentioned error
  2. Run dotnet nuget list source, this outputs two sources (e.g. Nuget and Local)
  3. Assuming Local is the problem, run dotnet nuget disable source Local
  4. Re-run dotnet list package --vulnerable --include-transitive and verify that error is gone
  5. Optionally, enable package source again with dotnet nuget enable source Local

Comments

-1

In my case another broken csproj file in the solution caused the problem.

Found it by divide-and-conquer removing projects from the solution.

Turns out a parameter in that other csproj file caused VS and NuGet Manager to malfunction.

2 Comments

Could you be a little bit more specific, please? Which parameter? Why? You say "Hope this helps someone else too" but your comment is really very generic and doesn't explain what the issue was...
no because the problem is very individual. But i gave the general hint how to find and resolve your specific problem if it is also caused by a broken csproj file because of a wrong version parameter(s).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.