2

Package Manager in VS2019 is totally broken for me.

enter image description here

When I attempt to view packages for my solution the UI just says "Error occurred" with the details below, '' is not a valid version string

My build environment is heavily customized with custom targets, and packages are loaded via an out-of-VS process called "corext." So my question is what file is being parsed when attempting to load the package manager? I have a nuget.config at the root of my enlistment as well as under AppData\Roaming\NuGet which I've deleted with no results. I've tried clearing out all the nuget caches. I've tried all of the suggestions in this post without luck. If I could get any more logs at all I might be able to unblock myself. I get exactly the same results in VS 2017. Any ideas?

Luke Schoen
  • 674
  • 6
  • 23
  • You said you have a new `nuget.config` file at the root of your enlistment. So I suggest you should check every `packagesources` node in the file. Check whether there is a space that affects. – Mr Qian Aug 21 '20 at 03:09
  • Could you please share your `nuget.config` file at the root of your enlistment with us? I think the issue is in this `nuget.config` file and there is a wrong space in somewhere else. – Mr Qian Aug 21 '20 at 03:44

2 Answers2

2

After countless hours of pain it was suggested to me to look for a <PackageReference> node with an unresolvable version number. To do this I went to any project in my tree and ran: msbuild /pp:pp.log foo.csproj. This generates a preprocessing log. In that log file I did a "find all instances" of "PackageReference". The first hit was a PackageReference in Directory.Build.props without a version number. The fix was to add (any) version number. I'll surely need to put in the right version number but the solution will look like this:

enter image description here

Luke Schoen
  • 674
  • 6
  • 23
0

First, please check your nuget.config file at the root of my enlistment. Usually, when you have a new nuget.config file over the root directory path of your project.

The current project and all projects in the subdirectory will use this nuget.config rather than the global nuget.config file(AppData\Roaming\NuGet). It will add the new pakageSource and will overwrite the same name of the packagesource from the global nuget.config file.

See this document about this info.

1) Please enter the nuget.config at the root of your enlistment.

Check if you have such node like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>

..............

  <packageSources>
    <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
    <add key="test123" value="C:\xxxx\" />   
    <add key="github source" value="https://xxxxxxxxxxxxxxxxxxxx"/>
  </packageSources>
  <disabledPackageSources>
  
    <add key="test123" value="true" />
    

  </disabledPackageSources>
  
</configuration>

If so, you should check every packagesource path and make sure there is no such a space on every packagesource in case of spelling mistakes.

Or you could use disabledPackageSources node to disable any packagesources except nuget.org.

Like this:

 <packageSources>
    <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
    <add key="test123" value="C:\xxxx\" />   
    <add key="github source" value="https://xxxxxxxxxxxxxxxxxxxx"/>
    .........
    .........
  </packageSources>

  <disabledPackageSources>      
    <add key="test123" value="true" />
    <add key="github source" value="true" />
   ..........    
  </disabledPackageSources>

Then, close VS and restart your project to test again.

Or you could just delete such nuget.config to check whether there is a error node in it. Also, make a backup.

2) Second, you could run this below under Tools-->NuGet Package Manager-->Package Manager Console.

 [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;

3) please try to a new project to check whether the issue persists in the new project. This can determine if there is a problem with nuget.config in that project.

Besides, you could try to share the nuget.config file with us.

In addition, if these do not help, please try the following steps:

a) disable any third party extensions under Extensions-->Manage Extensions

b) If these do not help, try to repair VS or update VS if there is a new update.

Mr Qian
  • 21,064
  • 1
  • 31
  • 41
  • I've deleted the nuget.config at my root, removed all packages.config around my project. In a project outside of my enlistment package manager works fine. Tried TLS12 but that didn't make a difference. I ran processmonitor looking for any packages.config or nuget.config touches and there weren't any. Turned off all extensions. VS is updated. Did a full git clean -dfx so there are no stray .vs folders or files hanging around. Is there anything I can do to get more logs to see where this error is coming from? – Luke Schoen Aug 21 '20 at 17:27