Skip to content

Update dotnet run file.cs spec with new ignored directives syntax #47543

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 5 commits into from
Mar 18, 2025

Conversation

jjonescz
Copy link
Member

No description provided.

@jjonescz jjonescz added the Area-run-file Items related to the "dotnet run <file>" effort label Mar 13, 2025
@Copilot Copilot AI review requested due to automatic review settings March 13, 2025 12:02
@ghost ghost added the untriaged Request triage from a team member label Mar 13, 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 updates the dotnet run file documentation to reflect the new ignored directives syntax for project metadata. Key changes include updating the description of entry-point file checks, renaming and reformatting directive examples (using "#:" prefixes instead of "#"), and clarifying how these directives are translated into MSBuild project elements.

Comments suppressed due to low confidence (2)

documentation/general/dotnet-run-file.md:182

  • [nitpick] Consider using a single space between the directive and its value for consistency with other examples.
#:sdk      Microsoft.NET.Sdk.Web

documentation/general/dotnet-run-file.md:211

  • [nitpick] Revise the bullet point formatting to ensure consistency with the previous bullet, which could improve clarity.
- error on multiple `#:sdk` directives.

The C# language needs to be updated to ignore these directives (instead of failing the compilation).
See [the corresponding language proposal][pound].
The value must be separated from the name of the directive by white space and any leading and trailing white space is not considered part of the value.
The value of `#:sdk` is injected into `<Project Sdk="{0}">` as is.
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought you had the SDK not actually in the SDK= part but imported manually so you could overwrite certain bits? Is that changing?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, that's not changing, but I would consider that to be an internal implementation detail (and it should go away if/when NuGet fixes their targets to not fail on virtual project files). Having <Project Sdk="..."> ... </Project> should be equivalent to <Project> <Import props /> ... <Import targets /> </Project> (I believe the former is just "syntactic sugar" for the latter, but I might be wrong).

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough

See [the corresponding language proposal][pound].
The value must be separated from the name of the directive by white space and any leading and trailing white space is not considered part of the value.
The value of `#:sdk` is injected into `<Project Sdk="{0}">` as is.
The value of `#:property` is split by the first `=` and injected as `<{0}>{1}</{0}>` in a `<PropertyGroup>`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you pass multiple like:
#property foo=fooV;bar=barV
etc.?

Copy link
Member Author

Choose a reason for hiding this comment

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

You can pass multiple like

#:property foo=fooV
#:property bar=barV

Copy link
Contributor

Choose a reason for hiding this comment

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

That's reasonable. I'm a bit split as to whether I think it's best to leave it like that or also permit the #property foo=fooV;bar=barV syntax. On the one hand, MSBuild (from the command line) supports either; on the other hand, I don't think that enables anything new, and this syntax is more similar to C# code, which feels appropriate. I think I'm happy with this.

```

The C# language needs to be updated to ignore these directives (instead of failing the compilation).
See [the corresponding language proposal][pound].
The value must be separated from the name of the directive by white space and any leading and trailing white space is not considered part of the value.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm definitely in favor of the package directive. I'm ok with the others, but I want to make sure that we have a clear end point. I don't mind adding things like this as they become necessary, but at some point, we should say "you seem to want a csproj without the csproj. Can you just use a csproj?"

@jjonescz jjonescz merged commit d1363e0 into dotnet:main Mar 18, 2025
8 checks passed
@jjonescz jjonescz deleted the sprint-doc-02 branch March 18, 2025 08:13
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 documentation untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants