Microsoft.DotNet.Web.targets was not found

Microsoft.DotNet.Web.targets was not found

This short post covers how to resolve the Microsoft.DotNet.Web.targets was not found issue. This problem might happen when importing existing asp.net MVC projects within your Visual Studio solution.

Microsoft.DotNet.Web.targets file missing

I’m currently porting some ASP.NET MVC project to .Net Core and running into a quite annoying issue. Every time I’m importing an existing project.json project file (asp.net MVC based project), I’m running into the following error:

The imported project “C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\ Microsoft.DotNet.Web.targets” was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

dotnetcore-error

And as the error message suggests, the file Microsoft.DotNet.Web.targets was indeed missing from the directory C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\

I’m not sure why this is happening. However, I think that this is related to the fact that I’ve installed different beta and pre-release versions of the .net core framework. Resolving the issue is simple;

How to solve the issue

  • CD into or open the location C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet.Web
  • Locate the file called Microsoft.DotNet.Web.targets

Note: In case the file is missing, you can download a copy here. Rename to Microsoft.DotNet.Web.targets

  • Copy this file to C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0 make sure you are an administrator, or the operation will fail too complete.
  • At this point, you will need to delete the previously generated your_project_name.xproj file. This file is located in the same folder as the project.json file.
  • Now you should be able to add the project without any problems.

Side notes

I ran into numerous issues when trying to port existing code. Therefore it’s important to make sure that the correct .Net Core version and matching tooling are installed. The .NET Core Downloads https://www.microsoft.com/net/download#core page lists the binaries for every platform.

Note: .NET Core 1.0 runtime has been released officially as version 1.0. The tooling around .NET Core remains in a Preview state.

You can find more information about the framework and tooling versions in this article on hansleman.com.

Post Navigation