-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Description
Usage of double quotes "
inside #:
file-level directives are now a build-time error when running file-based apps (dotnet run app.cs
). dotnet/sdk#51119
Version
.NET 10 GA
Previous behavior
In .NET 10 RC2 and older .NET 10 previews, quotes in directives weren't blocked but they didn't do what you might think they did - i.e., they were only escaped as any other special character and passed to MSBuild, for example #:property Prop="my test"
would result in <Prop>"my test"</Prop>
.
New behavior
An error is reported if double quote "
is encountered in any file-level directive (the error is Directives currently cannot contain double quotes (").
).
Type of breaking change
- Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
- Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
- Behavioral change: Existing binaries might behave differently at run time.
Reason for change
This was changed so we can later add support for quoted directives (dotnet/sdk#49367) without a breaking change. This also improves the error recovery experience if users try to use quotes now thinking that's supported syntax.
Recommended action
You should not use quotes in #:
directives. If you really need to use a double quote (or another special character which currently isn't supported, like trailing whitespace), move the corresponding project metadata entry into a Directory.Build.props
file instead (it will be picked up by the file-based app) or convert the file-based app to a full project (via dotnet project convert
).
Feature area
SDK
Affected APIs
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status