Jenkins-运行NuGet软件包还原以生成此文件 [英] Jenkins - Run a NuGet package restore to generate this file

查看:2366
本文介绍了Jenkins-运行NuGet软件包还原以生成此文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

When I build .NET Standard 2.0 Library on Jenkins build server

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]

我在构建日志中遇到了一个错误.

I got an error above in build log.

我搜索了错误,然后发现了解决方案

I searched about error and I found solution

但是

dotnet resotre <Solution Name>

在开始构建之前清理工作区时,该解决方案无法解决问题.

the solution does not help me out when I clean my workspace before build starts.

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

Therefore, I insert command before MSBuild but I failed with

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 Package Installer ...

According to Solution reference, maybe upgrade Nuget Package Installer could help me out. But I do not know how can I upgrade Nuget Package Installer by command line...

推荐答案

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

I had the same problem, getting the same error:

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来解决它.

I was able to solve it using MSBuild /t:restore instead of dotnet restore.

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

这篇关于Jenkins-运行NuGet软件包还原以生成此文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆