2
votes

I have an solution with one project. Able to build it via VS GUI. I want to build it via command prompt. But getting errors:

Command used:

"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe" "C:\Users\xxx\Desktop\WebApplication1\WebApplication1.sln" /t:build

error:

error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

How to resolve this. Please suggest.

2
@CodingYoshi : which one is the answer. There is no answer found in the link which u gave.ChandraSekhar.K

2 Answers

0
votes

This can happen when Visual Studio is not installed on the machine on which you're attempting to build the project (e.g. a build agent).

Verify VS is installed, or if this isn't an option you could run the following command in the package manager console:

Install-Package MSBuild.Microsoft.VisualStudio.Web.targets

This package will update the .csproj file of your project to use the VS version of the targets if they exist, otherwise a local version contained in the packages folder.

1
votes

The path of MSBuild should be "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" instead of "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe".

As per Visual Studio Blog: MSBuild is now part of Visual Studio!

Starting with Visual Studio 2013, the 2013 version of MSBuild will ship as a part of Visual Studio instead of the .NET Framework. This transition allows us to more rapidly evolve MSBuild.

So when you build project via command prompt in Visual Studio 2015, the path of MSBuild should be "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe".

Hope this can help you.