J'utilise Octopus sur TeamCity pour déployer une base de données dans notre environnement de production, mais il continue de générer une erreur.Octopus Deploy.ps1 Le déploiement de DACPAC échoue
Voici le code Deploy.ps1:
$dbName = $OctopusParameters['DBName']
$dbUser = $OctopusParameters['AdminDBUsername']
$dbPassword = $OctopusParameters['AdminDBPassword']
$dbSource = $OctopusParameters['DBDataSource']
# Set params
if (! $dbName)
{
Write-Host "Missing required variable dbName" -ForegroundColor Yellow
exit 1
}
if (! $dbUser)
{
Write-Host "Missing required variable dbUser" -ForegroundColor Yellow
exit 1
}
if (! $dbPassword)
{
Write-Host "Missing required variable dbPassword" -ForegroundColor Yellow
exit 1
}
if (! $dbSource)
{
Write-Host "Missing required variable dbSource" -ForegroundColor Yellow
exit 1
}
# Add the DLL
# For 64-bit machines
Add-Type -path ((Get-Item -Path ".\" -Verbose).FullName + "\bin\Microsoft.SqlServer.TransactSql.ScriptDom.dll")
Add-Type -path ((Get-Item -Path ".\" -Verbose).FullName + "\bin\Microsoft.SqlServer.Dac.dll")
# Create the connection string
$d = New-Object Microsoft.SqlServer.Dac.DacServices ("data source=" + $dbSource + ";User Id = " + $dbUser + ";pwd=" + $dbPassword)
#Load the dacpac
$dacpac = ((Get-Item -Path ".\" -Verbose).FullName + "\DeployScripts\Database.dacpac")
$dacpacoptions = ((Get-Item -Path ".\" -Verbose).FullName + "\DeployScripts\publish.xml")
#Load dacpac from file & deploy to database
$dp = [Microsoft.SqlServer.Dac.DacPackage]::Load($dacpac)
#Read a publish profile XML to get the deployment options
$dacProfile = [Microsoft.SqlServer.Dac.DacProfile]::Load($dacpacoptions)
# Deploy the dacpac
$d.Deploy($dp, $dbName, $TRUE, $dacProfile.DeployOptions)
Voici le profil de publication dans le cas où il importe:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IncludeCompositeObjects>True</IncludeCompositeObjects>
<TargetDatabaseName>MyDatabase</TargetDatabaseName>
<DeployScriptFileName>MyDatabase.sql</DeployScriptFileName>
<ProfileVersionNumber>1</ProfileVersionNumber>
<BlockWhenDriftDetected>True</BlockWhenDriftDetected>
<RegisterDataTierApplication>True</RegisterDataTierApplication>
</PropertyGroup>
</Project>
Ci-dessous est l'erreur que je reçois:
Exception Appelant "Deploy" avec "4" argument (s):
"Une erreur est survenue pendant le déploiement du gène plan ration. Le déploiement ne peut pas continuer «
A Deploy.ps1:. 60 CHAR: 2
d.Deploy $ (dp $, dbName $, $ TRUE, dacProfile.DeployOptions $)
~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
CategoryInfo: NotSpecified: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId: DacServicesException
Est-ce que quelqu'un a des idées sur ce qui peut causer cela? Et comment le réparer? Merci d'avance!