7

I have a problem when I check in my server to my build server (using TFS), but for some reason, return me the next error:

Exception Message: MSBuild error 1 has ended this build. You can find more specific information about the cause of this error in above messages. (type BuildProcessTerminateException)
Exception Stack Trace:    at System.Activities.Statements.Throw.Execute(CodeActivityContext context)
   at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
   at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

Adn as detail:

\WcfService4.csproj (92): The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

I'm not sure what is the problem or what I can solve it. Someone can help me?

Benjamin RD
  • 11,516
  • 14
  • 87
  • 157
  • [Did you install Windows 8 SDK?](http://stackoverflow.com/q/12944502/147211) – KMoraz Jul 30 '14 at 22:08
  • @KMoraz I'm using a windows 7 (in my build server) and .Net famework 4.5. Works? But the documentation that you sent me is Windows 8 and framwork 4.5 – Benjamin RD Jul 30 '14 at 22:23
  • @KMoraz You can use the SDK to build applications that target these operating systems: Windows 8, Windows 7, Windows Vista, Windows Server 2012, Windows Server 2008 R2, Windows Server 2008. I'll try it, thanks – Benjamin RD Jul 30 '14 at 22:25

3 Answers3

20

Your reference to

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets"

This works if the build is done on a machine that has Visual studio installed on it. If you change the reference to use nuget instead- https://www.nuget.org/packages/MSBuild.Microsoft.VisualStudio.Web.targets/ this package is the equivalent one to your local file. In your csproj.

 <Import Project="$(MSBuildBinPath)\Microsoft.WebApplication.targets" />

to (for example)

<Import Project="$(Yourpackageslocation)\MSBuild.Microsoft.VisualStudio.Web.targets\Microsoft.WebApplication.targets" />

You'll need to edit your csproj to point to the Nuget packages file.

James Woolfenden
  • 6,498
  • 33
  • 53
  • Hi, I tried this solution and it works fine at first, however Visual Studio keeps adding an extra line to the csproj file: this happens when opening the project with different versions of Visual Studio. Has anyone had this issue? – Techromancer Sep 10 '20 at 10:15
1

Your application is build on using MSBuild. MSBuild depends on target files that describe how certain application types need to be build.

In this case you are building a web application and your project file contains a link to the Microsoft.WebApplication.targets file. This file is installed on your local pc by installing Visual Studio but it's not available on your build server.

You have two options:

  • Copy the target file from your local pc to the build server in the correct location
  • Install Visual Studio on your build machine

To be honest, the second option is the easiest. You will probably need to copy a lot of files if you want to manually setup your build server. Installing Visual Studio takes care of all dependencies.

Wouter de Kort
  • 39,090
  • 12
  • 84
  • 103
  • 3
    The second is easier. But I do the harder one. (and manually copy the files over). Microsoft drives me nuts with this. The build-machine should not need Visual Studio. Msbuild.exe and an SDK should be enough, but they don't seem interested in plugging the gaps. – granadaCoder Jul 31 '14 at 15:28
  • 1
    @granadaCoder The official licensing whitepaper allows you to install VS on the build machine. I see no reason for not doing it. – Wouter de Kort Feb 19 '15 at 10:02
  • 2
    All that's needed is the nuget package in your project, this also associates the reference with the code. You shouldn't install more than is required on a build machine. – James Woolfenden Feb 26 '15 at 07:25
0

Either install visual studio on your build machine or copy the targets file from your local machine to the build server

Just TFS
  • 4,697
  • 1
  • 18
  • 22