0

ASP.NET 4.5 MVC application

Builds/runs just fine locally

Packages folder NOT checked into source control

Source control looks like this:

MyProject
  -.nuget
  -.tfignore
  -MyProject.Web
  -MyProject.Utilities
  -MyProject
  -MyProject.sln

Inside of the .nuget folder, there is only one file: NuGet.config, which has this inside:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <solution>
        <add key="disableSourceControlIntegration" value="true" />
    </solution>
</configuration>

I can delete the packages folder locally, run it, and it correctly downloads everything again.

When I kick off a build from Visual Studio which should build the solution and deploy it to Azure Cloud Service, the build fails saying:

The type or namespace name 'WindowsAzure' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
Scott Decker
  • 4,229
  • 7
  • 24
  • 39

1 Answers1

0

The "new" way to do this is to run

nuget.exe restore "MySolution.sln"

I put my (versioned) nuget.exe files on my build server like this:

c:\MyProgFiles\NuGet\2.8.6\nuget.exe
c:\MyProgFiles\NuGet\3.3.0\nuget.exe

Then before I build, I call

"c:\MyProgFiles\NuGet\2.8.6\nuget.exe" restore "c:\MyFullPath\MySolution.sln"

You can also read this about "how to clean up old nuget stuff"

http://docs.nuget.org/consume/package-restore/migrating-to-automatic-package-restore

(using CI macros when possible to create the file names)

I also put these lines before the "nuget restore" to help with debugging.

"c:\MyProgFiles\NuGet\2.8.6\nuget.exe" sources list

"c:\MyProgFiles\NuGet\2.8.6\nuget.exe" locals all -list

BTW: If you have a package source where the packages might get deleted, then add this to your build scripts (before the "restore" mentioned above)

"c:\MyProgFiles\NuGet\2.8.6\nuget.exe" locals all -clear

This will clear your local cache and force a fresh download.

Again, the value here is ONLY if you use a source where packages get deleted.

granadaCoder
  • 26,328
  • 10
  • 113
  • 146
  • So you're not defining a build definition in VS and then kicking that off. Rather you're doing it all through command line it looks like? – Scott Decker Jul 12 '16 at 15:23
  • Ideally, visual studio is NOT installed on the build server. Only framework and SDK. The "plugin's" that are available for jenkins...are usually just "somebody packaged up the command line calls for you". You set properties on the plug-in in your build definitions, and the writer of the plug-in is just encapsulating the command line calls for you. – granadaCoder Jul 12 '16 at 15:44
  • Your title says "on MSBuild Server".. So I'm assuming this is a machine (not your dev box) that does the build. thus adding the step of "nuget restore" would be prudent on the "MSBuild Server". That's why I'm trying to get across. – granadaCoder Jul 12 '16 at 16:02
  • You can add EXEC steps in the build definition. Also see : http://stackoverflow.com/questions/31384189/how-to-get-tfs2015-build-build-vnext-and-nuget-package-restore-to-use-custom-p (the "11" answer) – granadaCoder Jul 12 '16 at 21:32