Search code examples
msbuildvisual-studio-2015webdeploymicrosoft-web-deploy

Visual Studio 2015 exception SqlScriptPreprocessSqlVariables when running web publish wizard with update database


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()

Solution

  • 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>-->