ISSUE:
无法通过Powershell脚本部署DACPAC。此脚本适用于已配置用于发布管理的大约20个其他数据库服务器。
工作环境:
非工作环境:
命令:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120\sqlpackage.exe
/Action:Publish
/SourceFile:"\\<Server>\Builds\<BuildDefinition>\<BuildNumber>\Databases\Arsenal\Arsenal.dacpac"
/Profile:"\\<Server>\Builds\<BuildDefinition>\<BuildNumber>\Deployment\Configuration\Databases\Publish_DEFAULT.xml"
/p:TreatVerificationErrorsAsWarnings="True"
/v:BuildNumber="<BuildNumber>"
其中:
Publish_DEFAULT.xml
包含以下键:
<?xml version="1.0"?>
<Configurations>
<Properties>
<Property key="IncludeCompositeObjects" value="True" />
<Property key="ScriptDatabaseOptions" value="True" />
<Property key="BlockOnPossibleDataLoss" value="False" />
<Property key="DropObjectsNotInSource" value="True" />
<Property key="DropRoleMembersNotInSource" value="True" />
<Property key="DropPermissionsNotInSource" value="True" />
<Property key="DeployDatabaseInSingleUserMode" value="True" />
<Property key="BackupDatabaseBeforeChanges" value="False" />
<Property key="GenerateSmartDefaults" value="True" />
<Property key="TreatVerificationErrorsAsWarnings" value="True" />
</Properties>
<SQLCmdVariables>
<SQLCmdVariable key="BuildNumber" value="UNKNOWN" />
<SQLCmdVariable key="DeployLoadTestData" value="False" />
<SQLCmdVariable key="DeployPurgeData" value="False" />
</SQLCmdVariables>
</Configurations>
LOG :
发布到数据库 初始化部署(开始) 初始化部署(失败) 发生意外故障:算术运算导致溢出..
未处理的异常:System.OverflowException:算术运算 导致溢出。 在System.Data.SqlClient.TdsParser.ConsumePreLoginHandshake(布尔值 encrypt,Boolean trustServerCert,Boolean integratedSecurity,Boolean&amp; marsCapable) 在System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo,SqlInternalConnectionTds connHandler,Boolean ignoreSniOpenTimeout, Int64 timerExpire,布尔加密,布尔值trustServerCert,布尔值 integratedSecurity,Boolean withFailover) 在System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo,String newPassword,SecureString newSecurePassword, Boolean ignoreSniOpenTimeout,TimeoutTimer timeout,Boolean withFailover) 在System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo,String newPassword,SecureString newSecurePassword, Boolean redirectedUserInstance,SqlConnectionString connectionOptions, SqlCredential凭证,TimeoutTimer超时) 在System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout,SqlConnectionString connectionOptions,SqlCredential credential,String newPassword,SecureString newSecurePassword, Boolean redirectedUserInstance) 在System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity,SqlConnectionString connectionOptions,SqlCredential 凭证,Object providerInfo,String newPassword,SecureString newSecurePassword,Boolean redirectedUserInstance,SqlConnectionString userConnectionOptions) 在System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options,DbConnectionPoolKey poolKey,Object poolGroupProviderInfo, DbConnectionPool池,DbConnection owningConnection, DbConnectionOptions userOptions) 在System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection) owningConnection,DbConnectionPoolGroup poolGroup,DbConnectionOptions USEROPTIONS) 在System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,TaskCompletionSource
1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource
1次重试,DbConnectionOptions userOptions) 在System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry) at System.Data.SqlClient.SqlConnection.Open() at Microsoft.Data.Tools.Schema.Common.SqlClient.ReliableSqlConnection.<OpenConnection>b__0() at Microsoft.Data.Tools.Schema.Common.SqlClient.RetryPolicy.<>c__DisplayClass4.<ExecuteAction>b__3(RetryState retryState) at Microsoft.Data.Tools.Schema.Common.SqlClient.RetryPolicy.ExecuteAction[R](Func
2 func,Nullable1 token) at Microsoft.Data.Tools.Schema.Common.SqlClient.RetryPolicy.ExecuteAction(Action
1 action,Nullable1 token) at Microsoft.Data.Tools.Schema.Common.SqlClient.ReliableSqlConnection.OpenConnection() at Microsoft.Data.Tools.Schema.Common.SqlClient.ReliableConnectionHelper.OpenConnection(String connectionString, Boolean useRetry) at Microsoft.Data.Tools.Schema.Common.SqlClient.ReliableConnectionHelper.OpenConnection(SqlConnectionStringBuilder csb, Action
1 usingConnection,Predicate1 catchException, Boolean useRetry) at Microsoft.Data.Tools.Schema.Common.SqlClient.ReliableConnectionHelper.GetServerAndDatabaseVersion(String connectionString, ServerAndDatabaseInfo& info) at Microsoft.Data.Tools.Schema.Sql.SqlDatabaseSchemaProviderFamily.DetermineDatabaseSchemaProvider(String connectionString) at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentEndpointServer.GetProviderType(DatabaseSchemaProviderFamily connectionSniffer, String connectionString, Type& providerType, Boolean& validDataSource) at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentEndpointServer.OnInit(ErrorManager errors, String targetDBName) at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment..ctor(SqlDeploymentConstructor constructor) at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentConstructor.ConstructServiceImplementation() at Microsoft.SqlServer.Dac.DacServices.CreatePackageToDatabaseDeployment(String connectionString, IPackageSource packageSource, String targetDatabaseName, DacAzureDatabaseSpecification creationDefaults, DacDeployOptions options, ErrorManager errorManager) at Microsoft.SqlServer.Dac.DeployOperation.<>c__DisplayClass3.<>c__DisplayClass5.<CreatePlanInitializationOperation>b__1() at Microsoft.Data.Tools.Schema.Sql.Dac.OperationLogger.Capture(Action action) at Microsoft.SqlServer.Dac.DeployOperation.<>c__DisplayClass3.<CreatePlanInitializationOperation>b__0(Object operation, CancellationToken token) at Microsoft.SqlServer.Dac.Operation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context) at Microsoft.SqlServer.Dac.ReportMessageOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context) at Microsoft.SqlServer.Dac.OperationExtension.CompositeOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context) at Microsoft.SqlServer.Dac.OperationExtension.CompositeOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context) at Microsoft.SqlServer.Dac.DeployOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context) at Microsoft.SqlServer.Dac.OperationExtension.Execute(IOperation operation, DacLoggingContext loggingContext, CancellationToken cancellationToken) at Microsoft.SqlServer.Dac.DacServices.InternalDeploy(IPackageSource packageSource, Boolean isDacpac, String targetDatabaseName, DacAzureDatabaseSpecification creationDefaults, DacDeployOptions options, CancellationToken cancellationToken, DacLoggingContext loggingContext) at Microsoft.SqlServer.Dac.DacServices.Deploy(DacPackage package, String targetDatabaseName, Boolean upgradeExisting, DacDeployOptions options, Nullable
1 cancellationToken) 在Microsoft.Data.Tools.Schema.CommandLineTool.DacServiceUtil。&lt;&gt; c__DisplayClass8.b__0(DacServices) 服务) at Microsoft.Data.Tools.Schema.CommandLineTool.DacServiceUtil.ExecuteDeployOperation(String connectionString,String filePath,MessageWrapper messageWrapper, Boolean sourceIsPackage,Boolean targetIsPackage,Func1 generateScriptFromPackage, Func
2 generateScriptFromDatabase) 在Microsoft.Data.Tools.Schema.CommandLineTool.DacServiceUtil.DoDeployAction(DeployArguments) parsedArgs,Action1 writeError, Action
2 writeMessage,Action`1 writeWarning,CancellationToken cancellationToken) 在Microsoft.Data.Tools.Schema.CommandLineTool.Program.DoDeployActions(CommandLineArguments parsedArgs) 在Microsoft.Data.Tools.Schema.CommandLineTool.Program.PerformAction(CommandLineArguments parsedArgs) 在Microsoft.Data.Tools.Schema.CommandLineTool.Program.Run(String [] args) 在Microsoft.Data.Tools.Schema.CommandLineTool.Program.Main(String [] 参数)
其他评论:
两种环境之间唯一不同的是SQL Server的版本......但是,我确实有一台SQL Server 2012的服务器正在运行!
我将Powershell脚本作为服务的标识运行:Microsoft Deployment Agent ...相同的日志文件错误;但是,sqlpackage.exe抛出以下错误:
问题签名: 问题事件名称:CLR20r3 问题签名01:sqlpackage.exe 问题签名02:12.0.2743.1 问题签名03:5438200c 问题签名04:System.Data 问题签名05:4.0.30319.18408 问题签名06:52310bef 问题签名07:28b2 问题签名08:6e 问题签名09:System.OverflowException 操作系统版本:6.1.7601.2.1.0.272.7 区域设置ID:1033 附加信息1:d90e 附加信息2:d90ee7d582c41ae7b6b96ca9c0463ab1 附加信息3:5e41 附加信息4:5e414a69026c10f11cc9c0b8e675c3aa
答案 0 :(得分:1)
而不是尝试直接发布DACPAC如何生成更改脚本(发布配置文件中的复选框选项)并运行针对数据库生成的T-SQL?另一种选择是在sqlpackage.exe文件夹中打开命令提示符并直接运行命令以查看是否提供了更清晰的错误消息。另外,直接针对数据库运行发布配置文件是否有效? Visual Studio可能会对此有所了解。
答案 1 :(得分:1)
<强>问题强>:
此服务器已从SQL Server 2005升级到SQL Server 2012&amp;通过发布管理启用DACPAC部署(SSDT)。升级步骤与所有其他工作数据库服务器不同。 SSDT&amp; RM是在SQL Server 2012之后安装的(不是之前的)
解决强>:
使用以下步骤重建数据库服务器: