Question

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?

Was it helpful?

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.

OTHER TIPS

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.

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!

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.

This can also occur when opening an older project in Windows 10

I had the same problem (SqlServer.targets was not found) when opening an old SQL Server CLR assembly in Visual Studio 2010 on Windows 10, the same version used originally to write the assembly.

Confirmed the same project opened perfectly fine in Visual Studio 2010 on a Windows 7 computer.

Solution

Pay attention to the error message. In my case it was:

The imported project “C:\Windows\Microsoft.NET\Framework\v4.0.30319\SqlServer.targets” was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

Simply copy SqlServer.targets from the location indicated in Vladimir Dronov's answer, "C:\Windows\Microsoft.NET\Framework\v3.5\SqlServer.targets", to the directory indicated in the error message.

In my case that was "C:\Windows\Microsoft.NET\Framework\v4.0.30319\".

The Error Resulting from Several of these Solutions

I posted a specific question (C# VS 2013 Error 02019: Invalid target type for /target: must specify 'exe', 'winexe', 'library', 'module', 'appcontainerexe' or 'winmdobj' CSC) regarding the fatal build error described by Chris Torng below Vladimir Dronov's answer:

Error 1 02019: Invalid target type for /target: must specify 'exe', 'winexe', 'library', 'module', 'appcontainerexe' or 'winmdobj' CSC


The Fix

I was able to get rid of the error related to SQL Server dev tool compatibility issues in VS2013 Community Edition by following the advice in this forum:

https://connect.microsoft.com/SQLServer/feedbackdetail/view/979839

Posted by bsclifton on 11/15/2014 at 7:18 AM

Had this issue too with the Community 2013 edition; Going to Tools->Extensions and Updates and updating "Microsoft SQL Server Update for database tooling" resolved the issue :)

If this doesn't work for you, I'd recommend checking out that forum as it offers up several other ideas for how to fix the problem

Solution 1:

If the project is a .csproj file, you should check if Visual Studio also generated a .sqlproj file while upgrading. If that is the case, you can add that to the solution instead.

Solution 2:

You can try to change the following line in the .sqlproj file:

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

to

<Import Project="$(MSBuildBinPath)\SqlServer.targets" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top