【问题标题】:Unable to run the dbdeploy component using msbuild on windows server 2012 where SQL Server 2012 is installed无法在安装了 SQL Server 2012 的 Windows Server 2012 上使用 msbuild 运行 dbdeploy 组件
【发布时间】:2014-11-01 13:00:51
【问题描述】:

我正在尝试在安装了 SQL Server 2012 的 Windows Server 2012 上使用 MSBuild 运行 dbdeploy 组件。

在运行 msbuild 脚本时,我收到以下错误:

"E:\TestDeployment\Test.proj" (UpgradeDatabase target) (1) ->(dbDeploy target) ->
  E:\TestDeployment\Test.proj(212,5): error : Unexpected System.IO.FileNotFoundException
error executing SQL command: -- BEGINNING TRANSACTION\r
E:\TestDeployment\Test.proj(212,5): error : PRINT 'Beginning transaction'\r
E:\TestDeployment\Test.proj(212,5): error : BEGIN TRANSACTION \r
E:\TestDeployment\Test.proj(212,5): error : GO\r
E:\TestDeployment\Test.proj(212,5): error : \r
E:\TestDeployment\Test.proj(212,5): error : -- Drop Table ChangeLog\r
E:\TestDeployment\Test.proj(212,5): error : Print 'Checking for Table ChangeLog'\r
E:\TestDeployment\Test.proj(212,5): error : IF (NOT EXISTS(SELECT * FROM sys.objects WHER
E [object_id] = OBJECT_ID(N'[dbo].ChangeLog') AND [type]='U'))\r
E:\TestDeployment\Test.proj(212,5): error : BEGIN\r
E:\TestDeployment\Test.proj(212,5): error :         CREATE TABLE dbo.ChangeLog \r
E:\TestDeployment\Test.proj(212,5): error :         (\r
E:\TestDeployment\Test.proj(212,5): error :                 change_number INTEGER NOT NUL
,\r
E:\TestDeployment\Test.proj(212,5): error :                 delta_set VARCHAR(10) NOT NUL
,\r
E:\TestDeployment\Test.proj(212,5): error :                 start_dt DATETIME NOT NULL,\r
E:\TestDeployment\Test.proj(212,5): error :                 complete_dt DATETIME NULL,\r
E:\TestDeployment\Test.proj(212,5): error :                 applied_by VARCHAR(100) NOT N
LL,\r
E:\TestDeployment\Test.proj(212,5): error :                 description VARCHAR(500) NOT
ULL\r
E:\TestDeployment\Test.proj(212,5): error :         )\r
E:\TestDeployment\Test.proj(212,5): error : \r
E:\TestDeployment\Test.proj(212,5): error :         IF @@ERROR<>0 OR @@TRANCOUNT=0 BEGIN
IF @@TRANCOUNT>0 ROLLBACK SET NOEXEC ON END\r
E:\TestDeployment\Test.proj(212,5): error :                 \r
E:\TestDeployment\Test.proj(212,5): error :         ALTER TABLE ChangeLog ADD CONSTRAINT
PK_ChangeLog PRIMARY KEY (change_number, delta_set)\r
E:\TestDeployment\Test.proj(212,5): error :         IF @@ERROR<>0 OR @@TRANCOUNT=0 BEGIN
IF @@TRANCOUNT>0 ROLLBACK SET NOEXEC ON END\r
E:\TestDeployment\Test.proj(212,5): error : END\r
E:\TestDeployment\Test.proj(212,5): error : GO\r
E:\TestDeployment\Test.proj(212,5): error : IF @@ERROR<>0 OR @@TRANCOUNT=0 BEGIN IF @@TRA
NCOUNT>0 ROLLBACK SET NOEXEC ON END\r
E:\TestDeployment\Test.proj(212,5): error : GO\r
E:\TestDeployment\Test.proj(212,5): error : \r
E:\TestDeployment\Test.proj(212,5): error : UPDATE dbo.ChangeLog SET complete_dt = getdat
e() WHERE complete_dt IS NULL\r
E:\TestDeployment\Test.proj(212,5): error : GO\r
E:\TestDeployment\Test.proj(212,5): error : \r
E:\TestDeployment\Test.proj(212,5): error : IF @@ERROR<>0 OR @@TRANCOUNT=0 BEGIN IF @@TRA
NCOUNT>0 ROLLBACK SET NOEXEC ON END\r
E:\TestDeployment\Test.proj(212,5): error : GO\r
E:\TestDeployment\Test.proj(212,5): error : \r
E:\TestDeployment\Test.proj(212,5): error : -- COMMITTING TRANSACTION\r
E:\TestDeployment\Test.proj(212,5): error : IF @@TRANCOUNT>0\r
E:\TestDeployment\Test.proj(212,5): error : BEGIN\r
E:\TestDeployment\Test.proj(212,5): error :         PRINT 'Committing transaction'\r
E:\TestDeployment\Test.proj(212,5): error :         COMMIT TRANSACTION \r
E:\TestDeployment\Test.proj(212,5): error : END\r
E:\TestDeployment\Test.proj(212,5): error : GO\r
E:\TestDeployment\Test.proj(212,5): error : \r
E:\TestDeployment\Test.proj(212,5): error : SET NOEXEC OFF\r
E:\TestDeployment\Test.proj(212,5): error : GO\r
E:\TestDeployment\Test.proj(212,5): error :
E:\TestDeployment\Test.proj(212,5): error : Could not load file or assembly 'Microsoft.SqlServer.BatchParser, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.

上面的脚本在我的 Dev box 和安装了 SQL SERVER 2008 R2 的 box (Windows Server 2008 R2) 上运行良好。一旦我尝试在安装了 SQL SERVER 2012 的新机器上对其进行测试,问题就开始了。

谁能帮我解决这个问题?

【问题讨论】:

    标签: sql-server-2012 windows-server-2012 msbuild-4.0 dbdeploy


    【解决方案1】:

    检查可以工作的机器和不工作的机器之间的环境变量。这假设您正在打开命令提示符,然后运行 ​​MSBuild。

    我的机器上安装了 SQL Server 2012,并在以下位置找到了 BatchParser.DLL:

    • C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn
    • C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn
    • C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn

    因此,错误的最可能原因是您完全缺少一个指向其中之一的环境变量。

    据我所知,它们仅在我的 PATH 变量中。

    如果您在任何这些位置都找不到此 DDL,那么您需要按照这些 S.O. 中的说明安装 SMO。问题:

    编辑:
    最后要检查的是是否还有一个 C:\Program Files (x86)\Microsoft SQL Server\100 文件夹,该文件夹将包含 DTS\Binn 和/或 Tools\Binn 文件夹。我的猜测是,基于错误是

    无法加载文件或程序集 'Microsoft.SqlServer.BatchParser, Version=10.0.0.0

    它专门寻找 SMO 的 2008 版本,这是您的开发盒具有但不在仅具有 SQL 2012 的新盒上的东西。那么你的选择是:

    • 尝试简单地将“batchparser.dll”从您的开发箱复制到新的 SQL 2012 服务器并将其放在 C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn 文件夹。
    • 在新的 SQL Server 2012 服务器上下载并安装 SQL Server 2008 R2 Feature Pack,其中包括 SMO。展开“安装说明”部分并转到“Microsoft® SQL Server® 2008 R2 共享管理对象”以获取正确的 MSI。

    【讨论】:

    • 感谢 srutzky 提供详细信息。我检查了上面的详细信息,发现上面提到的组件存在于安装 SQL Server 2012 的 Windows server 2012 中。
    • @santoshkumarpatro :好的,我看到了你的答案。我刚刚更新了我的更多细节。仅仅为此不需要额外的项目可能会很好。
    【解决方案2】:

    我进一步分析了这个问题,发现我需要更新 dbDeploy 组件。我使用在 URL:http://dbdeploynet2.codeplex.com/ 上找到的 DbDeploy.Net 2 更新了现有项目,然后根据提到的示例对现有的 msbuild 脚本进行了更改,它开始对我正常工作。在这个实现之后我面临的唯一问题是 DedicatedAdminConnection="True" 的使用给出了另一个与 SQL 连接相关的错误。因此,我不想在 msbuild 脚本中使用 DedicatedAdminConnection="True"。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多