3

更新: 我用一个新的空 VS2015 WebApplication 项目重现了同样的错误。

  • 向新的空 SQL 数据库添加了 connectionString
  • 向解决方案添加了一个 sql-script 文件并在发布向导中选择了发布...。

包含更新脚本的网络发布向导示例。

在构建 web 部署包或 web deploy 时,我会遇到同样的错误。

原帖: “SqlScriptPreprocessSqlVariables”任务意外失败。当我将发布向导或 MSBuild 与选择了更新数据库的配置文件一起使用时,会发生这种情况。在仅安装了 VS2015 Update1 的新安装机器上,以及我们使用 Team Fondation Server 2015 构建代理的构建服务器上。相同的发布配置文件适用于我们的 VS2013 环境。

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

这是相同的错误,但来自新构建系统中的构建代理。我在新代理上运行 XAML 构建时遇到了同样的错误。

##[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()
4

3 回答 3

2

这就是我修复 webdeploy 打包问题的方法。这不是我推荐的解决方案,但它适用于我的机器和构建服务器。

找到文件Microsoft.Web.Publishing.MsDeploy.Common.targets

这是我机器上的位置:

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

在第 117 行及之前,我注释掉了以下部分。

<!--<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>-->
于 2016-06-27T14:14:58.087 回答
0

我最近遇到了同样的问题,我安装了最新版本的“SQL Server Data Tools”并重新启动机器解决了这个问题。正如@JimAho 提到的,问题与安装的 SQL Server Data Tools 版本有关。 在这里你可以下载它

在此处输入图像描述

不要忘记重新启动机器。

于 2016-09-01T15:15:32.750 回答
0

仍然对这些解决方案不太满意,我做了一些研究,我能看到的侵入性最小的方法就是在 GAC 中注册程序集。

  • 以管理员身份运行 VS 命令提示符
  • 点击 Windows 开始
  • 输入“开发者”
  • 右键单击“VS 2017 的开发人员命令提示符”
  • 选择以管理员身份运行

VS 2017 的开发人员命令提示符

  • 运行以下命令(将 Enterprise 替换为您的安装,例如 Professional、BuildTools、Community):
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\Microsoft\SQLCommon\130\Microsoft.SqlServer.BatchParser.dll"
于 2018-06-11T02:50:09.217 回答