-
Notifications
You must be signed in to change notification settings - Fork 433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DACPAC updated returns on error on VS2022/.NET 4.8 based hosted agents #1592
Labels
Comments
I think the issue is related to issue dotnet/runtime#39078. When the script (within the tasks) is tested locally on PowerShell V5 I can get the same error, but if I run script the twice it works the 2nd time function Update-DacpacVerion {
param(
[parameter(Mandatory)]
[String]$Path,
[Parameter(Mandatory)]
[System.Version]$VersionNumber,
[string]$ToolPath
)
#Specifying the Error Preference within the function scope to help catch errors
$ErrorActionPreference = 'Stop'
# Add SQL methods from Dlls, using Test-Path to determine which version to import based on VS version
try {
Add-Type -Path "$ToolPath\Microsoft.SqlServer.Dac.Extensions.dll"
Add-Type -Path "$ToolPath\Microsoft.SqlServer.Dac.dll"
}
catch {
Write-Error 'Failed to load DLL, check all SDKs and SSDT are installed correctly in the Visual Studio folders.'
Exit -1
}
#Loads the DacPac ready for updating
$StorageType = [Microsoft.SqlServer.Dac.DacSchemaModelStorageType]::File
$AccessType = [System.IO.FileAccess]::ReadWrite
$DacPacObject = [Microsoft.SqlServer.Dac.DacPackage]::Load($Path, $StorageType, $AccessType)
#Sets up various load options for updating dacpac
$LoadOptions = New-Object Microsoft.SqlServer.Dac.Model.ModelLoadOptions($null)
$LoadOptions.LoadAsScriptBackedModel = $true
$LoadOptions.ModelStorageType = $StorageType
$TSQLModel = [Microsoft.SqlServer.Dac.Model.TSqlModel]::LoadFromDacpac($Path, $LoadOptions)
#sets up details to update in dacpac
$DacpacOptions = New-Object Microsoft.SqlServer.Dac.PackageMetadata($null)
$DacpacOptions.Description = $DacPacObject.Description
$DacpacOptions.Name = $DacPacObject.Name
$DacpacOptions.Version = $VersionNumber
Try {
Write-Verbose "Attempting to update $($DacPacObject.Name) with version number $VersionNumber" -Verbose
#Updates the DacPack with specified details
[Microsoft.SqlServer.Dac.DacPackageExtensions]::UpdateModel($DacPacObject, $TSQLModel, $DacpacOptions)
Write-Verbose "Succeeded in updating $($DacPacObject.Name) with version number $VersionNumber" -Verbose
}
catch {
Write-Warning "Failed to update DacPac $($DacPacObject.Name), due to error:"
Write-Warning "$($error[0])"
}
}
Update-DacpacVerion -path "C:\projects\bm-source\ISS\Src\Expenses\BlackMarble.ISS.Database\bin\Debug\BlackMarble.ISS.Database.dacpac" -versionnumber 1.2.3.4 -toolpath 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\Extensions\Microsoft\SQLDB\DAC' I need to get a repo on a hosted agent |
rfennell
added a commit
that referenced
this issue
Mar 4, 2024
rfennell
added a commit
that referenced
this issue
Mar 4, 2024
Fixed with a hacky workaround (a retry) in 3.7.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Azure DevOps Extensions
Manifest Versioning
Platform
Azure DevOps Services
Azure DevOps Server (TFS) Version
No response
Extension Version
DACPAC updater
Describe the bug
When the DACPAC task is run on a current Microsoft hosted agent (VS2022 and .NET 4.8) the following error is seen
Repo Steps
Use the task on a current hosted build agent
Expected Behavior
The version should be set without error
Logging Information
No response
The text was updated successfully, but these errors were encountered: