Skip to content

File-level directives do not allow empty values #51077

@jjonescz

Description

@jjonescz

For example, I'd like to have a multi-targeting app like:

#:property OutputType=Library
#:property TargetFramework=
#:property TargetFrameworks=net9.0;net10.0
class C;

and hence I need to set TargetFramework to an empty value to reset the default. That result in this error however:

error: The property directive needs to have two parts separated by '=' like '#:property PropertyName=PropertyValue'.

The spec explicitly says that property values are allowed to be empty though:

A #:property is injected as <{0}>{1}</{0}> in a <PropertyGroup>.
It is an error if property does not have a value or if its name is empty (the value is allowed to be empty) or contains invalid characters.

There might be a similar problem with other directive kinds.

Metadata

Metadata

Assignees

Labels

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

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions