2016-05-20 158 views
1

我们使用PowerShell脚本来部署SQL数据库。这个脚本使用SqlPackage.exe工具来发布我们的主数据库,它工作正常,直到我们将SSDT升级到它的最新版本SSDT 2015时,它声称抛出下面的错误。升级后SqlPackage.exe命令抛出错误

PowerShell脚本行:

& "C:\Program Files (x86)\Microsoft SQL Server\120\DAC\bin\SqlPackage.exe" /Action:Publish /SourceFile:"$DatabaseDacpacLocation" /TargetServerName:$DataServerSqlInstance /TargetDatabaseName:$Database /Variables:master="$MasterDatabase" /v:DatabaseName="$pDatabaseName" /p:ExcludeObjectType=Sequences 

错误:

Unhandled Exception: System.TypeInitializationException: The type initializer for 'Microsoft.SqlServer.Dac.DacPackage' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Microsoft.SqlServer.Dac.DacServices' threw an exception. ---> System.TypeInitializationException: The type initializer for 'SqlSchemaModelStaticState' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.SqlServer.TransactSql.ScriptDom, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.

回答

4

它看起来像你的部署环境中缺少SqlDom版本12(Microsoft.SqlServer.TransactSql.ScriptDom.dll) ,预计将在GAC中进行。您可以从SQL Server 2014 Feature Pack页面下载:https://www.microsoft.com/en-us/download/details.aspx?id=42295

您应该下载并安装两个文件--SqlDom.msi的x64和x86版本。

看来您目前正在使用SQL Server 2014版本的数据层应用程序框架。请注意,如果您更新到SQL Server 2016版本的数据层应用程序框架(DacFX),则需要确保也安装了DacFX的依赖项(SqlSysClrTypes.msi和SqlDom.msi)的较新版本(v13) 。