Jenkins-运行NuGet软件包还原以生成此文件
当我在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]
我在构建日志中遇到了以上错误。
我搜索了错误并找到了解决方案
然而,
dotnet resotre <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]
根据解决方案参考,也许升级 Nuget
Package Installer 可以帮助我。但是我不知道如何通过命令行升级 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
。
请参阅:https : //docs.microsoft.com/zh-cn/nuget/reference/msbuild-
targets#restore-target
以上是 Jenkins-运行NuGet软件包还原以生成此文件 的全部内容, 来源链接: utcz.com/qa/417871.html