我正在尝试使用NuGet TeamCity构建步骤来恢复.NET核心解决方案的NuGet安装程序包。“MSBuild自动检测”选择MSBuild v4.0而不是.NET核心项目所需的v15.0:
[15:41:53][restore] Starting NuGet.exe 4.1.0.2450 from C:\TeamCity\buildAgent\tools\NuGet.CommandLine.4.1.0\tools\NuGet.exe
[15:41:53][restore] MSBuild auto-detection: using msbuild version '4.0' from 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319'.
[15:41:53][restore] Nothing to do. None of the projects in this solution specify any packages for NuGet to restore.
[15:41:53][restore] Process exited with code 0
这将导致在包恢复之后运行的“MSBuild”TeamCity步骤中的编译错误:
Assets file 'C:\TeamCity\...\MyProj\obj\project.assets.json' not found.
Run a NuGet package restore to generate this file.
对于“MSBuild”TeamCity步骤,我手动选择MSBuildTools版本,如本所以回答中所述:
但是我没有找到“NuGet安装程序”步骤的类似设置。我是不是遗漏了什么?
发布于 2017-06-13 15:04:56
发布于 2017-06-13 13:34:51
两件事,
这可能是因为它在从C:\TeamCity\buildAgent\tools\NuGet.CommandLine.4.1.0\tools\NuGet.exe,启动NuGet.exe 4.1.0.2450的文件夹中运行,而不是像您预期的那样在源代码目录中运行。
您的项目中有packages.config文件吗?
发布于 2017-06-13 13:48:32
如果您只使用.NET核心/ .NET标准项目(“基于SDK的”csproj),则不需要使用nuget.exe
进行还原,而是可以创建调用Restore
目标的msbuild调用:
msbuild /t:Restore the.sln
如果使用PackageReference
包管理格式,这也适用于非核心/标准项目(典型的csproj):
https://stackoverflow.com/questions/44522321
复制相似问题