问题描述
我有一个项目,当使用VS构建时,该项目将成功:
I have a project which, when built in VS will succeed:
PM> dotnet build -f net452
Project Core.RecordingProvider (.NETFramework,Version=v4.5.2) will be compiled because expected outputs are missing
Compiling Core.RecordingProvider for .NETFramework,Version=v4.5.2
Compilation succeeded.
0 Warning(s)
0 Error(s)
Time elapsed 00:00:01.0807947
但是,当该项目在TeamCity中构建时,由于我完全不知道的原因而失败:
But, when that project is built in TeamCity, it fails for reasons which are not at all clear to me:
[11:37:40]Step 1/4: -- Restore -- (.NET Core (dotnet)) (5s)
[11:37:40]Starting: "C:\Program Files\dotnet\dotnet.exe" restore
[11:37:40]in directory: C:\BuildAgents\Agent-5\work\e1ee23b6a628140b
[11:37:41]log : Restoring packages for C:\BuildAgents\Agent-5\work\e1ee23b6a628140b\Core.RecordingProvider\Core.RecordingProvider.Tests\project.json...
[11:37:41]log : Restoring packages for C:\BuildAgents\Agent-5\work\e1ee23b6a628140b\Core.RecordingProvider\src\Core.RecordingProvider.FunctionalTests\project.json...
[11:37:41]log : Restoring packages for C:\BuildAgents\Agent-5\work\e1ee23b6a628140b\Core.RecordingProvider\src\Core.RecordingProvider\project.json...
[11:37:44]log : Writing lock file to disk. Path: C:\BuildAgents\Agent-5\work\e1ee23b6a628140b\Core.RecordingProvider\src\Core.RecordingProvider.FunctionalTests\project.lock.json
[11:37:44]log : C:\BuildAgents\Agent-5\work\e1ee23b6a628140b\Core.RecordingProvider\src\Core.RecordingProvider.FunctionalTests\project.json
[11:37:44]log : Restore completed in 2199ms.
[11:37:44]log : Writing lock file to disk. Path: C:\BuildAgents\Agent-5\work\e1ee23b6a628140b\Core.RecordingProvider\Core.RecordingProvider.Tests\project.lock.json
[11:37:44]log : C:\BuildAgents\Agent-5\work\e1ee23b6a628140b\Core.RecordingProvider\Core.RecordingProvider.Tests\project.json
[11:37:44]log : Restore completed in 2463ms.
[11:37:45]log : Writing lock file to disk. Path: C:\BuildAgents\Agent-5\work\e1ee23b6a628140b\Core.RecordingProvider\src\Core.RecordingProvider\project.lock.json
[11:37:45]log : C:\BuildAgents\Agent-5\work\e1ee23b6a628140b\Core.RecordingProvider\src\Core.RecordingProvider\project.json
[11:37:45]log : Restore completed in 3556ms.
[11:37:45]Process exited with code 0
[11:37:45]Step 2/4: -- Build -- (.NET Core (dotnet)) (1s)
[11:37:45]Starting: "C:\Program Files\dotnet\dotnet.exe" build Core.RecordingProvider/src/Core.RecordingProvider --framework net452 --configuration Debug --build-profile --no-incremental
[11:37:45]in directory: C:\BuildAgents\Agent-5\work\e1ee23b6a628140b
[11:37:46]Project Core.RecordingProvider (.NETFramework,Version=v4.5.2) will be compiled because project is not safe for incremental compilation. Use --build-profile flag for more information.
[11:37:46]Compiling Core.RecordingProvider for .NETFramework,Version=v4.5.2
[11:37:46]C:\BuildAgents\Agent-5\work\e1ee23b6a628140b\Core.RecordingProvider\src\Core.RecordingProvider\project.json(8,33): error NU1001: The dependency System.Data could not be resolved.
[11:37:46]
[11:37:46]Compilation failed.
[11:37:46] 0 Warning(s)
[11:37:46] 1 Error(s)
[11:37:46]
[11:37:46]Time elapsed 00:00:00.0319611
[11:37:46]
[11:37:46]Process exited with code 1
[11:37:47]Step -- Build -- (.NET Core (dotnet)) failed
此错误是什么 NU1001:无法解析依赖项System.Data
,仅在使用TC构建时会发生,该如何解决?
What is this error NU1001: The dependency System.Data could not be resolved
that only occurs when building with TC, and how do I resolve it?
在Google上进行了一个多小时的研究并没有发现任何有用的东西,甚至没有暗示可能有用的东西。
More than an hours worth of research on Google hasn't turned up anything useful, not even a hint of something that might be useful.
这里是project.json,以防万一有用。
Here's the project.json, in case that turns out to be useful.
{
"version": "1.1.0-*",
"dependencies": {
"Microsoft.Azure.DocumentDB": "1.11.1",
"WindowsAzure.Storage": "8.0.1"
},
"frameworks": {
"net452" : {}
}
}
谢谢
推荐答案
答案是我的TeamCity服务器没有所有的DotNetFrameworkTargetingPacks。特别是,它确实具有4.0、4.5和4.6包,但缺少4.5.1、4.5.2、4.6.1和4.6.2的包。
The answer turned out to be that my TeamCity server did not have all the DotNetFrameworkTargetingPacks. In particular, it did have the 4.0, 4.5, and 4.6 packs, but was missing the packs for 4.5.1, 4.5.2, 4.6.1, and 4.6.2.
我从以下网站下载了它们:
I downloaded them from this website: http://getdotnet.azurewebsites.net/target-dotnet-platforms.html
这四个包是
.NET Framework 4.6.2开发人员包
.NET Framework 4.6 .1 Targeting Pack
.NET Framework 4.5.2开发人员包
.NET Framework 4.5.1开发人员包
The 4 packs were.NET Framework 4.6.2 Developer Pack.NET Framework 4.6.1 Targeting Pack.NET Framework 4.5.2 Developer Pack.NET Framework 4.5.1 Developer Pack
在安装了全部4个之后,我重新启动了TC Server,重新运行了构建,然后运行完成。
After I installed all 4 of them, I rebooted the TC Server, re-ran the builds, and they ran to completion.
这篇关于TeamCity构建失败,VS 2015构建成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!