Skip to content

Conversation

@chsienki
Copy link
Member

Fixes #49368

Copilot AI review requested due to automatic review settings June 13, 2025 17:50
@chsienki
Copy link
Member Author

@dotnet/run-file for reviews

@chsienki chsienki added the Area-run-file Items related to the "dotnet run <file>" effort label Jun 13, 2025
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 adds a flag to skip including runtime configuration items when publishing, addressing issue #49368.

  • Introduce includeRuntimeConfigInformation parameter to WriteProjectFile
  • Set the flag based on BuildTarget != "Publish" in CreateProjectRootElement
  • Wrap the runtimeconfig <ItemGroup> generation in a conditional

targetFilePath: EntryPointFileFullPath,
artifactsPath: GetArtifactsPath());
artifactsPath: GetArtifactsPath(),
includeRuntimeConfigInformation: BuildTarget != "Publish");
Copy link

Copilot AI Jun 13, 2025

Choose a reason for hiding this comment

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

Use a case-insensitive comparison when checking BuildTarget to avoid unexpected mismatches. For example: !string.Equals(BuildTarget, "Publish", StringComparison.OrdinalIgnoreCase).

Suggested change
includeRuntimeConfigInformation: BuildTarget != "Publish");
includeRuntimeConfigInformation: !string.Equals(BuildTarget, "Publish", StringComparison.OrdinalIgnoreCase));

Copilot uses AI. Check for mistakes.
targetFilePath: EntryPointFileFullPath,
artifactsPath: GetArtifactsPath());
artifactsPath: GetArtifactsPath(),
includeRuntimeConfigInformation: BuildTarget != "Publish");
Copy link

Copilot AI Jun 13, 2025

Choose a reason for hiding this comment

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

[nitpick] Extract the literal "Publish" into a named constant or enum to eliminate a magic string and improve maintainability.

Suggested change
includeRuntimeConfigInformation: BuildTarget != "Publish");
includeRuntimeConfigInformation: BuildTarget != BuildTargets.Publish);

Copilot uses AI. Check for mistakes.

var targetDirectory = Path.GetDirectoryName(targetFilePath) ?? "";
writer.WriteLine($"""
if (includeRuntimeConfigInformation)
Copy link

Copilot AI Jun 13, 2025

Choose a reason for hiding this comment

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

Add unit tests covering both paths of includeRuntimeConfigInformation (true and false) to verify the runtime config <ItemGroup> is correctly included or omitted. Use the Fact Skip parameter to reference issue #49368.

Copilot generated this review using guidance from repository custom instructions.
@baronfel baronfel merged commit 27ae645 into dotnet:main Jun 13, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-run-file Items related to the "dotnet run <file>" effort

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not set executing script directory when publishing

2 participants