1

根据NuGet 文档,NuGet 包还原应该与 TFS 2013 一起“正常工作”。

它不是。

当构建机器运行时,它给了我以下错误(找不到 Newtonsoft.Json)

Program.cs (5): The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)

这是一个全新的项目,在 TFS 2013 上使用默认模板 (TfvcTemplate.12.xaml)。我正在使用 VS 2013。老实说,我是 TFS 新手,所以我不确定构建日志应该是什么样子,但我的看起来像这样:

Overall Build Process
Overall build process
Update build number
Run on agent (reserved build agent CTIDEV2k8 - Agent1)
Initialize environment
Get sources from Team Foundation Version Control
Associate the changesets that occurred since the last good build
Compile, Test and Publish
Run optional script before MSBuild
Run MSBuild
Built $/Web/TestApp/TestApp.sln for default targets.
Built $/Web/TestApp/TestApp/TestApp.csproj for default targets.
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets (1697): Could not resolve this reference. Could not locate the assembly "Newtonsoft.Json". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
Program.cs (5): The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
MSBuild Log File
Exception Message: MSBuild error 1 has ended this build. You can find more specific information about the cause of this error in above messages. (type BuildProcessTerminateException)
Exception Stack Trace:    at System.Activities.Statements.Throw.Execute(CodeActivityContext context)
   at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
   at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
Handle Exception
Create a bug for the build failure
Rethrow the exception so the build will stop
Perform Final Actions On Agent
Copy binaries to drop
Reset the Environment
Work item '96: Build Failure in Build: TestApp2_20150224.2' was opened by the build.

有人对这个有了解吗?

4

2 回答 2

2

问题原来是我们有一个内部的 Nuget 包提要。通过将 nuget.config 文件添加到解决方案文件夹的根目录,该问题已得到解决:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageRestore>
    <add key="enabled" value="True" />
  </packageRestore>
  <packageSources>
    <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
    <add key="InternalFeed" value="https://our.nuget.com" />
  </packageSources>
  <activePackageSource>
    <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
  </activePackageSource>
</configuration>
于 2016-04-28T19:56:43.753 回答
0

您确定在构建服务器上的 Visual Studio 中启用了包还原吗?Build Server 可以访问 nuget.org 吗?您可以在构建服务器上打开 TestApp.sln 并尝试手动编译它。这行得通吗?

启用包还原

于 2015-02-25T18:13:28.413 回答