我有一个项目,当在VS中构建时会成功:
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中构建的时候,它失败的原因对我来说一点都不清楚:
[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
只有在使用TC构建时才会出现此错误NU1001: The dependency System.Data could not be resolved
,我该如何解决?
超过一小时的谷歌研究没有发现任何有用的东西,甚至没有一些可能有用的东西。
这是project.json,如果事实证明是有用的。
{
"version": "1.1.0-*",
"dependencies": {
"Microsoft.Azure.DocumentDB": "1.11.1",
"WindowsAzure.Storage": "8.0.1"
},
"frameworks": {
"net452" : {}
}
}
由于
答案 0 :(得分:1)
答案结果是我的TeamCity服务器没有所有的DotNetFrameworkTargetingPacks。特别是它确实有4.0,4.5和4.6包,但缺少4.5.1,4.5.2,4.6.1和4.6.2的包。
我是从这个网站下载的:http://getdotnet.azurewebsites.net/target-dotnet-platforms.html
4包是 .NET Framework 4.6.2开发人员包 .NET Framework 4.6.1 Targeting Pack .NET Framework 4.5.2开发人员包 .NET Framework 4.5.1开发人员包
安装完所有4个后,我重新启动了TC Server,重新运行了构建,然后它们就完成了。