powershell - Visual Studio 中用于 PowerShell 项目的 Nuget

标签 powershell visual-studio-2015 nuget

如何在 Visual Studio 2015 中为我的 PowerShell 项目安装 nuget 包?我已经尝试使用 PowerShell 模块项目和 PowerShell 脚本项目来做到这一点。我已经为 Visual Studio 2015 安装了 PowerShell 工具。

当我打开这些项目时,包管理器控制台中的默认项目是空的。这是我的意思的屏幕截图。

empty Default project:

当我尝试安装 nuget 包时,例如Pester ,我收到以下错误。

PM> Install-Package Pester Install-Package : Project 'Default' is not found. At line:1 char:1 + Install-Package Pester + ~~~~~~~~~~~~~~~~~~~~~~     + CategoryInfo          : ObjectNotFound: (Default:String) [Install-Package], ItemNotFoundExc     eption     + FullyQualifiedErrorId : NuGetProjectNotFound,NuGet.PackageManagement.PowerShellCmdlets.Inst     allPackageCommand   PM>

最佳答案

我知道这个线程可能已经过时并且相当陈旧,但我的旧文章提供了一些可能的解决方案可能会对这里有所帮助。我测试了当前状态,但 VS 2015 中仍然不支持 PowerShell 项目和 NuGet 包。

当前状态是:

  • 选择 https://chocolatey.org/并将其安装在您的开发盒(和 CI)上 => 您使用以下命令全局安装 Pester:巧克力安装纠缠并在需要时对其进行更新。
  • 使用旧的 packages.config 并手动更新版本号并运行 nuget 恢复 (nuget 更新将不再适用于此类解决方案)。
  • 将整个 pester 版本到 repo 并直接调用它。您可以使用 nuget安装纠缠为此(如果您在某处的路径中有 nuget)

  • 链接:http://rostacik.net/2015/12/16/how-to-use-nuget-packages-even-with-powershell-projects-with-visual-studio-2015/

    关于powershell - Visual Studio 中用于 PowerShell 项目的 Nuget,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35414729/

    相关文章:

    .net - <TargetFramework> 和 <RuntimeFrameworkVersion> 有什么区别?

    dependencies - 安装 RavenDb Embedded 时出现 Nuget 依赖错误

    xml - 使用 powershell 将 XML 转换为特定的 JSON 结构

    c# - core 2.0 和 office interop - microsoft.office.core 包在哪里?

    xml - 如何使用 Xml.Save 强制或指定编码类型?

    c++ - 未调用基类构造函数?

    c# - 错误 CS0103 : The name does not exist in the current context when debugging referenced project

    visual-studio-2015 - 我发布时,Visual Studio 2015将配置从调试更改为发布

    powershell - 在 Windows 10 上通过 ssh 在 cygwin 上获得 rsync 的神奇组合

    powershell - 使用PowerShell自动进行Telnet