【发布时间】:2010-09-24 19:30:15
【问题描述】:
我目前正在使用 MSDeploy 将一组网站从 II6 迁移到另一台运行 IIS7.5 的机器上。实际的网站迁移按预期工作,但我也在尝试迁移每个网站的关联数据库。
到目前为止,我能够成功移动我们的一组测试站点,但是我在我们的实时站点上遇到了部署失败(并且运行时间极度长 - 1 小时以上,400MB db)。我看到的失败似乎与存储在 sql 数据库(作为数据)中的一些 javascript 有关。看起来,当 SMO BatchParser 读取它生成的 sql 脚本 时,它会在第一行尝试在数据中插入带有一些 javascript 的行时死掉。
这是我正在使用的 MSDeploy 命令:
msdeploy.exe -source:source-manifest.xml -dest:manifest=dest-manifest.xml
source-manifest.xml:
<sitemanifest>
<dbFullSql path="Data Source=srv_source;Initial Catalog=db;User ID=usr;Password=pwd" Transacted="True" CopyAllLogins="False" CopyAllUsers="False" />
</sitemanifest>
dest-manifest.xml:
<sitemanifest>
<dbFullSql path="Data Source=srv_dest;Initial Catalog=db;Integrated Security=true" DropDestinationDatabase="True" />
</sitemanifest>
MSDeploy 错误是:
Error: An error occurred during execution of the database script. The approximate location of the error was between lines '17009' and '17400' of the script. The verbose log may have more information about the error. The command started with:
INSERT [dbo].[Pages] ([PathID], [PageID], [PageKey
Error:
Error count: 1.
导致错误的sql文件摘录:
INSERT [dbo].[Pages] ([PathID], [PageID], [PageKey], [DeveloperID], [FrameworkID], [MasterPageID], [FormID], [Label], [Description], [Status], [AdminPosition], [AdminIndent], [Created], [LastEdited], [PageScript], [PageScriptHead], [PageScriptForm], [PageOnLoad], [PageOnUnload], [PageOnSubmit], [HtmlAttributes], [HasThumbnail], [QueryStringVars], [FriendlyPageURL], [CanonicalURL], [MvtStatus], [MvtAutoOptimize], [MvtStartDate], [MvtEndDate], [MvtExperimentID], [DeepLinkOk]) VALUES (72, 580, N'zz', N'zz', N'zzz', N'zzz', NULL, N'zzz', N'zzz', N'U', 0, 0, CAST(0x00009D3D00A0C296 AS DateTime), CAST(0x00009D4C00C99FA8 AS DateTime), NULL, N' <script language="javascript" type="text/javascript">
function javascript_stuff()
{
this.$("panel").style.display = "block";
...
lots more snipped out code in here
}
var regex = /^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$/;
var jsobj = new jsobj();
</script>', NULL, NULL, NULL, NULL, NULL, 1, NULL, N'welcome', NULL, N'N', N'N', NULL, NULL, 0, 0)
GO
如果我尝试通过 IIS UI 错误导入包:
An error occurred during execution of the database script. The approximate location of the error was between lines '17003' and '17394' of the script. The verbose log may have more information about the error. The command started with :
INSERT [dbo].[Pages] ([PathID], [PageID], [PageKey
[Expanded Information]
Microsoft.Web.Deployment.DeploymentException: An error occurred during execution of the database script. The approximate location of the error was between lines '17003' and '17394' of the script. The verbose log may have more information about the error. The command started with :
INSERT [dbo].[Pages] ([PathID], [PageID], [PageKey
---> ManagedBatchParser.ParserException
at ManagedBatchParser.Parser.Parse()
at Microsoft.Web.Deployment.SqlBatchParser.ProcessSqlCmdScript(String sqlCmdScript)
at Microsoft.Web.Deployment.SqlScriptToDBProvider.AddHelper(DeploymentObject source, Boolean whatIf)
--- End of inner exception stack trace ---
at Microsoft.Web.Deployment.SqlScriptToDBProvider.AddHelper(DeploymentObject source, Boolean whatIf)
at Microsoft.Web.Deployment.DeploymentObject.AddChild(DeploymentObject source, Int32 position, DeploymentSyncContext syncContext)
at Microsoft.Web.Deployment.DeploymentSyncContext.HandleAddChild(DeploymentObject destParent, DeploymentObject sourceObject, Int32 position)
at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildrenOrder(DeploymentObject dest, DeploymentObject source)
at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildrenOrder(DeploymentObject dest, DeploymentObject source)
at Microsoft.Web.Deployment.DeploymentSyncContext.ProcessSync(DeploymentObject destinationObject, DeploymentObject sourceObject)
at Microsoft.Web.Deployment.DeploymentObject.SyncToInternal(DeploymentObject destObject, DeploymentSyncOptions syncOptions, PayloadTable payloadTable, ContentRootTable contentRootTable)
at Microsoft.Web.Deployment.DeploymentObject.SyncTo(DeploymentProviderOptions providerOptions, DeploymentBaseOptions baseOptions, DeploymentSyncOptions syncOptions)
at Microsoft.Web.Deployment.DeploymentObject.SyncTo(DeploymentWellKnownProvider provider, String path, DeploymentBaseOptions baseOptions, DeploymentSyncOptions syncOptions)
at Microsoft.Web.Deployment.UI.InstallProgressWizardPage.OnWorkerDoWork(Object sender, DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
有人知道我该如何解决这个问题吗?如果我直接使用 SQL Management Studio 从包中运行 sql 文件,它运行得非常好。因此,除非 SMO BatchParser 中存在错误,否则我必须设置某种 SMO 选项来解决此问题。
任何帮助将不胜感激!
【问题讨论】:
-
经过进一步调查,问题似乎是在行数据(存储的 javascript 代码)中发现了 $(blah)。 MSDeploy 允许在使用相同 $() 语法的 Sql 脚本中进行 SqlCmd 样式变量替换。所以现在我知道为什么了,但真正的问题是:有没有办法在 MSDeploy 的 dbFullSql 提供程序中关闭变量替换?