-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Make multi-targeting constants local properties #2854
Comments
Passing global parameters on the command line (or just having conflicting environment variables by accident - such as Three behaviors of global properties seem to surprise people:
Now we could start a list with all the properties that you may want to pass via command line and try to find the best way to deal with each of them. My personal suggestion is to use custom properties wherever possible, like <DefineConstants Condition="'$(AdditionalDefineConstants)' != ''">$(DefineConstants );$(AdditionalDefineConstants)</DefineConstants> or adding a logical switch to the project ( But I also believe that some areas like |
I don't think the "inverse expectation makes" sense in the context of a multi-target build, though. Multi-target builds branch out / build the same project with in a slightly different way. I'd expect this to be stable, regardless of what gets passed in the command line. The inverse case would only work if the build author would specify an explicit |
It's a very tricky situation. |
Hmn, yes, it's a bit tricky since |
….8 (dotnet#2854) - Microsoft.DotNet.Cli.Runtime - 3.1.100-preview1.19462.8
Due to lack of recent activity, this issue has been labeled as 'stale'. It will be closed if no further activity occurs within 30 more days. Any new comment will remove the label. |
The
DefineConstants
properties for multi targeting builds are a bit confusing, since they are global and not local. This means that if there is a custom-p:DefineConstants=WHATEVER
on the command line, the multi targeting constants won't get added.What I'm asking here is to add a
TreatAsLocalProperty="DefineConstants"
to Microsoft.NET.Sdk.CSharp.targets, (and possibly other .target / .props files whereDefineConstants
gets updated), so that it works consistently when the consuming build modifies it via a PropertyGroup as well as via command line args.Let me elaborate. We have an old non-SDK style solution that we are gradually refactoring into AspNetCore and SDK-style. We were confronted with the build on the CI server failing miserably, because the target framework constants weren't defined during the build (e.g.
#if NET462
and#if NETCOREAPP2_2
were not working as expected). Turned out that we had some build configurations passing in a customDefineConstants
property. As this property is global, this line Microsoft.NET.Sdk.CSharp.targets does not work like a non-msbuild expert would would expect from reading it. It took us multiple days of digging through MSBuildBinLog, and collective WTFing, to finally figure out what's going on. Ironically, we did skim over the SDK.CSharp.targets, as it was seemingly not doing what it was supposed to do, but it looked OK at first glance.Adding to the confusion was the fact that if you add a custom
<PropertyGroup><DefineConstants>WHATEVER</DefineConstants></PropertyGroup>
, it gets concatenated, and not overridden.Ideally, it would behave the same way (concatenate the existing value) when it gets passed in via the command line arg.
The text was updated successfully, but these errors were encountered: