Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 413
Chris Avatar asked Nov 15 '13 16:11

Chris


3 Answers

Just copied SqlServer.targets from C:\Windows\Microsoft.NET\Framework\v3.5 to C:\Program Files (x86)\MSBuild\12.0\Bin and it helps. VS2013 is now able to open the old project.

like image 69
Vladimir Dronov Avatar answered Nov 02 '22 05:11

Vladimir Dronov


I had a similar problem when upgrading from Visual Studio 2008 to 2013. It took awhile but I had to install the SSDT for VS 2013 (again), then I created a new database project to find out the relative path to the new sqlserver.targets file. It should be as follows:

  <Import Condition="'$(SQLDBExtensionsRefPath)' != ''" Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.SqlTasks.targets" />
  <Import Condition="'$(SQLDBExtensionsRefPath)' == ''" Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" />

The biggest hindrance that I found to fixing this error was trying to understand the error message provided (BC2014: the value 'database' is invalid for option 'target')

Hope this helps!

like image 5
Rolan Avatar answered Nov 02 '22 05:11

Rolan


I had the same problem and I solved this way: Just create a file named 'SQLServer.targets' on 'C:\Windows\Microsoft.NET\Framework\v4.0.30319' with the following content:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <PropertyGroup>
           <SqlClrTargetsFullPath>$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\TeamData\Microsoft.Data.Schema.SqlClr.targets</SqlClrTargetsFullPath>
    </PropertyGroup>

    <Import Project="$(SqlClrTargetsFullPath)" Condition="Exists('$(SqlClrTargetsFullPath)')"/>
</Project>

Good luck.

like image 2
Stephen Knupfer Avatar answered Nov 02 '22 05:11

Stephen Knupfer