You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building a project by setting DefineConstants from the command line, the NET***_OR_GREATER symbols are defined, but NET***, NET, and NETCOREAPP are not.
To Reproduce
Build a .NET 9 library with the following file with dotnet build -f net9.0 /p:DefineConstants=HELLOWORLD:
net-sdk-repro failed with 1 error(s) (2,9s)
C:\Users\teo\code\ephemeral\net-sdk-repro\Class1.cs(8,31): error CS0103: The name '_myString' does not exist in the current context
Build failed with 1 error(s) in 3,9s
Further technical details
I'm using .NET SDK 9.0.101.
After some investigation, the NET*** constants are defined here, and the NET***_OR_GREATER constants here. The former has no effect because because we are reassigning a global property, but the latter succeeds because we can reassign global properties inside a Target?
One way of fixing this is to update the NET*** constant definition to use the _ImplicitDefineConstant item, and move it to BeforeCommon.targets, which will also deduplicate the logic from C#, F# and VB. If that sounds good I can open a PR.
The text was updated successfully, but these errors were encountered:
Good observation - this is one of a category of problems that we have due to the duplicate use of global properties. Your proposal sounds good to me, but there are a number of other places that the Roslyn compiler especially is called (Razor and WPF are the main ones I'm thinking of) so we'd need to coordinate/sequence the change.
Describe the bug
When building a project by setting
DefineConstants
from the command line, theNET***_OR_GREATER
symbols are defined, butNET***
,NET
, andNETCOREAPP
are not.To Reproduce
Build a .NET 9 library with the following file with
dotnet build -f net9.0 /p:DefineConstants=HELLOWORLD
:Exceptions (if any)
Further technical details
I'm using .NET SDK 9.0.101.
After some investigation, the
NET***
constants are defined here, and theNET***_OR_GREATER
constants here. The former has no effect because because we are reassigning a global property, but the latter succeeds because we can reassign global properties inside aTarget
?One way of fixing this is to update the
NET***
constant definition to use the_ImplicitDefineConstant
item, and move it toBeforeCommon.targets
, which will also deduplicate the logic from C#, F# and VB. If that sounds good I can open a PR.The text was updated successfully, but these errors were encountered: