Jenkins - 运行 NuGet 包还原来生成此文件

2024-04-02

当我在 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 https://github.com/Microsoft/vsts-tasks/issues/3762

但是,运行时:

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]

根据解决方案参考 https://github.com/Microsoft/vsts-tasks/issues/3762,也许升级Nuget 包安装程序可以帮助我。但不知道如何升级Nuget 包安装程序通过命令行...


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

error : Package <package> 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. [<path>]

我能够使用解决它MSBuild /t:restore代替dotnet restore.

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Jenkins - 运行 NuGet 包还原来生成此文件 的相关文章

随机推荐