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
"C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\sdk\5.0. 406\Microsoft\VisualStudio\v15. 0\WebApplications\Microsoft. WebApplication.
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.
With Visual Studio 2019 and later, it's installed under the Visual Studio installation folder. For a typical default installation on Windows 10, MSBuild.exe is under the installation folder in MSBuild\Current\Bin.
Overview. MSBuild is a build tool that helps automate the process of creating a software product, including compiling the source code, packaging, testing, deployment and creating documentations. With MSBuild, it is possible to build Visual Studio projects and solutions without the Visual Studio IDE installed.
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:
The accepted answer above is technically correct just incomplete, a bit confusing, at least for me, and needed one extra step to get Visual Build Professional working.
vs_buildtools.exe does not technically exist. I had to create a question asking where that file was. It was not obvious that vs_buildtools.exe is vs_buildtools_*******.exe and is the actual installation program. Additionally the the "-add ***" mentioned above is just a shorthand. One can go to the GUI and check both workflow tasks. That does the same thing. I wound up having the vs_buildtools file, though not needing it.
VSB Pro still did not build my project. I got thrown the same error above. The secret sauce was simply to copy the WebApplications
folder in C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0
to C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0
. I then rebuilt the project and all was fine. I placed the WebApplication.targets file at the expected location.
Why Microsoft could not have done that is beyond me. Also, why the separate installation. VS17 installs an enormous amount of stuff. Build Tools is implied, like always. Whatever.
I am posting this answer as hopefully it will help others. I fell into the trap and lost quite a bit of time with my project not building. I hope that this answer clarifies things a bit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With