- 
                Notifications
    
You must be signed in to change notification settings  - Fork 54
 
feat(build): container publish for image with dacpac and sqlpackage #799
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
base: master
Are you sure you want to change the base?
Conversation
| 
           @nmummau Why do we need to have the sqlpackage version involved? Could we not just use: 
  | 
    
| 
           @nmummau And thanks for doing this, this is a great addition!  | 
    
| 
           @nmummau Just watched the video - a great help for me (not being a docker expert). Some thoughts: 
  | 
    
          
 Short answer: we can use the .NET global tool, but the current approach (pulling the NuGet nupkg/platform zip) is more deterministic and works on the slimmer base image without extra fuss. 
 Also, pinning to a  If you think we should use the .NET SDK with the global tool, instead of what I have, I can give that a shot and see what I come up with. Thought?  | 
    
          
 @nmummau Ah, in that case, let's stick to the runtime only image! Wonder if we could move the DacFX/Sqlpackage version to the Directory.Build.Props file, and use that both here and in the .Dacpac tool?  | 
    
- paird with video demo: https://youtu.be/NaCNs0OOUbM - new build target PublishContainer will create a docker image that can be run to publish your project's dacpac to a target database via sqlpackage
- Move hardcoded DacFx version to Sdk.props - Reference $(DacFxVersion) in DacpacTool.csproj - Set SqlPackageVersion from DacFxVersion in Sdk.targets - Ensures SDK owns versioning and keeps DacFx and SqlPackage in sync
a434500    to
    3ea4a94      
    Compare
  
    
          
 @ErikEJ I experimented with a few approaches, and the commit 3ea4a94 is what I landed on. This does essentially what you were suggesting — it centralizes the version of DacFx so that it’s also the version of SqlPackage used in the publish process. From what I found digging through MSBuild behavior,  
 This effectively gives the SDK full ownership of the version number, without relying on the consumer to specify anything. This means the SDK is now the only place to bump when needed. This is probably the cleanest if we want SDK maintainers to fully own the DacFx/SqlPackage version, and to keep them in sync.  | 
    
The previous change attempted to use the $(DacFxVersion) property from the SDK to set the Microsoft.SqlServer.DacFx package version in DacpacTool.csproj. This didn’t work because DacpacTool.csproj does not import the custom SDK and therefore has no knowledge of properties defined in Sdk.props.
| 
           @ErikEJ to my previous comment... just kidding, that won't work!  The DaxFx version is now back directly in  I'm open to ideas, but I don't see a clear path to keeping the   | 
    
          
 @ErikEJ This is a great callout. Give me some time to come up with a solution here.  | 
    
| 
           @ErikEJ this is aside, but I wanted to show you a PR (with another guide video) I created for a different project where I implemented some Docker tooling for the purpose of deploying to a containerized database using a   | 
    
| 
           @nmummau I really see the value of having something like this in the box. Having the ability to just publish a database project as a container that when run would deploy it to a target database can help in a lot of scenario's. While I appreciate the effort you've put into this and I'm not entirely sure this is the right approach to implementing this feature. In its current form it seems that we're running   | 
    
Proposal to resolve issue #733
This PR provides a new build target "PublishContainer" which will create a docker image that contains both your project's dacpac and sqlpackage. This image can then be run to publish your dacpac to a target database.
Demo video for the PR feature: https://youtu.be/NaCNs0OOUbM
How I've tested this
I've been building and packing the SDK with
dotnet build -c Release && dotnet pack MSBuild.Sdk.SqlProj.csproj -c ReleaseI then copy the nupkg...
C:\code\MSBuild.Sdk.SqlProj\src\MSBuild.Sdk.SqlProj\bin\Release\MSBuild.Sdk.SqlProj.3.3.0-beta.16.g87c1e17ddb.nupkg...to a directory I use as a local NuGet feed
C:\LocalFeedThen in the project I want to use this, for me this is
c/code/wes/inventory/src🧱 Then build with the PublishContainer target
Due to the name of the project I'm using this with my resulting docker image is named
wes.inventory.database-publisher:releaseYou can look into the files within the image
results:
🎊 Finally you can run the image (git bash) to publish your dacpac to the target database
results