我真的很疯狂地使用nuget并在Visual Studio Team Services(visualstudio.com)下构建解决方案。任何帮助将不胜感激。
我有一个包含36个项目的解决方案。许多项目使用相同的5或6个nuget包。我已仔细按照Migrating MSBuild-Integrated solutions to use Automatic Package Restore的说明操作,因此在我的解决方案文件夹下有一个.nuget文件夹,其中包含唯一的NuGet.Config文件,不再包含Nuget.exe或Nuget.targets文件。所有项目都删除了Nuget.targets行。
我正在使用Visual Studio 2013 Professional(v12 Update 2),解决方案在本地构建,没有错误或警告。即使在清理并删除packages文件夹之后,它也会下载并构建正常。 package文件夹未在Visual Studio Team Services中签入。
检查构建日志表明:
事情开始失败的日志示例(虽然这显然是因为nuget没有介入):
Project "C:\a\src\TFS\RSPlatform\Main\Source\RSPlatform Team Project.sln" (1) is building "C:\a\src\TFS\RSPlatform\Main\Source\Support\A2Refresh\A2Refresh.csproj" (8) on node 1 (default targets).
PrepareForBuild:
Creating directory "obj\Release\".
ResolveAssemblyReferences:
Primary reference "Bytescout.Spreadsheet".
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Bytescout.Spreadsheet". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [C:\a\src\TFS\RSPlatform\Main\Source\Support\A2Refresh\A2Refresh.csproj]
For SearchPath "C:\a\src\TFS\RSPlatform\Main\Source\Support\A2Refresh\FakesAssemblies".
Considered "C:\a\src\TFS\RSPlatform\Main\Source\Support\A2Refresh\FakesAssemblies\Bytescout.Spreadsheet.winmd", but it didn't exist.
Considered "C:\a\src\TFS\RSPlatform\Main\Source\Support\A2Refresh\FakesAssemblies\Bytescout.Spreadsheet.dll", but it didn't exist.
Considered "C:\a\src\TFS\RSPlatform\Main\Source\Support\A2Refresh\FakesAssemblies\Bytescout.Spreadsheet.exe", but it didn't exist.
For SearchPath "{HintPathFromItem}".
Considered "..\..\packages\Bytescout.Spreadsheet.2.4.0.1346\lib\net45\Bytescout.Spreadsheet.dll", but it didn't exist.
For SearchPath "{TargetFrameworkDirectory}".
Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Bytescout.Spreadsheet.winmd", but it didn't exist.
Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Bytescout.Spreadsheet.dll", but it didn't exist.
Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Bytescout.Spreadsheet.exe", but it didn't exist.
Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\Bytescout.Spreadsheet.winmd", but it didn't exist.
Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\Bytescout.Spreadsheet.dll", but it didn't exist.
Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\Bytescout.Spreadsheet.exe", but it didn't exist.
For SearchPath "{Registry:Software\Microsoft\.NETFramework,v4.5.1,AssemblyFoldersEx}".
Considered AssemblyFoldersEx locations.
For SearchPath "{AssemblyFolders}".
有人可以建议我如何让Visual Studio Team Services使用nuget吗?
如果自动包恢复建议删除~/.nuget/NuGet.exe
,Visual Studio Team Services如何使用NuGet?
提前致谢, 克里斯
答案 0 :(得分:4)
如果您正在构建Visual Studio Team Services,那么我发现Nuget.exe和Nuget.targets都需要存在,这似乎与通过Google搜索此主题找到的所有建议相反。
添加它们使我的Visual Studio Team Services构建工作。
答案 1 :(得分:2)
在尝试了很多事情后,我发现我使用了错误的默认模板。
我正在使用:
DefaultTemplate.11.1.xaml
我的正确模板是:
TfvcTemplate.12.xaml
当我使用此模板时,构建从nuget恢复并正确完成
答案 2 :(得分:1)
我没有使用Visual Studio Team Services,但NuGet docs声称默认情况下Package Restore应该是构建过程的一部分
适用于Team Foundation Build 2013内部部署和Visual Studio Online (以前称为Team Foundation Service),默认的Build Process 模板已经实现了NuGet Package Restore工作流程 任何特殊配置。以下信息仅适用于 Team Foundation Build 2012及更早版本,或构建流程模板 已经定制并具有NuGet Restore功能 除去。
如果由于某种原因,您的构建过程不包含此步骤(看起来就是这种情况),您可能需要手动添加它。此blog post详细说明了如何将程序包还原与Team Services一起使用。它使用专用的构建文件和前一个链接中描述的过程。