Visual Studio 2013: Database Project MSBuild error

MsbuildVisual Studio-2013Database Project

Msbuild Problem Overview


I've got a database project as part of my solution in Visual Studio 2013. Been working perfectly for the last 3 weeks and now suddenly today it won't build and so I cannot publish any changes. I'm getting an MSBuild error:

> "C:\Program Files > (x86)\MSBuild\Microsoft\VisualStudio\v12.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets(513,5): > Error: MSB4018: The "SqlBuildTask" task failed unexpectedly. > System.MethodAccessException: Attempt by method 'Microsoft.Data.Tools.Schema.Sql.Build.SqlTaskHost.OnCreateCustomSchemaData(System.String, > System.Collections.Generic.Dictionary`2)' > to access method > 'Microsoft.Data.Tools.Components.Diagnostics.SqlTracer.ShouldTrace(System.Diagnostics.TraceEventType)' > failed."

Anyone got any ideas? All I did this morning was pull down the latest changes from source control. I can't see how that would mess up the actual MSBuild process, and the guy who checked in last doesn't have any issues at all.

Msbuild Solutions


Solution 1 - Msbuild

You need to install the last version of SQL Server Data Tools:

http://msdn.microsoft.com/en-US/data/hh297027

Make sure to restart VS and then build the solution again. This solves the problem!

Solution 2 - Msbuild

In Visual Studio 2013 -> Tools -> Extensions and Updates... -> Updates -> Product Updates -> Microsoft SQL Server Update for database to 12.0.50318.0

I was upgrading from 12.0.41012.0 and this resolved my issue. This relates to the answer to install the latest SQL Server Data Tools.

Solution 3 - Msbuild

I am using Visual Studio Community 2013.

I had same error:

You can fix it by updating the SQL Server Tools:

Tools --> Extensions and Updates

enter image description here

Then under Product Updates you will see an option to update SQL Server Update.

Click on Update, after it has installed restart Visual Studio.

enter image description here

Solution 4 - Msbuild

Solution 5 - Msbuild

I searched "Visual Studio 2013 Update 2" in MSDN subscriber downloads and it was there

Also I filed a bug with MS VS2013 SqlBuildTask 04018 Error Please up vote it if you are getting the same problem

Solution 6 - Msbuild

I had the same issue. I tried to repair Visual Studio 2013, update 4, SSDT, the DAC tools, etc., but it didn't work any better.

However I noticed the Microsoft.Data.Tools.Schema.SqlTasks.targets file present in C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\SSDT was dated from 2013 (In fact it corresponded to the old SSDT). So what I did is just copy the new one (which I suprisingly found in C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\SSDT ...) over to this v12.0\SSDT folder, restarted Visual Studio 2013 and now it works. For information, that new SSDT targets file is dated from 2014/10/26 and its size is 75437 bytes.

Solution 7 - Msbuild

It turns out the issue was with Visual Studio Update 3. I uninstalled and reinstalled VS 2013 to Update 2 only and reinstalled Data Tools and it works perfectly now.

Solution 8 - Msbuild

I already had the newest Version of SQL Data Tools installed, but after installing VS2015 RC it stopped to work. After run a repair on SSDT it compiles again with success.

Solution 9 - Msbuild

I had Visual Studio 2013 Update 5 installed and was having this issue. I followed these steps from above and that fixed the issue for me -->

In Visual Studio 2013 -> Tools -> Extensions and Updates... -> Updates -> Product Updates -> Microsoft SQL Server Update for database to 12.0.50730.0

Solution 10 - Msbuild

I had the same issue and just restart the Visual Studio and it works for me.

Solution 11 - Msbuild

I experienced the same issue with a slightly different stack trace:

> Error MSB4018: The "SqlBuildTask" task failed unexpectedly. > System.IO.IOException: The file exists.

Turns out this is a issue with the Temp directory for the service account I was using, I think if you exceed X number of folders/files in that directory the publish will no longer work. Fixed this issue by following the instructions mentioned here (for my service account):

  • Go start-> run
  • Type %temp% and click ok
  • Make sure you are in the folder /Local/Temp
  • Delete everything in this folder

Solution 12 - Msbuild

If it helps anybody, I installed VS2014 CTP 3, and I can build from it. Interestingly after a successfull build in vs2014, the next time you build in VS2013 it works. But subsequent builds in VS2013 dont work, until you rebuild in VS2014.

Solution 13 - Msbuild

I was able to fix the issue by repairing Microsoft SQL Server Data Tools and re-starting Visual Studio 2013. Control Panel > Right Click: "Microsoft SQL Server Data Tools" > Click: "Repair" > Re-Start Visual Studio

Solution 14 - Msbuild

I had the same issue. Running disk check and then rebooting fixed it.

Solution 15 - Msbuild

I got the same error and fix it by re-install Visual Studio 2015

Solution 16 - Msbuild

I had this problem and fixed it like this:

  1. install the latest DacFx from http://www.microsoft.com/en-us/download/details.aspx?id=43370

  2. Delete the Microsoft.Data.Tools.Schema.SqlTasks.targets file from C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\SSDT

  • repair SQL Server Data Tools 2013 , reset visual studio()

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGooseZAView Question on Stackoverflow
Solution 1 - MsbuildMauro BilottiView Answer on Stackoverflow
Solution 2 - MsbuildBrandon HawbakerView Answer on Stackoverflow
Solution 3 - MsbuildDawood AwanView Answer on Stackoverflow
Solution 4 - MsbuildCSharperView Answer on Stackoverflow
Solution 5 - MsbuildFranklinView Answer on Stackoverflow
Solution 6 - MsbuildSimon MourierView Answer on Stackoverflow
Solution 7 - MsbuildGooseZAView Answer on Stackoverflow
Solution 8 - MsbuildmartinossView Answer on Stackoverflow
Solution 9 - MsbuildSagarView Answer on Stackoverflow
Solution 10 - MsbuildAatish LandgeView Answer on Stackoverflow
Solution 11 - MsbuildDavid RogersView Answer on Stackoverflow
Solution 12 - MsbuilddalcamView Answer on Stackoverflow
Solution 13 - MsbuildJamie M.View Answer on Stackoverflow
Solution 14 - MsbuildQgecNickView Answer on Stackoverflow
Solution 15 - Msbuilduser5365082View Answer on Stackoverflow
Solution 16 - MsbuildmarziehView Answer on Stackoverflow