我正在使用Octopus部署MVC项目和数据库。当部署数据库的步骤被命中时,我收到以下错误:
An error occurred during deployment plan generation. Deployment cannot continue.
Error SQL72018: Database Options could not be imported but one or more of these objects exist in your source.
at Microsoft.SqlServer.Dac.DacServices.CreateController(SqlDeployment deploymentEngine, 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.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, DacDeployOptions options, CancellationToken cancellationToken, DacLoggingContext loggingContext)
at Microsoft.SqlServer.Dac.DacServices.Deploy(DacPackage package, String targetDatabaseName, Boolean upgradeExisting, DacDeployOptions options, Nullable`1 cancellationToken)
at CallSite.Target(Closure , CallSite , Object , Object , Object , Boolean , Object )
Errors occurred while modeling the target database. Deployment can not continue.
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.ThrowIfErrors(String message, ErrorManager errors, Object category)
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentEndpointServer.OnLoad(ErrorManager errors, DeploymentEngineContext context)
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.PrepareModels()
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.InitializePlanGeneratator()
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.CreateController(Action`1 msgHandler)
at Microsoft.SqlServer.Dac.DacServices.CreateController(SqlDeployment deploymentEngine, ErrorManager errorManager)
这是Deploy.ps1文件
# Add the DLL
# For 64-bit machines
Write-Host "Add Types"
Add-Type -path ((Get-Item -Path ".\" -Verbose).FullName + "\bin\Microsoft.SqlServer.Dac.dll")
Add-Type -path ((Get-Item -Path ".\" -Verbose).FullName + "\bin\Microsoft.SqlServer.TransactSql.ScriptDom.dll")
# Create the connection string
$services = New-Object Microsoft.SqlServer.Dac.DacServices ("Data Source=$dbSource;User Id=$dbAdminUser;Password=$dbAdminPassword")
Write-Host "Load the dacpac " + ((Get-Item -Path ".\" -Verbose).FullName + "\Resources\Database.publish.xml")
#Load the dacpac
$dacpac = ((Get-Item -Path ".\" -Verbose).FullName + "\Resources\Database.dacpac")
$dacpacoptions = ((Get-Item -Path ".\" -Verbose).FullName + "\Resources\Database.publish.xml")
#Load dacpac from file & deploy to database
$dp = [Microsoft.SqlServer.Dac.DacPackage]::Load($dacpac)
Write-Host "dacProfile set"
#Read a publish profile XML to get the deployment options
$dacProfile = [Microsoft.SqlServer.Dac.DacProfile]::Load($dacpacoptions)
Write-Host "Add dbUser"
$dacProfile.DeployOptions.SqlCommandVariableValues["dbUsername"] = $dbUser
Write-Host "Add dbPassword"
$dacProfile.DeployOptions.SqlCommandVariableValues["dbPassword"] = $dbPassword
Write-Host "About to deploy the dacpac"
# Deploy the dacpac
$services.Deploy($dp, $dbName, $TRUE, $dacProfile.DeployOptions)
# Configure IIS
.\DeployScripts\IISConfiguration.ps1
SQL Project的目标是SQL Server 2012.我不确定其他哪些信息会对您有所帮助,所以如果您需要更多信息请告诉我。所有帮助表示赞赏。谢谢你的时间!
答案 0 :(得分:0)
您不再需要安装SQLPackage,他们已经发布了包含它的NuGet包。看看https://www.nuget.org/packages/Microsoft.Data.Tools.Msbuild