Windows – What do I need to setup a Jenkins build server that can build ASP.NET projects without Visual Studio

asp.netJenkinsmsbuildwindows

I'm trying to setup a build server using Jenkins (on Windows Server 2012) that will be responsible for building (with config transform) and packaging (zip file) ASP.NET MVC/Web API projects, then moving them to designated location (C:/Published).

Basically, I need the Visual Studio Web Publish for File System via command line without having to install Visual Studio. The zipping process can be deferred to the command line via Jenkins.

From searching, the following steps is what I've done so far:

  1. Installed Jenkins
  2. Installed Jenkins MSBuild plugin
  3. Copied 'C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets' to my build server
  4. Installed Windows 8 SDK
  5. Created Jenkins job that pulls source code from repo
  6. Added command line arguments to MSBuild task….

Step 6 is what's stumping me. I've tried numerous suggestions online, but can't figure out how to get the full effect of Visual Studio's publish command.

One suggestion was to use a publish profile properties as parameters:

/p:WebPublishMethod=FileSystem
/p:LastUsedBuildConfiguration=Release
/p:LastUsedPlatform=AnyCPU
/p:ExcludeApp_Data=False
/p:publishUrl=C:\Published\
/p:DeleteExistingFiles=True

But that dosen't move any files over to c:\Published\.

Best Answer

I needed to copy the files in C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web from my dev box to the same location on the build server, then the properties worked fine.

In addition to the steps I outlined above, below are the extra steps I had to do to get this working:

  1. Changed Jenkins Windows service to logon as Administrator
  2. Copy the files in C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web from my dev machine to the same location on the build server
  3. Enabled NuGet package restore by running [Environment]::SetEnvironmentVariable("EnableNuGetPackageRestore", "true.", "Machine") in Powershell