问题
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
回答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.
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.
来源:https://stackoverflow.com/questions/62442959/is-not-a-valid-version-string-exception-in-nuget-for-vs2019