visual-studiomsbuild

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


I'm trying to upgrade our buildserver (jenkins) from Visual Studio 2015 to 2017. We're building via MS-Build. I've downloaded and installed MS-Buld tools as described in this answer. If I compile my projects I get an error that Microsoft.WebApplication.targets was 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 find 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 can be seen the file exists for old compiler versions, but for v15.0 it is missing.

I also have installed Visual Studio 2017 on the build-server. The project succeeds to build if I compile with Visual Studio 2017.

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

Thx


Solution

  • Looks like you are missing the workload for "Web development build tools": Microsoft.VisualStudio.Workload.WebBuildTools.

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

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

    or opening vs_buildtools.exe and selecting the "Web development build tools" component in the GUI:

    screenshot from GUI