-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fixes problems in WindowsDesktop SDK due to _TargetFrameworkVersionWithoutV being undefined sometimes #1707
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
Conversation
packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.props
Outdated
Show resolved
Hide resolved
packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.targets
Outdated
Show resolved
Hide resolved
packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.props
Outdated
Show resolved
Hide resolved
…etFrameworkVersion
…and fixup the default value in .targets file. Fixup an incorrect comment
12c6916
to
27ad4f5
Compare
… to Pbt.targets (used for dotnet/wpf builds only)
packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.props
Show resolved
Hide resolved
Why doesn't the existing |
@dsplaisted It does, but only in the cases where it's in the same condition. It doesn't apply when the is-defined check is applied at the ItemGroup level. |
I'm not the expert - @rainersigwald should confirm; it does, but in this way I think: <ItemGroup Condition="$(A) != '' And $(A) >= 3.0> <!-- works ok --->
<!-- You'd think that A != '' is a given, but it needs to be repeated here - and everywhere else involving an expression containing 'A' - otherwise it doesn't count -->
<Foo Condition="$(A) >= 4.0" Include="Bar" />
</ItemGroup> |
@vatsan-madhavan Assuming that's correct, would it not be simpler to just repeat the nonempty check in all the conditions that need to do comparisons on the version? |
That's not an approach particularly suited to maintainability IMO. It's simple to explain - yes, but it makes for worse readability, and sets up a system where small changes could incur complex and redundant conditions that should otherwise have been guaranteed by an enclosing scope already. It's somewhat arguable that such a change would even be even simpler. The proposed change effectively leaves all the conditional constructs intact (modulo small well defined transformations from |
Addresses #1651 - Invalid comparison in MSBuild's ignore-conditions mode in outer build of multitargeted project
This change ensures that the WindowsDesktop SDK never deals with undefined numeric values related to TFM.
This solution leverages the fact that
Items
are evaluated afterProperties
by MSBuild. See Comparing properties and items_TargetFrameworkVersionValue
- a new Property which is defined for exclusive use within the WindowsDesktop SDK, and which is intended to act as a proxy for_TargetFrameworkVersionWithoutV
- is defined inMicrosoft.NET.Sdk.WindowsDesktop.targets
afterTargetFrameworkVersionWithoutV
is guaranteed to be defined byMicrosoft.NET.Sdk.targets
.Even here, we ensure that a fallback default (
0.0
) is provided - guaranteeing that_TargetFrameworkVersionValue
will always be numeric.When the
Condition
s in the variousItems
inMicrosoft.NET.WindowsDesktop.props
are evaluated (which will happen strictly after allProperties
are evaluated - whether they appear in.props
or.targets
),_TargetFrameworkVersionValue
would have been (a) well-defined and (b) guaranteed to be a numeric value. This would in turn guarantee that errors of the kind"A numeric comparison was attempted on "$(_TargetFrameworkVersionValue)" that evaluates to "" instead of a number,"
will no longer appear in outer-builds or in any other context.PS: This is a fix for a regression introduced by #1027 (which shipped in Preview 6) as part of a set of fixes for improving multi-targeting experience, improved warnings and error messages during build, and improvements to project-system integration.