Skip to content

Fix tool projects so they don't remove apphosts when publishing (not packing) #49818

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

Merged
merged 7 commits into from
Jul 21, 2025

Conversation

baronfel
Copy link
Member

@baronfel baronfel commented Jul 16, 2025

Fixes #49799

The PackTool targets were unconditionally overwriting the UseAppHost and related properties at evaluation-time. This results in publishes of the projects not having AppHosts when they were expected to.

Instead of modifying the way that the projects are Published, we now use knowledge of the intent of the Publish to determine if the apphost/binary should be included in the generated tool package.

@Copilot Copilot AI review requested due to automatic review settings July 16, 2025 19:08
Copy link
Contributor

@Copilot 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 fixes a bug where tool projects were incorrectly removing apphosts during publish operations. The issue was that PackTool targets were unconditionally overwriting UseAppHost and related properties at evaluation time, causing published tool projects to lack AppHosts when they were expected.

  • Moved UseAppHost property modifications from evaluation-time to a target that runs early in the pack process
  • Added a test to verify that tool projects can publish with apphosts correctly
  • Relocated ToolCommandRunner property group to be set within the SetPackToolProperties target

Reviewed Changes

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

File Description
test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAToolProject.cs Added new test class to verify tool projects can publish with apphosts
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackTool.targets Moved UseAppHost and ToolCommandRunner property settings from evaluation-time to SetPackToolProperties target
Comments suppressed due to low confidence (2)

test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAToolProject.cs:35

  • The test should verify that the publish command executed successfully before checking for the apphost file. Consider adding .Should().Pass() or similar assertion after Execute().
            publishCommand.Execute();

@baronfel baronfel requested a review from a team July 16, 2025 19:08
@baronfel baronfel force-pushed the fix-tool-standalone-publishing branch from ca002d9 to f282413 Compare July 21, 2025 17:48
@baronfel baronfel merged commit d3d494e into dotnet:main Jul 21, 2025
27 checks passed
@baronfel baronfel deleted the fix-tool-standalone-publishing branch July 21, 2025 21:33
@baronfel
Copy link
Member Author

/backport to release/10.0.1xx-preview7

Copy link
Contributor

Started backporting to release/10.0.1xx-preview7: https://github.com/dotnet/sdk/actions/runs/16449036667

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.NET 10 preview 6 SDK did not generate exe/AppHost when pack as tool
3 participants