【问题标题】:Missing required property 'OutputPath' for project type 'PackageReference'缺少项目类型“PackageReference”所需的属性“OutputPath”
【发布时间】:2019-05-07 11:04:52
【问题描述】:

我正在尝试通过 Jenkins Pipeline 运行以下命令

bat 'nuget restore mySolution.sln -MSBuildPath "C:\\Program Files (x86)\\MSBuild\\14.0\\Bin"'

但我说错了

无效的恢复输入。缺少必需的属性“OutputPath” 项目类型“PackageReference”。输入文件:C:\Program Files (x86)\Jenkins\workspace\我的项目构建 管道\myProject\myProject.csproj。

我试过了

bat label: '', script: '"C:\\Package tools\\nuget.exe" restore "C:\\Program Files (x86)\\Jenkins\\workspace\\My Project Build Pipeline\\myProject\\myProject.csproj" -MSBuildPath "C:\\Program Files (x86)\\MSBuild\\14.0\\Bin"'  // Restore packages.

我希望在 Visual Studio 中“恢复 NuGet 包”时安装所有 NuGet 包。

【问题讨论】:

  • 您的C:\Program Files (x86)\Jenkins\workspace\My Project Build Pipeline\myProject\myProject.csproj 中有outputPath 吗?
  • 是的,我在属性组下有它,<OutputPath>bin\Release\</OutputPath>
  • 这个 OutputPath 属性位于<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
  • 这在PackageReference 下找不到。这就是错误所在。我尝试通过 msdn 阅读.. 但找不到我想要的。
  • 我也尝试根据github.com/Microsoft/msbuild/issues/3000更新nuget,但没有帮助。

标签: msbuild jenkins-pipeline


【解决方案1】:

显然,您正在使用 VS 2015 工具 (MSBuild 14) 和/或较旧的 nuget.exe (PackageReference 引用 NuGet 包的方式处理项目。使用较新的工具(Nuget 4+、VS / Build Tools 2017+)来解决此问题。

【讨论】:

  • 谢谢。我正在使用 VS 2019 和 NuGet 4+。但它选择的是 MSBuild 版本 14。我不得不将它指向最新的 MSBuild,它位于 Microsoft Visual Studio 程序文件中。
  • 我建议使用 vswhere 来查找 msbuild 位置,并且默认情况下 nuget 也应该能够选择正确的路径。如果您使用的是 VS 2019,我建议使用 NuGet 5+。如果您只使用基于 PackageReference 的项目,您可以直接使用 msbuild 并将 /restore 传递给它。
【解决方案2】:

我通过运行 powershell 命令解决了这个问题:

Install-Module VSSetup -Scope CurrentUser

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-26
    • 2014-01-20
    • 2022-08-15
    • 2022-01-19
    • 1970-01-01
    • 2012-02-23
    相关资源
    最近更新 更多