Skip to content
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

Allow sql projects to publish on build (PublishOnBuild). #286

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

AraHaan
Copy link

@AraHaan AraHaan commented Apr 30, 2022

This is triggered with a new msbuild property: PublishOnBuild.

This is triggered with a new msbuild property: PublishOnBuild.
@@ -302,4 +305,4 @@
</ItemGroup>
<Message Importance="Low" Text="CopyDacpacFiles: @(CopyDacpacFiles)" />
</Target>
</Project>
Copy link
Author

Choose a reason for hiding this comment

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

I blame GitHub for this line.

@AraHaan
Copy link
Author

AraHaan commented Apr 30, 2022

cc: @jmezach

@@ -258,6 +258,9 @@
<Delete Files="@(SqlArtifacts -> '$(TargetDir)%(Filename)%(Extension)')" />
</Target>

<!-- Allows a project to set to publish on build for their sql project (so they can deploy it on build that is if they want). -->
<Target Name="PublishSqlProject" BeforeTargets="CoreCompile" DependsOnTargets="Publish" Condition="'$(PublishOnBuild)' != 'False' And '$(DeployOnPublish)' != 'False'" />
Copy link
Member

Choose a reason for hiding this comment

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

Looking at the Condition here I get the feeling that it is an opt-out now, rather than an opt-in. To be honest I think this should be an opt-in.

Additionally it seems we have two separate properties that achieve the same thing?

Copy link
Author

@AraHaan AraHaan May 2, 2022

Choose a reason for hiding this comment

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

I could do it with only checking PublishOnBuild however it seems the Publish target runs when DeployOnPublish is true, while this might try to run the target it might not run if the user sets DeployOnPublish to false.

Copy link
Author

@AraHaan AraHaan May 2, 2022

Choose a reason for hiding this comment

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

Removed DeployOnPublish from this line. I wonder if it should also be removed from the publish target (and probably removed entirely).

@ErikEJ
Copy link
Collaborator

ErikEJ commented Nov 27, 2022

How is this different from

dotnet build

dotnet publish

especially since we support publish for local development only

@AraHaan
Copy link
Author

AraHaan commented Nov 27, 2022

It allows this to be published even if the sqlproj just happens to be part of a solution where publishing those projects might fail (because they depend on runtimes for which the only supported form of publish is FDD). Also, it acts as a shortcut for when you only want to run build on the entire solution and do not want to run publish on the entire solution as well (however you want to publish specific projects in it via cli).

@ErikEJ
Copy link
Collaborator

ErikEJ commented Nov 28, 2022

I do not understand this sentence: because they depend on runtimes for which the only supported form of publish is FDD - what is FDD?

Also, it acts as a shortcut for when you only want to run build on the entire solution and do not want to run publish on the entire solution as well (however you want to publish specific projects in it via cli).

How is that very different from just

dotnet build

dotnet publish

@AraHaan
Copy link
Author

AraHaan commented Nov 28, 2022

I do not understand this sentence: because they depend on runtimes for which the only supported form of publish is FDD - what is FDD?

Also, it acts as a shortcut for when you only want to run build on the entire solution and do not want to run publish on the entire solution as well (however you want to publish specific projects in it via cli).

How is that very different from just

dotnet build

dotnet publish

Framework dependent deployment (or FDD). I think dotnet publish now specifies an implicit RID since the release of the .NET 7 SDK which implies self-contained which can be breaking for some projects 💀.

Imran-imtiaz48

This comment was marked as duplicate.

Copy link

@Imran-imtiaz48 Imran-imtiaz48 left a comment

Choose a reason for hiding this comment

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

The old and new code snippets appear to serve similar purposes, focusing on publishing a SQL project during the build process based on certain conditions (PublishOnBuild and DeployOnPublish variables). Here’s a breakdown of the changes:

Simplification: The new code has removed the condition And '$(DeployOnPublish)' != 'False' from the PublishSqlProject target, simplifying the logic. This change suggests a streamlined approach, potentially reducing complexity and making the code easier to understand.

Functionality Retention: Both versions retain functionality related to publishing the .dacpac file to a target server after the build (Publish target).

Clarity: The removal of the additional condition in the PublishSqlProject target in the new code improves clarity by focusing directly on the PublishOnBuild condition, which may enhance maintainability and readability of the build script.

Conclusion:

The new code improves upon the old code by simplifying the condition in the PublishSqlProject target while retaining the essential functionality of publishing the .dacpac file. This change not only enhances clarity but also potentially reduces the risk of unintended logic errors, making the build script more robust and easier to manage.

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.

None yet

4 participants