The sqlpackage.exe is existing on Hosted VS 2017 agent, but not in the capacity list. (can’t add this capacity manually and use deploy database task, check VS2017 Hosted Agent: SQL Server Data Tools)
The workaround is that you can call sqlpackage.exe command by using Command Line task:
- Right click your project > Publish to create a publish profile
- Edit that publish profile to add Password to TargetConnectionString (Could be tokenized by using Replace Tokens task)
Sample:
<TargetConnectionString>Data Source=XXX.database.windows.net,1433;Persist Security Info=True;User ID=XXX;Password=XXX;Pooling=False;MultipleActiveResultSets=False;Connect Timeout=60;Encrypt=False;TrustServerCertificate=True</TargetConnectionString>
- Check in changes
- Add Command line task: (Tool:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\130\sqlpackage.exe
; Arguments: /Action:Publish /SourceFile:"$(build.artifactstagingdirectory)\DatabaseDemo.dacpac" /Profile:"$(build.sourcesdirectory)\DatabaseDemo\DatabaseDemo.publish.xml"
)
- Queue build with Hosted VS2017 agent.