3
votes

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()
3
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
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
@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
This might have to do with the version of SQL Server Data Tools that you have installed. - Jim Aho
Did you ever resolve this problem? - LawrenceF

3 Answers

2
votes

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>-->
0
votes

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.

0
votes

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"