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

丶灬走出姿态 提交于 2021-01-29 16:36:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!