MS-Build 2017 "Microsoft.WebApplication.targets" is missing

I am trying to upgrade our buildserver (jenkins) from Visual Studio 2015 to 2017. We are building through MS-Build. I downloaded and installed MS-Buld tools as described in this. If I compile my projects, I get an error that Microsoft.WebApplication.targets not found.

Detailed error:

  error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" 

I performed a search in the MS-Build directory:

 PS C:\Program Files (x86)\MSBuild> dir -Recurse -Filter "Microsoft.WebApplication.targets" Directory: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 11.01.2012 00:23 19654 Microsoft.WebApplication.targets Directory: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\WebApplications Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 22.07.2013 01:25 19995 Microsoft.WebApplication.targets Directory: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 06.07.2015 21:55 20118 Microsoft.WebApplication.targets Directory: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\WebApplications Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 22.07.2013 01:25 19995 Microsoft.WebApplication.targets 

As you can see, the file exists for older versions of the compiler, but for v15.0 it is missing.

I also installed Visual Studio 2017 on the build-server. The project will be created if I compile Visual Studio 2017.

Any tips on how to solve this? One possible solution is to create a symbolic link from C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications to old files v14.0 (located under C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications ).

thanks

+63
source share
6 answers

It looks like you are missing the workload for the "web development build tools": Microsoft.VisualStudio.Workload.WebBuildTools .

You can install it by downloading the build tools installer from the page here (VS2017) or here (VS2019), then running

 vs_buildtools.exe --add Microsoft.VisualStudio.Workload.WebBuildTools 

or open vs_buildtools.exe and select the Web Development Build Tools component in the GUI:

screenshot from GUI

+88
source

The accepted answer above is technically correct, just incomplete, a little confusing, at least for me, and one additional step is required for Visual Build Professional to work.

  • vs_buildtools.exe technically does not exist. I had to create a question about where this file is located. It was not obvious that vs_buildtools.exe is vs_buildtools _ *******. Exe is a real installer. In addition, the above -add *** is just a shorthand. You can go to the GUI and check both tasks of the workflow. It does the same. I ran the vs_buildtools file, although this is not necessary.

  • VSB Pro has not yet built my project. I got the same error above. The secret sauce was simply to copy the WebApplications folder to C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0 to C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0 . Then I rebuilt the project, and everything was in order. I put the WebApplication.targets file in the expected location.

Why Microsoft couldn’t do this is beyond me. In addition, why a separate installation. VS17 sets up a huge amount of material. Build Tools is implied, as always. Whatever.

I am posting this answer, hope this helps others. I fell into a trap and lost a lot of time when the project was not built. I hope this answer clarifies things a bit.

+70
source

I had a similar problem after upgrading from Visual Studio 2015 to 2017. When I try to download a web application project, it gives me an error message:

The imported project "C: \ Program Files (x86) \ Microsoft Visual Studio \ 2017 \ Enterprise \ MSBuild \ Microsoft \ VisualStudio \ v14.0 \ WebApplications \ Microsoft.WebApplication.targets" was not found. Also tried to find "WebApplications \ Microsoft.WebApplication.targets" in the backup search paths for $ (VSToolsPath) - "C: \ Program Files (x86) \ MSBuild \ Microsoft \ VisualStudio \ v15.0". These search paths are defined in "C: \ Users \ xxx \ AppData \ Local \ Microsoft \ VisualStudio \ 15.0_558e146f \ devenv.exe.config". Make sure that the path in the declaration is correct and that the file exists on disk in one of the search paths.

I found a solution to this error here .

In my case, the .csproj file contained the following lines:

 <PropertyGroup> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v14.0</VSToolsPath> </PropertyGroup> 

After replacing v14.0 with v$(VisualStudioVersion) in the VSToolPath tag VSToolPath project can be loaded.

I also replaced v14.0 from v10.0 in the VisualStudioVersion tag, as a solution in the link above shows. But for me, this also worked, leaving it at 14.0.

Here's how these lines should look at the end:

 <PropertyGroup> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> </PropertyGroup> 

If you do not have these lines in your .csproj, then you must add them manually directly BEFORE this line:

 <Import Project="$(VSToolsPath)\Web\Microsoft.Web.Publishing.targets" Condition="'$(VSToolsPath)' != ''" /> 

In my case (a slightly different error message, but the same problem) was this line:

 <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" /> 

It seems that projects created in versions of Visual Studio since 2011 contain strings with VSToolsPath overrides, but this is not the VSToolsPath in older files. Visual Studio never added them automatically when upgrading to the new version of VS, so you should add them if they are not there.

Source of this information: https://developercommunity.visualstudio.com/content/problem/27735/project-fails-to-load-with-error-regarding-microso.html?childToView=123664#comment-123664 (click on Show more comments to see the entire discussion thread - unfortunately, I can’t directly link to the comments in this "more" section.)

+15
source

It's easy to install the 2017 build tools, with the WebBuildTools option already enabled using chocolate . After installation, enter the following at the administrator’s command prompt:

 choco install visualstudio2017buildtools -y 

For VS 2019, it looks like:

 choco install visualstudio2019buildtools -y 
+10
source

Copy WebApplications folder from

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

to

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

Or in your build script add the following line before compiling

Copy-Item "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications" "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications" -Recurse -Force

Be sure to run it with elevated rights.

+7
source

How to create VS 2017 pro, asp.net MVC application and build it with Jenkins?

use vs 2017 pro on both dev and build computers

Verify that VisualStudio is set to 15
Import Project = "$ (MSBuildExtensionsPath32) \ Microsoft \ VisualStudio \ v15.0 \ WebApplications \ Microsoft.WebApplication.targets" Condition = "false"

install msbuild tool
in C: \ Program Files (x86) \ Microsoft Visual Studio \ 2017 \ Professional \ MSBuild \ 15.0 \ Bin \ MSBuild.exe in the global jenkins configuration manager

Using jenkins, run the windows command:
retore nugets: "C: \ Program Files (x86) \ Jenkins \ tools \ nuget \ NuGet.exe" restore "C: \ Program Files (x86) \ Jenkins \ workspace \ theapp_build \ theapp.sln"

Using jenkins, run the windows command:
MSBuild build file: theapp.sln
Command line arguments: / nologo / t: restore / t: rebuild / p: Configuration = "Debug" / p: VisualStudioVersion = 15.0

+3
source

Source: https://habr.com/ru/post/1270232/


All Articles