简体   繁体   中英

Nuget not working after Windows Refresh (Windows 10 / VS2015 Community)

Because of some network card issues in my Surface pro 3, I refreshed my Windows 10 installation to what was the PC's state a few days before (about a week). This option supposedly only changes settings and installations (reg keys, installed software, etc.)

After that, I can't get Nuget to work properly on Visual Studio. Here are the symptoms: If you add a package, for instance MVVMLight, after dependency resolution and adding files, this is what I see in the console:

Executing script file 'C:\Users\Erick\Documents\Projects\test\packages\MvvmLight.5.2.0.0\tools\install.ps1'...
null : The term 'null' is not recognized as the name of a cmdlet, function, script file, or operable program. Check 
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\Erick\Documents\Projects\test\packages\MvvmLight.5.2.0.0\tools\install.ps1:160 char:15
+     $resources = null
+                  ~~~~
    + CategoryInfo          : ObjectNotFound: (null:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Locator

#text
-----
True 


Successfully installed 'MvvmLight 5.2.0' to Cierre de Eventos
========== Finished ==========

The packages.config file in the project gets correctly updated:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="CommonServiceLocator" version="1.3" targetFramework="net46" />
  <package id="MvvmLight" version="5.2.0.0" targetFramework="net46" />
  <package id="MvvmLightLibs" version="5.2.0.0" targetFramework="net46" />
</packages>

and the packages folders is created and with those packages in there. The thing is that inside each of those packages folder, for instance MvvmLight.5.2.0.0, I only see:

Content (Folder)
tools (Folder)
MvvmLight.5.2.0.0.nupkg
MvvmLight.5.2.0.nupkg

There is no lib folder and certainly no MvvmLight.5.2.0.0.dll! Since no dll is ever pulled, it isn't added to the project's references...

Also, in the root directory, there is no .nuget folder either... I know that in my older VS projects, there is a .nuget folder, but I am not sure if that is the way Nuget works anymore (as in VS2015/latest versions of Nuget).

With a package like the FirebirdSql.Data.FirebirdClient.4.7.0.0, I don't get any 'null' related error in the console, the lib folder is created, but in the net45 folder there only has a debug file FirebirdSql.Data.FirebirdClient.pdb, no dll...

So I have uninstalled/reinstalled nuget, uninstalled/reinstalled Visual Studio and still the same problem... What can I do to fix this?

This looks like a bug in the MvvmLight 5.2 install.ps1 PowerShell script. I see the same error if I install MvvmLight 5.2 using the NuGet Package Manager Console.

The line with the error has:

$resources = null

When it should be:

$resources = $null

Using null without the dollar sign prefix is not valid PowerShell. If you try to run the line $resources = null directly in PowerShell you will see the same error that NuGet reports.

I would report this as a bug against MvvmLight .

One workaround is to download the MvvmLight NuGet package and then using a zip file editor, such as 7zip, edit the install.ps1 file and fix the incorrect PowerShell. Then you can setup a package source that points to the directory containing the .nupkg file and install it from there without any errors.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM