2015-02-24 112 views
1

按照NuGet Documentation,NuGet包還原應「只是工作」與TFS 2013年TFS 2013未恢復的NuGet包

它不是。

當構建機器運行時,它給了我下面的錯誤(如不能找到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. 

有誰知道這事?

+2

這是在生成機器上嗎?如果是這樣,你是否在該機器上安裝了Visual Studio? – 2015-02-24 16:27:56

+0

@BuckHodges:是的,是的。 – Pharylon 2015-02-24 16:31:01

回答

1

問題竟然是,我們有一個內部的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> 
0

是否確定在Build Server的Visual Studio中啓用了Package Restore? Build Server可以訪問nuget.org嗎?您可以在Build Server上打開TestApp.sln並嘗試手動編譯。這是否工作?

Enable Package Restore

+0

是的,服務器上啓用了恢復功能,當在服務器上的VS中打開解決方案時,恢復軟件包並編譯。 – Pharylon 2015-02-25 18:41:36