I am really going nuts here with nuget and building a solution under Visual Studio Team Services (visualstudio.com). Any help will be much appreciated.
I have a solution containing 36 projects. Many projects use the same 5 or 6 nuget packages. I have carefully followed instructions for Migrating MSBuild-Integrated solutions to use Automatic Package Restore and therefore have a .nuget folder under my solution folder which contains a sole NuGet.Config file and no longer contains Nuget.exe or Nuget.targets files. All projects have had their Nuget.targets lines removed.
I am using Visual Studio 2013 Professional (v12 Update 2) and the solution builds locally without errors or warnings. Even after a Clean and deletion of the packages folder it downloads and builds fine. The packages folder is NOT checked into Visual Studio Team Services.
Examining the build log suggests that:
- nuget did not kick in at the start of the Build in order to check for, download and unpack any unresolved packages (it was doing this before migrating from MSBuild-Integrated to Automatic Package Restore - however despite that, it wasn't able to resolve references)
- I am left with 113 errors, centred around the fact that projects were unable to resolve references.
- Unlike a local build (and MSBuild-Integrated), Visual Studio Team Services now doesn't even mention nuget in its build log!!!
An example of the log where things start to fail (although this is obviously because nuget hasn't stepped in):
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}".
Can anyone advise how I should get Visual Studio Team Services to use nuget?
How is Visual Studio Team Services even suposed to use NuGet if Automatic Package Restore suggests dropping ~/.nuget/NuGet.exe
?
Thanks in advance, Chris
If you are building on Visual Studio Team Services then I have found that both Nuget.exe and Nuget.targets need to be present, which seems to be contrary to all the advice you can find by googling this subject.
Adding them in got my Visual Studio Team Services builds working.
I have not used Visual Studio Team Services, but the NuGet docs claim that Package Restore should be part of the build process by default
If for some reason your build process does not include this step (as appears to be the case) you may need to add it manually. This blog post details how to use package restore with Team Services. It uses a dedicated build file and the process described in the previous link.
After trying many things I found that I was using the wrong default template.
I was using:
The Correct template for me was:
When I used this template the build restored from nuget and completed correctly