【问题标题】:Jenkins - Run a NuGet package restore to generate this fileJenkins - 运行 NuGet 包还原以生成此文件
【发布时间】:2018-12-31 06:16:40
【问题描述】:

当我在 Jenkins 构建服务器上构建 .NET Standard 2.0 库时

C:\Program Files\dotnet\sdk\2.1.302\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198,5): error : Assets file 'C:\Jenkins\workspace\<Project>\Sources\Library\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. [C:\Jenkins\workspace\<Project>\Sources\Library\Library.csproj]

我在构建日志中遇到了上述错误。

我搜索了错误,发现solution

但是,运行时:

dotnet restore <Solution Name>

当我在构建开始之前清理我的工作区时,该解决方案无法帮助我。

因此,我在 MSBuild 之前插入命令,但失败了

C:\Program Files\dotnet\sdk\2.1.302\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198,5): error : Package Microsoft.CodeAnalysis.CSharp.Workspaces, version 2.8.0 was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions. [C:\Jenkins\workspace\<Project>\Sources\Web\Web.csproj]

根据Solution reference,也许升级Nuget Package Installer 可以帮助我。但是我不知道如何通过命令行升级Nuget Package Installer...

【问题讨论】:

    标签: jenkins msbuild nuget-package-restore


    【解决方案1】:

    我遇到了同样的问题,得到了同样的错误:

    error : Package &lt;package&gt; was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions. [&lt;path&gt;]

    我能够使用MSBuild /t:restore 而不是dotnet restore 来解决它。

    见:https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#restore-target

    【讨论】:

      【解决方案2】:

      更新:值得一提的是,在另一个answer 中深入讨论了 Jenkins 中的问题。

      @Mat 的提示对我不起作用:/t:restore 目前无法恢复使用 package.config 的项目的 nuget 包,正如我提到的 here。对我有用的是:

      call "%PROGRAMFILES(X86)%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
      nuget restore CodeBinder.sln
      MSBuild Solution.sln /p:Configuration=Release /p:Platform="Any CPU" /t:build /restore
      pause
      

      它基本上需要从官方网站[1],Windows x86 命令行部分下载 nuget CLI。开关/restore,正如here 所指出的,修复了部分完成的Nuget 恢复错误,类似于MSBuild /t:restore,但它可以与/t:build 一起完成。

      [1]https://www.nuget.org/downloads

      【讨论】:

      • 这个解决方案对我有用。我的解决方案有一些带有 package.config 的项目,只有一个带有包引用。
      猜你喜欢
      • 2019-11-09
      • 1970-01-01
      • 2018-07-04
      • 1970-01-01
      • 1970-01-01
      • 2018-07-31
      • 2023-03-05
      • 1970-01-01
      • 2015-10-11
      相关资源
      最近更新 更多