Search code examples
sql-servervisual-studiomsbuildvisual-studio-2013

Project fails to load due to missing SqlServer.targets file after upgrading to Visual Studio 2013


Having upgraded to Visual Studio 2013, I have found that an old SQL project fails to load when I attempt to open a solution. The error displayed is:

The imported project "C:\Program Files (x86)\MSBuild\12.0\bin\SqlServer.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. C:\Some\Path\To\Project\Database.sqlproj

In my .sqlproj file I have the line

<Import Project="$(MSBuildToolsPath)\SqlServer.targets" />

which in Visual Studio 2012 resolves to C:\Windows\Microsoft.NET\Framework\v4.0.30319\SqlServer.targets but in Visual Studio 2013 this resolves to C:\Program Files (x86)\MSBuild\12.0\bin\SqlServer.targets. However, the SqlServer.targets file is in neither of these locations.

Presumably this is due to MSBuild becoming part of Visual Studio, rather than it being part of the .Net Framework.

Does anyone know how to fix this issue and to migrate this project to Visual Studio 2013?


Solution

  • I had the same problem when trying to build a VS 2010 solution under VS 2013. The fix was to upgrade the solution file to VS 2013 first. After that it worked without further modifications.