简体   繁体   English

Windows刷新后Nuget无法正常工作(Windows 10 / VS2015社区)

[英]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). 由于Surface pro 3中的某些网卡问题,我将Windows 10安装刷新到几天前(大约一周)的PC状态。 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. 之后,我无法让Nuget在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: 症状如下:如果在依赖性解析和添加文件之后添加了软件包(例如MVVMLight),这就是我在控制台中看到的内容:

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: 项目中的packages.config文件已正确更新:

<?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. 然后创建packages文件夹,并在其中包含这些软件包。 The thing is that inside each of those packages folder, for instance MvvmLight.5.2.0.0, I only see: 关键是在每个包文件夹中,例如MvvmLight.5.2.0.0,我只看到:

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! 没有lib文件夹,当然也没有MvvmLight.5.2.0.0.dll! Since no dll is ever pulled, it isn't added to the project's references... 由于从未提取过任何dll,因此不会将其添加到项目的引用中...

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). 另外,在根目录中也没有.nuget文件夹...我知道在我的旧版VS项目中,有一个.nuget文件夹,但是我不确定Nuget是否能继续工作(如VS2015) /最新版本的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... 使用FirebirdSql.Data.FirebirdClient.4.7.0.0之类的程序包,在控制台中没有得到任何与“ null”相关的错误,创建了lib文件夹,但是在net45文件夹中只有调试文件FirebirdSql.Data .FirebirdClient.pdb,没有dll ...

So I have uninstalled/reinstalled nuget, uninstalled/reinstalled Visual Studio and still the same problem... What can I do to fix this? 因此,我已经卸载/重新安装了nuget,卸载/重新安装了Visual Studio,仍然存在相同的问题...我该怎么做才能解决此问题?

This looks like a bug in the MvvmLight 5.2 install.ps1 PowerShell script. 这看起来像是MvvmLight 5.2 install.ps1 PowerShell脚本中的错误。 I see the same error if I install MvvmLight 5.2 using the NuGet Package Manager Console. 如果使用NuGet软件包管理器控制台安装MvvmLight 5.2,则会看到相同的错误。

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. 使用不带美元符号前缀的null无效,PowerShell无效。 If you try to run the line $resources = null directly in PowerShell you will see the same error that NuGet reports. 如果尝试直接在PowerShell中运行$resources = null行,您将看到与NuGet报告相同的错误。

I would report this as a bug against MvvmLight . 我将其报告为针对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. 一种解决方法是下载MvvmLight NuGet程序包,然后使用zip文件编辑器(例如7zip),编辑install.ps1文件并修复错误的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. 然后,您可以设置一个包源,该包源指向包含.nupkg文件的目录,并从那里安装它而不会出现任何错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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