Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft.WebApplication.targets was not found, on the build server. What's your solution?

Trying to build my project on the build server gives me the following error:

Microsoft (R) Build Engine Version 4.0.30319.1 error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamData\Microsoft.Data.Schema.SqlTasks.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.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. error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.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 solved this problem a few months ago, with installing Visual Studio 2010 on the Build Server. But now I'm setup a new server from scratch, and I want to know if there any better solution to solve this issue.

like image 308
stacker Avatar asked Oct 20 '10 18:10

stacker


People also ask

Where can I find Microsoft WebApplication targets?

"C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\sdk\5.0. 406\Microsoft\VisualStudio\v15. 0\WebApplications\Microsoft. WebApplication.

What is Microsoft WebApplication targets used for?

Essentially, this target takes the build output of your web application project and turns it into a web deployment package that can be published to an IIS web server. To view a project file (for example, ContactManager. Mvc. csproj) in Visual Studio 2010, you first need to unload the project from your solution.


2 Answers

To answer the title of the question (but not the question about the output you're getting):

Copying the following folder from your dev machine to your build server fixes this if it's just web applications

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

Remove x86 according to how your build breaks. If you have other project types you will probably need to copy the entire msbuild folder.

like image 120
Chris S Avatar answered Sep 29 '22 11:09

Chris S


The solution would be to install redistributable packages on build server agent. It can be accomplished multiple ways, out of which 3 are described below. Pick one that suits you best.

Use installer with UI

this is the original answer

Right now, in 2017, you can install WebApplication redists with MSBuildTools. Just go to this page that will download MSBuild 2017 Tools and while installation click Web development build tools to get these targets installed as well: enter image description here

This will lead to installing missing libraries in C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications by default

Use command line

disclaimer I haven't tested any of the following proposals

As @PaulHicks and @WaiHaLee suggested in comments, it can also be installed in headless mode (no ui) from CLI, that might actually be preferable way of solving the problem on remove server.

  • Solution A - using package manager (choco)
choco install visualstudio2017-workload-webbuildtools 
  • Solution B - run installer in headless mode

    Notice, this is the same installer that has been proposed to be used in original answer

vs_BuildTools.exe --add Microsoft.VisualStudio.Workload.WebBuildTools --passive 
like image 43
SOReader Avatar answered Sep 29 '22 11:09

SOReader