简体   繁体   English

无法在VS2015中运行NuGet Package Command

[英]Cannot run NuGet Package Command in VS2015

I have done this many times with many projects on the same machine, but for some reason the following is not working for me: 我在同一台机器上做过很多次这样的项目,但由于某种原因,以下内容对我不起作用:

  1. Add desired DLL (filehelpers in this case) from NuGet package manager 从NuGet包管理器添加所需的DLL(在本例中为filehelpers)
  2. Install Costura.Fody (by default it includes Fody 2.0.6; 2.0.7 is available I tried both versions which produced the same result) 安装Costura.Fody(默认情况下它包括Fody 2.0.6; 2.0.7可用我尝试了两个版本产生相同的结果)
  3. Use Package Manager Console to run command Install-CleanReferencesTarget (copy/pasted from https://github.com/Fody/Costura ) 使用程序包管理器控制台运行命令Install-CleanReferencesTarget (从https://github.com/Fody/Costura复制/粘贴)

When I get to step three (which has always worked up until now) I get the following error: 当我到达第三步(到目前为止一直工作)时,我收到以下错误:

PM> Install-CleanReferencesTarget
Install-CleanReferencesTarget : The term 'Install-CleanReferencesTarget' 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 line:1 char:1
+ Install-CleanReferencesTarget
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Install-CleanReferencesTarget:String) [],
                              CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I have tried recreating the project, restarting my PC, restarting VS, running VS as admin, etc but same result. 我已经尝试重新创建项目,重新启动我的电脑,重新启动VS,运行VS作为管理员等,但结果相同。 I also verified the DLL in question (FileHelpers.dll) is set to copy local. 我还验证了有问题的DLL(FileHelpers.dll)设置为复制本地。

I also looked at the FodyWeavers.xml file in another project that included the same DLL and didn't have this issue, and that it is identical to the one in this troublesome project: 我还查看了包含相同DLL的另一个项目中的FodyWeavers.xml文件,并且没有此问题,并且它与此麻烦项目中的相同:

<?xml version="1.0" encoding="utf-8" ?>
<Weavers>
  <Costura/>
</Weavers>

Does anyone know why this is happening all of a sudden? 有谁知道为什么会突然发生这种情况?

As per the latest doc , it seems to have been removed in newer versions, which will automatically enable the feature. 根据最新的文档 ,似乎已在较新版本中删除,这将自动启用该功能。 Clean-up can be disabled by changing the Costura configuration file. 可以通过更改Costura配置文件来禁用清理。

DisableCleanup DisableCleanup

As part of Costura, embedded assemblies are no longer included as part of the build. 作为Costura的一部分,嵌入式组件不再作为构建的一部分包含在内。 This cleanup can be turned off. 可以关闭此清理。

Defaults to false 默认为false

 <Costura DisableCleanup='true' /> 

See also this post for more details on configuration options. 有关配置选项的更多详细信息,另请参阅此帖子

  1. Open the NuGet Package Management Console (View->Other Windows) and use the command line options, from here: Creating And Publishing A Package[^] 打开NuGet包管理控制台(View-> Other Windows)并使用命令行选项,从这里:创建和发布包[^]
  2. Compile this from the source: NuGet Package Project extension[^] (source is here: Home[^]) 从源代码编译:NuGet Package Project扩展[^](来源在这里:主页[^])

Not an answer as such, but I've just had the same issue and managed to find a work around. 这不是一个答案,但我只是遇到了同样的问题,并设法找到了解决方法。

In the end, rather than use the cmdlet, I added the Target to my proj file from the bottom of here . 最后,而不是使用该cmdlet,我从底部添加目标到我的凸出文件在这里 This seems to have worked. 这似乎有效。

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

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