Skip to content

Conversation

jjonescz
Copy link
Member

Resolves #49369.

@jjonescz jjonescz added the Area-run-file Items related to the "dotnet run <file>" effort label Aug 11, 2025
@jjonescz jjonescz marked this pull request as ready for review August 11, 2025 19:11
@Copilot Copilot AI review requested due to automatic review settings August 11, 2025 19:11
@jjonescz jjonescz requested a review from a team as a code owner August 11, 2025 19:11
@jjonescz jjonescz requested a review from a team August 11, 2025 19:11
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 implements support for dotnet pack file.cs to enable packing file-based programs directly from C# source files. The change allows users to create NuGet packages from standalone C# files without requiring a traditional project file structure.

Key changes:

  • Modified the PackCommand to detect and handle file-based programs using the virtual project building infrastructure
  • Updated command completion descriptions to include C# files as valid inputs
  • Added test coverage for the new functionality

Reviewed Changes

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

Show a summary per file
File Description
src/Cli/dotnet/Commands/Pack/PackCommand.cs Refactored to use CommandFactory pattern and support file-based programs through VirtualProjectBuildingCommand
src/Cli/dotnet/Commands/Pack/PackCommandParser.cs Updated argument name and description to include C# files as valid inputs
src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs Added PackageOutputPath property and updated runtime config logic to exclude Pack target
test/dotnet.Tests/CommandTests/Run/RunFileTests.cs Added comprehensive test for pack functionality and updated virtual project templates
test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetPackInvocation.cs Fixed cast to handle new return type from PackCommand.FromArgs
documentation/general/dotnet-run-file.md Updated documentation to reflect pack support and clarify behavior
test/dotnet.Tests/CompletionTests/snapshots/zsh/DotnetCliSnapshotTests.VerifyCompletions.verified.zsh Updated completion description to include C# files
Comments suppressed due to low confidence (1)

@jjonescz jjonescz requested a review from 333fred August 15, 2025 10:23
@RikkiGibson RikkiGibson removed their request for review August 15, 2025 21:47
@RikkiGibson
Copy link
Member

Removing my assignment since I speculate Fred and Chris's sign off will be enough. Let me know if I misunderstood something. Thanks

@jjonescz
Copy link
Member Author

@333fred for another look, thanks

@jjonescz jjonescz changed the base branch from main to release/10.0.1xx August 22, 2025 10:09
@jjonescz
Copy link
Member Author

Setting both PublishAot=true and PackAsTool=true by default does not currently seem to be possible - #50435.

Hence I've reverted the last commit and I plan to merge this without the PackAsTool=true default for now.

@jjonescz jjonescz merged commit df34bde into dotnet:release/10.0.1xx Aug 22, 2025
27 checks passed
@jjonescz jjonescz deleted the sprint-pack branch August 22, 2025 16:05
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.

Support packing file-based apps
7 participants