无法在VS2015中运行NuGet Package Command

时间:2017-05-04 20:44:03

标签: c# visual-studio-2015 nuget

我已经在同一台机器上执行了很多次这样的项目,但由于某些原因,以下内容对我不起作用:

  1. 从NuGet包管理器
  2. 添加所需的DLL(在本例中为filehelpers)
  3. 安装Costura.Fody(默认情况下它包含Fody 2.0.6; 2.0.7可用我试过两个版本产生相同的结果)
  4. 使用程序包管理器控制台运行命令Install-CleanReferencesTarget(从https://github.com/Fody/Costura复制/粘贴)
  5. 当我到达第三步(总是一直工作到现在为止)时,我收到以下错误:

    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
    

    我尝试重新创建项目,重新启动我的电脑,重新启动VS,以管理员身份运行VS等,但结果相同。我还验证了有问题的DLL(FileHelpers.dll)设置为复制本地。

    我还查看了另一个包含相同DLL的项目中的FodyWeavers.xml文件,并且没有这个问题,并且它与这个麻烦项目中的文件相同:

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

    有谁知道为什么会突然发生这种情况?

3 个答案:

答案 0 :(得分:2)

根据latest doc,它似乎已在较新版本中删除,这将自动启用该功能。可以通过更改Costura配置文件来禁用清理。

  

DisableCleanup

     

作为Costura的一部分,嵌入式组件不再包含在内   构建。可以关闭此清理。

     

默认为false

<Costura DisableCleanup='true' />

有关配置选项的详细信息,另请参阅this post

答案 1 :(得分:1)

  1. 打开NuGet包管理控制台(View-&gt; Other Windows)并使用命令行选项,从这里:创建和发布包[^]
  2. 从源代码编译:NuGet Package Project扩展[^](来源在这里:主页[^])

答案 2 :(得分:0)

不是这样的答案,但我遇到了同样的问题,并设法找到了解决办法。

最后,我将目标添加到here底部的proj文件中,而不是使用cmdlet。这似乎有效。