3

Update: I have reproduced the same Error with a new empty VS2015 WebApplication project.

  • Added a connectionString to a new empty SQL database
  • Added a sql-script file to the solution and selected publish... in the publish wizard.

Example of web Publish wizard with included Update script.

I will get the same error building a web deployment package or web deploy .

Original post: The "SqlScriptPreprocessSqlVariables" task failed unexpectedly. This happens when I use publishing wizard or MSBuild with a profile where the Update Database is selected. On a newly installed machine with only VS2015 Update1 and also on our build server with Team Fondation Server 2015 Build Agent. The same publish profile works in our VS2013 environment.

System.TypeLoadException: Signature of the body and declaration in a method implementation do not match. 
Type:   'Microsoft.Web.Publishing.Tasks.SqlScriptPreprocessor.SqlCommandExecuter'.   
Assembly: 'Microsoft.Web.Publishing.Tasks, Version=14.0.0.0, Culture=neutral,    PublicKeyToken=b03f5f7f11d50a3a'. 
at Microsoft.Web.Publishing.Tasks.SqlScriptPreprocessor.SqlScriptPreprocessSqlVariables.Execute() 
at   Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask>d__26.MoveNext()

Here is the same error but from the Build Agent in the new build system. I got the same error runnig XAML build on the new Agent.

##[error]C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Deploy\Microsoft.Web.Publishing.MSDeploy.Common.targets(119,5): Error MSB4018: The "SqlScriptPreprocessSqlVariables" task failed unexpectedly.
##[error]System.TypeLoadException: Signature of the body and declaration in a method implementation do not match.  Type: 'Microsoft.Web.Publishing.Tasks.SqlScriptPreprocessor.SqlCommandExecuter'.  Assembly: 'Microsoft.Web.Publishing.Tasks, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
##[error]   at Microsoft.Web.Publishing.Tasks.SqlScriptPreprocessor.SqlScriptPreprocessSqlVariables.Execute()
##[error]   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
##[error]   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
Oskbo
  • 51
  • 8
  • 1
    Where did you get "SqlScriptPreprocessSqlVariables" task? Instead of TFS Build, can you build your project locally? From the log, it seems your issue relates to your project, not TFS. – Cece Dong - MSFT Apr 20 '16 at 10:15
  • 1
    The build work but the publish step gives the error. I invoke msbuild with the folowing parameters `/p:DeployOnBuild=true /p:PublishProfile=Release.pubxml /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true` – Oskbo Apr 20 '16 at 13:23
  • @Cece-MSFT I'll get the error when running the publish wizard on the web project. If i uncheck the Update Database option it will work. – Oskbo Apr 20 '16 at 13:52
  • 1
    This might have to do with the version of SQL Server Data Tools that you have installed. – Jim Aho Apr 25 '16 at 07:54
  • Did you ever resolve this problem? – LawrenceF Jun 21 '16 at 14:59
  • @LawrenceF Yes I did, but it's a pretty ugly solution that involves changing .target XML. I'll post it as a solution to this. – Oskbo Jun 23 '16 at 06:59
  • @Oskbo I can cope with ugly...that would be great. Thanks. – LawrenceF Jun 27 '16 at 09:21
  • @JimAho you are right. I faced the same issue and I solved it installing the latest version of "SQL Server Data Tools" – gsubiran Sep 01 '16 at 15:39

3 Answers3

2

This is how I fixed the webdeploy packaging problem. This is not a solution I recommend but it works on my machine and on the build server.

Locate the file Microsoft.Web.Publishing.MsDeploy.Common.targets

This is the location on my machine:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Deploy\ Microsoft.Web.Publishing.MsDeploy.Common.targets

On row 117 and forward I commented out the following section.

<!--<SqlScriptPreprocessSqlVariables
UnsupportedKeywords="$(MsdeploySqlUnsupportedCommand)" CheckForUnsupportCommands="$(CheckSqlScriptForUnsupportedCommands)"
TreadSqlScriptUnsupportedCommandsAsWarning="$(TreadSqlScriptUnsupportedCommandsAsWarning)"
SqlScriptFile="%(_DatabasesToPackageForSQL.SourcePath)"
DestinationGroup="%(_DatabasesToPackageForSQL.DestinationGroup)"
ResolveIncludes="$(SqlScriptPreProcessResolveIncludes)"
BatchDelimiter="$(SqlScriptPreProcessBatchDelimiter)"
Condition="$(EnableSqlScriptVariableParameterize) And '%_DatabasesToPackageForSQL.SourcePath)' != '' And Exists('%(_DatabasesToPackageForSQL.SourcePath)')  ">
<Output TaskParameter="List" ItemName="_DatabasesToPackage_SqlVariables" />
</SqlScriptPreprocessSqlVariables>-->
Oskbo
  • 51
  • 8
0

I recently faced the same issue and I solved it installing the latest version of "SQL Server Data Tools" and restarting the machine. As @JimAho mentioned, the problem is related to SQL Server Data Tools version installed. Here you could download it

enter image description here

Don't forget to restart the machine.

gsubiran
  • 2,012
  • 1
  • 22
  • 33
  • 1
    I did exactly that, but it did not help. But the tools have been updated since then so I will try again. – Oskbo Sep 07 '16 at 06:29
0

Still not quite satisfied with these solutions, I did some research and the least invasive approach I can see is simply registering the assembly in the GAC.

  • Run VS Command Prompt as Administrator
  • Hit Windows Start
  • type "Developer"
  • Right Click "Developer Command Prompt for VS 2017"
  • Select Run as Administrator

Developer Command Prompt for VS 2017

  • Run the following command (Replace Enterpise with your installation, e.g. Professional, BuildTools, Community):
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\Microsoft\SQLCommon\130\Microsoft.SqlServer.BatchParser.dll"
Daniel Leach
  • 5,517
  • 4
  • 18
  • 32