Build ASP.NET 4.5 without Visual Studio on Build Server
Asked Answered
S

6

82

Its been a while since I setup a Build Server so maybe I've forgotten something or maybe .NET 4.5 is different from whatever version I did this with last time, but here is my problem.

I'm trying to setup a build server to monitor a source control repository. Whenever something changes, I want the server to pull the changes and build the project. If there are no errors, I want to deploy the site to a web site running on the build server.

In the past when I did this, I thought that I was able to do this having only .NET installed, but when I try to build this project I get an error that "C:\Program Files\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets" is missing, and if I go and look I can see that it is missing. In fact there are no Visual Studio 11 targets files.

After a lot of thought and head scratching, I went out and got the "Windows 8/.NET 4.5 SDK" thinking that the .NET 4.5 SDK might install the targets files that I needed, but it did not unless I installed it wrong somehow.

So, what do I need to put on the Build Server in order to get the project to build. I would prefer not to have to install the full Visual Studio 2012.

Sforza answered 17/10, 2012 at 22:39 Comment(6)
I've been doing some research since I posted this. Let me know if I'm going down the wrong track. It looks like this was a problem with Visual Studio 2010 as well and it looks like people solved this a few ways. One was to install Visual Studio Team Explorer. I tried that but my server is Win 2008 r1 and VSTE2012 isn't compatible. The other solution which is a little scary is to copy the target files from another machine. that got me further, but now I'm getting errors that my reference assemblies are missing which I'm guessing is related to the original problem. Is there another way?Sforza
You're on the right track, the easy way to slolve the problem is to install VS 2010 on your build server. That is a bit of a blunt instrument though. The second way would be to do what you're doing and get the targets and associated dependancies from another machine and deploy just those files to the server. The danger with this approach is that a VS service pack may change the files you have copied and your build server will be using a stale version of those targets whilst your developers are using the updated versions.Bethannbethanne
Do you mean VS2012? Yeah. I'll check, but I'm assuming that it's not comparable with win server 2008 r1 since team explorer 2012 wasn't, but ill double check.Sforza
Sorry I missed the 2012 bit, I guess it will only install on server 2008 r2 as it only works with win 7 on the client side of things. I assume that updating the os on the build server is out of the question?Bethannbethanne
yeah, I've been thinking about updating the server os. I'm going to look into it, but I'm not sure if I'm going to be allowed to.Sforza
looks like we are going to upgrade the serverSforza
S
35

My problem was related to installing the Windows Software Development Kit (SDK) for Windows 8 on a Windows 2008 Box. If you read further on the page, you will get to a heading labeled ".NET Framework 4.5 SDK Tools on Windows Vista and Windows Server 2008." This tells you to:

  1. Run the Windows SDK for Windows 8 installer on a supported operating system (for example, Windows 7, or Windows 8).
  2. Choose the following option on the Specify Location screen: Download the Windows SDK for installation on a separate computer.
  3. Press the Next button.
  4. Answer the questions on the Join the Customer Experience Improvement Program (CEIP) screen.
  5. On the next screen, choose the .NET Framework 4.5 Software Development Kit feature. Unselect all other features that can be unselected.
  6. Choose the Download button.
  7. Go to the download location (specified in step 2) and find the following .NET Framework 4.5 SDK tool installer files: sdk_tools4.msi, sdk_tools4.cab
  8. You can copy these files to a Windows Vista or Windows 2008 Server computer within your organization. These files need to be copied to same directory on the Windows Vista or Windows 2008 Server computer. Note: Do not redistribute these files outside your organization or as part of any other installer.
  9. On the Windows Vista or Windows 2008 Server computer, review the license terms here .
  10. Check whether .NET Framework 4.5 is already installed on the computer. Otherwise, download and install .NET Framework 4.5 from www.microsoft.com .
  11. Open a command prompt with administrator privileges.
  12. Go to the directory where .NET Framework 4.5 SDK Tools installer files were copied.
  13. Install .NET Framework 4.5 SDK tools by using the command line: Msiexec /i sdk_tools4.msi VSEXTUI=1
Stopcock answered 23/10, 2012 at 15:56 Comment(4)
Thanks Swampy. I'm going to mark this answer as correct, but I just wanted to mention a couple of things. I'm not going to test this out, but your answer does look like it might work. Instead we are just upgrading the server. Second, do you know if doing it this way would have allowed the components to be updated when patches and service packs are released?Sforza
I have followed these instructions with Server 2008 but unfortunately I'm still seeing .nlp files and mscorlib is being included in deployments using web deployCallimachus
Thank you very much. I'm using Jenkins and I've just update my project to use .NET 4.5. When I push my work to Jenkins it didn't complain about wrong version, it complain about missing System.Runtime assembly. I prefer this solution over manual copy of files because this solution is easier to automate.Coeternity
I use Windows Server 2012, and I have VS2012 in Windows 8 (Development Machine). Only I require targets for MsBuild "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\. SDK includes much more, isn't ?Amoy
P
84

To run on on your CI server without Visual Studio, you only need to copy a few folders from a development machine to the same location on the CI server. There is no need to install the SDK.

VS 2015:

  • C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web
  • C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications

VS 2013:

  • C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web
  • C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\WebApplications

VS 2012:

  • C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web
  • C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications

VS 2010:

  • C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web
  • C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications

.NET 4.6:

  • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6

.NET 4.5.2:

  • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2

.NET 4.5.1:

  • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1

.NET 4.5:

  • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5

.NET 4.0.1:

  • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0.1

.NET 4.0:

  • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0

Or, as Matt suggested, you could copy them into a subdirectory of your project and alter the <MSBuildExtensionsPath32> location in your MSBuild (typically .csproj or .vbproj) file.

Once you have done this, your project will compile.

You should also set the VisualStudioVersion environment variable explicitly to the Visual Studio version (10.0 for VS2010, 11.0 for VS2012, 12.0 for VS2013, 14.0 for VS2015) you are using just to be sure it is set right in your configuration.

Pedagogics answered 15/10, 2013 at 15:55 Comment(5)
this solved the problem for us +1. Coming from maven/java this is nuts.Sessler
Reference Assemblies not installed with .NET Framework ? MSBuild targets not. I'm not sure Reference Assemblies, I think that yes.Amoy
Copying C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0 from developer machine to same folder on the build machine did the trick for me after Team City could not compile .NET 4.5 solution, however a .NET 4.0 solution earlier did compile.Platitudinize
+1 for the reference assemblies. I'm building a 4.5.1 project using Teamcity and MSBuild14 and that was the missing link on my build agent machine.Visconti
this is a stupid problem to have, but a simple solution to it.Odelet
S
35

My problem was related to installing the Windows Software Development Kit (SDK) for Windows 8 on a Windows 2008 Box. If you read further on the page, you will get to a heading labeled ".NET Framework 4.5 SDK Tools on Windows Vista and Windows Server 2008." This tells you to:

  1. Run the Windows SDK for Windows 8 installer on a supported operating system (for example, Windows 7, or Windows 8).
  2. Choose the following option on the Specify Location screen: Download the Windows SDK for installation on a separate computer.
  3. Press the Next button.
  4. Answer the questions on the Join the Customer Experience Improvement Program (CEIP) screen.
  5. On the next screen, choose the .NET Framework 4.5 Software Development Kit feature. Unselect all other features that can be unselected.
  6. Choose the Download button.
  7. Go to the download location (specified in step 2) and find the following .NET Framework 4.5 SDK tool installer files: sdk_tools4.msi, sdk_tools4.cab
  8. You can copy these files to a Windows Vista or Windows 2008 Server computer within your organization. These files need to be copied to same directory on the Windows Vista or Windows 2008 Server computer. Note: Do not redistribute these files outside your organization or as part of any other installer.
  9. On the Windows Vista or Windows 2008 Server computer, review the license terms here .
  10. Check whether .NET Framework 4.5 is already installed on the computer. Otherwise, download and install .NET Framework 4.5 from www.microsoft.com .
  11. Open a command prompt with administrator privileges.
  12. Go to the directory where .NET Framework 4.5 SDK Tools installer files were copied.
  13. Install .NET Framework 4.5 SDK tools by using the command line: Msiexec /i sdk_tools4.msi VSEXTUI=1
Stopcock answered 23/10, 2012 at 15:56 Comment(4)
Thanks Swampy. I'm going to mark this answer as correct, but I just wanted to mention a couple of things. I'm not going to test this out, but your answer does look like it might work. Instead we are just upgrading the server. Second, do you know if doing it this way would have allowed the components to be updated when patches and service packs are released?Sforza
I have followed these instructions with Server 2008 but unfortunately I'm still seeing .nlp files and mscorlib is being included in deployments using web deployCallimachus
Thank you very much. I'm using Jenkins and I've just update my project to use .NET 4.5. When I push my work to Jenkins it didn't complain about wrong version, it complain about missing System.Runtime assembly. I prefer this solution over manual copy of files because this solution is easier to automate.Coeternity
I use Windows Server 2012, and I have VS2012 in Windows 8 (Development Machine). Only I require targets for MsBuild "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\. SDK includes much more, isn't ?Amoy
B
25

From msdn:

The Windows SDK no longer ships with a complete command-line build environment. You must install a compiler and build environment separately. If you require a complete development environment that includes compilers and a build environment, you can download Visual Studio 2012 Express, which includes the appropriate components of the Windows SDK.

In order to fix this, I had to copy the folder C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5 from my development machine (which has Visual Studio 2012 by the way) onto the build agents. After this operation, Team City did not report any more errors and mscorlib.dll was not output to the bin folder.

Brain answered 27/2, 2013 at 11:5 Comment(6)
thanks, this fixed it for me, without the need to download the sdk. (or any of the steps in the accepted answer)Fowlkes
This should definitely be the accepted answer. Much easier since you definitely already have a machine with the ref assemblies.Sapient
@Stanfield VS 2012 and the Win 8 SDK both do not install on Win2k8 R1. If you're on R1 as I was, you have to copy the ref assemblies.Sapient
@JoshKodroff forgot to mention, we have server 2012 build agents, thanks for clarifyingStanfield
But there's no copy of msbuild.exe in this directory. I installed VS2012 on my dev PC (not the build machine), and I still don't see a 4.5 version.Handhold
+1, I'm using Jenkins and this solution worked fine on Windows 2008 R2.Marco
C
12

Microsoft Build Tools 2013 will help in this case, as its download page describes:

If you don't have Visual Studio installed on your computer, you can use Build Tools 2013 to build managed applications. The Visual Basic and C# compilers are also included in this download. (In earlier versions, these tools were included in the stand-alone .NET Framework.)

Cleliaclellan answered 16/6, 2014 at 10:53 Comment(2)
A little more explanation might help out the fellow programmers to understand how the reference link works.As in future the reference link might not exist anymore.Wurth
Microsoft Build Tools 2013 for VS 2013 and too VS 2012 ? Anyways, better install Microsoft Build Tools or Visual Studio Agents 2012 https://mcmap.net/q/257520/-build-asp-net-4-5-without-visual-studio-on-build-server ?Amoy
P
8

My dept. likes taking a minimalistic approach to what's installed on our Win 7 build machines. However, we don't like just copying and pasting files/folders because of potential registry key issues. Instead of installing VS 2013, I installed the following much smaller and free components. Now the dev team can build VS 2013 web apps successfully.

Prospector answered 24/3, 2015 at 18:14 Comment(1)
Thank you so much. I've always wondered how to get Microsoft.WebApplication.targets and I never knew about that Isolated Shell!Kelsi
D
6

I solve this problem with Visual Studio Agents.

You can try install Visual Studio Agents 2012.

http://www.microsoft.com/en-us/download/details.aspx?id=38186

Downpipe answered 4/12, 2013 at 10:47 Comment(6)
Doesn't work for VS2013. I installed Agent and Controller but C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0 wasn't createdReeder
Agents for Visual Studio 2013 are also available of course - for those reading this answer with VS 2013 rather than VS 2012 in mind.Ikeda
It indeed works! You just need to install Visual Studio 2013 Shell (Isolated) (x86) And than Visual Studio 2013 Shell (Integrated) (x86)Parrot
@Andrii Visual Studio Agents 2012 requires installed ? or only Visual Studio 2012 & 2013 Shell (Isolated) (x86) and Visual Studio 2012 & 2013 Shell (Integrated) (x86) without install VS Agents?Amoy
Only shells. I installed 2013 onlyParrot
This did not work for me. I see only two files and I installed both. v11.0 does not get added. Copying the files over manually from a devbox did work (as mentioned in popular answer).Threemaster

© 2022 - 2024 — McMap. All rights reserved.