Skip to content

Make packtool targets light up only on pack #50445

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

Open
wants to merge 1 commit into
base: release/10.0.1xx
Choose a base branch
from

Conversation

baronfel
Copy link
Member

Fixes #50435

The PackTool.targets were modifying critical properties of the tool package project that impacted the way the tool would be published, not just packed.

To fix this, I looked at the data dependencies between the various properties and pushed them into a series of Targets that happen early on in tool packaging to ensure that tool projects can be published as normal, and the tool-specific modifications only ever light up on packaging-based Targets

@Copilot Copilot AI review requested due to automatic review settings August 22, 2025 22:21
@baronfel baronfel requested a review from a team as a code owner August 22, 2025 22:21
@baronfel baronfel changed the base branch from main to release/10.0.1xx August 22, 2025 22:21
@dotnet dotnet deleted a comment from github-actions bot Aug 22, 2025
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 an issue where PackTool.targets were incorrectly modifying properties that affected tool publishing behavior, not just packaging. The fix restructures the targets to ensure tool-specific modifications only activate during pack operations.

Key changes:

  • Moves tool-specific property modifications from global scope to pack-specific targets
  • Adds _IsPacking property to PackCommand and related test framework classes
  • Updates file-based program support to include dotnet pack functionality

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackTool.targets Restructures targets to move property modifications into pack-specific scope
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets Removes PackAsTool condition from runtime identifier inference
src/Cli/dotnet/Commands/Pack/PackCommand.cs Adds file-based program support and refactors command creation
test/Microsoft.NET.TestFramework/Commands/*.cs Adds _IsPacking and _IsPublishing properties to test commands
test/dotnet.Tests/CommandTests/Run/RunFileTests.cs Adds comprehensive tests for pack functionality with file-based programs
test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAToolProject.cs Adds regression test for normal publish behavior
eng/Version.Details.xml Updates Microsoft.Testing.Platform and MSTest package versions

@@ -51,28 +48,15 @@ NOTE: This file is imported from the following contexts, so be aware when writin
<_UserSpecifiedToolPackageRids Condition="'$(_UserSpecifiedToolPackageRids)' == ''">$(RuntimeIdentifiers)</_UserSpecifiedToolPackageRids>
<_HasRIDSpecificTools Condition=" '$(_UserSpecifiedToolPackageRids)' != '' ">true</_HasRIDSpecificTools>
<_HasRIDSpecificTools Condition="'$(_HasRIDSpecificTools)' == ''">false</_HasRIDSpecificTools>
<!-- unlike all of the other computed properties here, we _do_ want to mutate RuntimeIdentifiers here so that we ensure that the shims are included in restores -->
<RuntimeIdentifiers Condition="'$(PackAsToolShimRuntimeIdentifiers)' != ''">$(_UserSpecifiedToolPackageRids);$(PackAsToolShimRuntimeIdentifiers)</RuntimeIdentifiers>
Copy link
Preview

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

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

[nitpick] This property modification is in global scope but the comment on line 51 indicates it should mutate RuntimeIdentifiers. This creates inconsistency with the goal of moving modifications to pack-specific targets. Consider moving this to a pack-specific target if possible.

Suggested change
<RuntimeIdentifiers Condition="'$(PackAsToolShimRuntimeIdentifiers)' != ''">$(_UserSpecifiedToolPackageRids);$(PackAsToolShimRuntimeIdentifiers)</RuntimeIdentifiers>

Copilot uses AI. Check for mistakes.

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.

AOT publish doesn't work if PackAsTool is set (a regression)
1 participant