Allow duplicate #:project and #:ref directives#54035
Merged
jjonescz merged 4 commits intodotnet:release/10.0.4xxfrom Apr 24, 2026
Merged
Allow duplicate #:project and #:ref directives#54035jjonescz merged 4 commits intodotnet:release/10.0.4xxfrom
jjonescz merged 4 commits intodotnet:release/10.0.4xxfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates file-based program directive handling to permit duplicate #:project and #:ref directives, aligning tests and docs with the new behavior for project/ref references.
Changes:
- Allow duplicate
#:projectand#:refdirectives during directive parsing (no duplicate error reported). - Update run-file tests to expect successful execution when these directives are repeated.
- Update documentation to describe the new duplicate-directive exception for
#:projectand#:ref.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/dotnet.Tests/CommandTests/Run/RunFileTests.cs | Updates existing tests to expect success when #:project/#:ref directives are duplicated. |
| src/Cli/Microsoft.DotNet.FileBasedPrograms/FileLevelDirectiveHelpers.cs | Changes duplicate-directive validation logic to exempt #:project and #:ref. |
| documentation/general/dotnet-run-file.md | Documents the new duplicate-directive rule (with exceptions for #:project/#:ref). |
RikkiGibson
approved these changes
Apr 22, 2026
333fred
approved these changes
Apr 22, 2026
| We disallow duplicate `#:` directives to allow us design some deduplication mechanism in the future. | ||
| We disallow duplicate `#:` directives (except `#:project` and `#:ref`) to allow us to design some deduplication mechanism in the future. | ||
| Specifically, directives are considered duplicate if their type and name (case insensitive) are equal. | ||
| `#:project` and `#:ref` duplicates are allowed because MSBuild handles deduplication of project references naturally. |
Member
There was a problem hiding this comment.
Maybe clarify that multiple <ProjectReference> directives are allowed? The current wording says that indirectly, but it could be more explicit about it.
MiYanni
approved these changes
Apr 24, 2026
This was referenced Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #51139.