Keywords: MS-Build | Visual Studio 2017 | Microsoft.WebApplication.targets | Web development build tools
Abstract: This article comprehensively addresses the common error of missing Microsoft.WebApplication.targets during MS-Build compilation after upgrading to Visual Studio 2017. Based on the best answer, it provides a step-by-step solution to install the Web development build tools component, with supplementary methods from other answers for efficient problem resolution.
Problem Background
When upgrading build servers from Visual Studio 2015 to 2017, a frequent issue encountered is the missing Microsoft.WebApplication.targets file during MS-Build compilation. The error typically references the path C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets, leading to build failures that disrupt continuous integration workflows.
Error Analysis
Upon investigation, the root cause is identified as an incomplete installation of MS-Build tools. While users may have installed Visual Studio 2017 Build Tools, the default setup lacks the Web development-specific components, particularly the Microsoft.VisualStudio.Workload.WebBuildTools workload. This omission results in the absence of the Microsoft.WebApplication.targets file in the v15.0 directory, whereas it is present in older versions like v14.0, as shown in file system searches.
Primary Solution
Following the best answer, the recommended approach is to install the missing Web development build tools component. Here are the detailed steps:
- First, ensure the Visual Studio 2017 Build Tools installer is downloaded from official sources or provided links.
- Install via command line: Run
vs_buildtools.exe --add Microsoft.VisualStudio.Workload.WebBuildTools. Alternatively, use the GUI installer to select the "Web development build tools" component. - After installation, restart the build server or refresh environment variables to allow MS-Build to recognize the new components.
This method automatically deploys the Microsoft.WebApplication.targets file to the correct location, resolving the compilation error. It is the most advised solution due to its adherence to official installation procedures, ensuring proper configuration of dependencies and files.
Supplementary Solutions
In some scenarios, users may need quick fixes or encounter installation hurdles. Referring to other answers, alternative methods include:
- Copying the
WebApplicationsfolder: Copy fromC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications(if available) toC:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0. - Creating symbolic links: Use command-line tools like mklink to create a link from the v15.0 directory to the v14.0 directory, though this may not be universally applicable.
These alternatives can provide temporary relief but are less stable than official installation and may fail with future updates, so they should be used only in emergencies.
Conclusion
To ensure long-term stability and compatibility of build servers, it is highly recommended to adopt the official method of installing the Web development build tools component. This not only fixes the immediate Microsoft.WebApplication.targets missing error but also prevents potential issues from file path inconsistencies. By following standardized installation processes, users can streamline maintenance and enhance build efficiency.