Skip to content

Conversation

@jmezach
Copy link
Member

@jmezach jmezach commented Jan 22, 2026

Hopefully this will make sure that using the Publish option in Visual Studio will still publish the database as we did in previous versions of MSBuild.Sdk.SqlProj (prior to 4.0.0).

fixes #849
fixes #851

Signed-off-by: Jonathan Mezach <jonathan.mezach@rr-wfm.com>
@ErikEJ
Copy link
Collaborator

ErikEJ commented Jan 22, 2026

@jmezach I tried this locally, publish does nothing - also maybe it should be "true" rather than "True" for consistency

Signed-off-by: Jonathan Mezach <jonathan.mezach@rr-wfm.com>
@jmezach
Copy link
Member Author

jmezach commented Jan 22, 2026

@ErikEJ I fixed the inconsistency, but I doubt that that is actually fixing something. Might need to get another binary log to figure that out though. But doing that from VS is a bit more involved, see https://github.com/dotnet/msbuild/blob/main/documentation/wiki/Providing-Binary-Logs.md#capturing-binary-logs-through-visual-studio.

@ErikEJ
Copy link
Collaborator

ErikEJ commented Jan 22, 2026

@jmezach Correct, the inconsistency fixed nothing, I will try to get a VS binary log

Signed-off-by: Jonathan Mezach <jonathan.mezach@rr-wfm.com>
@jmezach
Copy link
Member Author

jmezach commented Jan 23, 2026

@ErikEJ I made another change, can you gave that a shot? If that still doesn't work I might have to fire up a machine with Visual Studio installed :P

@ErikEJ
Copy link
Collaborator

ErikEJ commented Jan 23, 2026

Same issue:

Build started at 12:04...
1>------ Build started: Project: TestProject, Configuration: Release Any CPU ------
1>Using target framework net8.0 to run DacpacTool
1>TestProject -> C:\dev\GitHub\MsBuild.Sdk.SqlProj.Origin\test\TestProject\bin\Release\net8.0\TestProject.dacpac
2>------ Publish started: Project: TestProject, Configuration: Release Any CPU ------
2>Using target framework net8.0 to run DacpacTool
2>TestProject -> C:\dev\GitHub\MsBuild.Sdk.SqlProj.Origin\test\TestProject\bin\Release\net8.0\TestProject.dacpac
2>TestProject -> C:\dev\GitHub\MsBuild.Sdk.SqlProj.Origin\test\TestProject\bin\Release\net8.0\publish\
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 12:04 and took 02,843 seconds ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========
========== Publish completed at 12:04 and took 02,845 seconds ==========

@ErikEJ
Copy link
Collaborator

ErikEJ commented Jan 23, 2026

@jmezach I have sent a Windows binary log

@jmezach
Copy link
Member Author

jmezach commented Jan 27, 2026

@ErikEJ I've got a fix now that works with VS. Only thing I'm a bit on the fence about now is whether we should have dotnet publish (note: without explicitly saying /t:PublishContainer) default to doing nothing or actually publish a container. We can have it either way, just wondering what the most natural way of working would be.

@ErikEJ
Copy link
Collaborator

ErikEJ commented Jan 27, 2026

@jmezach Publish normally means prepare the deployment - "Publishes the application and its dependencies to a folder for deployment to a hosting system."

In our case, it is basically the same as build as far as I can tell. So probably do nothing ?

Add test project to solution
@ErikEJ
Copy link
Collaborator

ErikEJ commented Jan 27, 2026

@jmezach I will do some smoke testing again this evening

@ErikEJ
Copy link
Collaborator

ErikEJ commented Jan 28, 2026

@jmezach Confirmed that this works! 🥂

Copy link
Collaborator

@ErikEJ ErikEJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restores Visual Studio publish functionality for database projects by introducing a custom Publish target that conditionally includes the PublishDatabase target when building inside Visual Studio. Additionally, the solution file format is migrated from the classic .sln format to the newer .slnx XML format.

Changes:

  • Added a Publish target with configurable dependencies that includes PublishDatabase when executed from Visual Studio
  • Replaced the traditional .sln file with a new .slnx XML-based solution file
  • Modified PublishDependsOn property to control publish behavior in different contexts

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets Added Publish target and configured PublishDependsOn to restore database publishing in Visual Studio
MSBuild.Sdk.SqlProj.slnx New XML-based solution file with project and folder structure
MSBuild.Sdk.SqlProj.sln Removed classic solution file in favor of .slnx format

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jmezach
Copy link
Member Author

jmezach commented Jan 28, 2026

@jeffrosenberg Can you have a look at this as well?

@jmezach
Copy link
Member Author

jmezach commented Feb 2, 2026

@ErikEJ @jeffrosenberg Maybe we should just merge this?

@ErikEJ
Copy link
Collaborator

ErikEJ commented Feb 2, 2026

@jmezach agree

@jmezach jmezach merged commit c539e16 into master Feb 2, 2026
28 checks passed
@jmezach jmezach deleted the feature/fix-vs-publish branch February 2, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Housekeeping: migrate solution to .slnx Database publish in VS no longer works with 4.0.0

3 participants