Skip to content

Invalid comparison in MSBuild's ignore-conditions mode in outer build of multitargeted project #1651

@rainersigwald

Description

@rainersigwald

Originally reported by @batzen at https://github.com/dotnet/cli/issues/12267#issuecomment-522067627

  • .NET Core Version: 3.0.100-preview9-013744
  • Windows version: 10.0.18362.239
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: No

Problem description:

A multitargeted WPF project throws an exception when evaluated in MSBuild's "ignore conditions" mode, which is often used in design-time scenarios.

This is because while the conditions here are sufficient at build time for real projects, when conditions are ignored MSBuild thinks the project is invalid (dotnet/msbuild#4622)

<ItemGroup Condition="('$(TargetFrameworkIdentifier)' == '.NETFramework') And ('$(_TargetFrameworkVersionWithoutV)' != '') And
('$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)')">
<!--
The following 3 _WpfCommonNetFxReference items normally require Condition="'$(_TargetFrameworkVersionWithoutV)' >= '3.0'", since
they are supported on .NET Framework 3.0 and above.
This condition is implicitly satisfied by '$(_TargetFrameworkVersionWithoutV)' >= '$(_WindowsDesktopSdkTargetFrameworkVersionFloor)'
in the outer ItemGroup
-->
<_WpfCommonNetFxReference Include="WindowsBase" />
<_WpfCommonNetFxReference Include="PresentationCore" />
<_WpfCommonNetFxReference Include="PresentationFramework" />
<_WpfCommonNetFxReference Include="System.Xaml" Condition="'$(_TargetFrameworkVersionWithoutV)' >= '4.0'">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</_WpfCommonNetFxReference>
<_WpfCommonNetFxReference Include="UIAutomationClient" Condition="'$(_TargetFrameworkVersionWithoutV)' >= '4.0'" />
<_WpfCommonNetFxReference Include="UIAutomationClientSideProviders" Condition="'$(_TargetFrameworkVersionWithoutV)' >= '4.0'" />
<_WpfCommonNetFxReference Include="UIAutomationProvider" Condition="'$(_TargetFrameworkVersionWithoutV)' >= '4.0'" />
<_WpfCommonNetFxReference Include="UIAutomationTypes" Condition="'$(_TargetFrameworkVersionWithoutV)' >= '4.0'" />
<_WpfCommonNetFxReference Include="System.Windows.Controls.Ribbon" Condition="'$(_TargetFrameworkVersionWithoutV)' >= '4.5'" />
</ItemGroup>

Actual behavior:

error: A numeric comparison was attempted on "$(_TargetFrameworkVersionWithoutV)" that evaluates to "" instead of a number, in condition "'$(_TargetFrameworkVersionWithoutV)' >= '4.5'".  c:\program files\dotnet\sdk\3.0.100-preview8-013656\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.NET.Sdk.WindowsDesktop.props

Expected behavior:

No error

Minimal repro:

  • dotnet new wpf
  • Replace TargetFramework with <TargetFrameworks>netcoreapp3.0;net45</TargetFrameworks>
  • dotnet restore
  • dotnet list package

Metadata

Metadata

Labels

BugProduct bug (most likely)ask-moderank20Rank: Priority/rank on a scale of (1..100)regressionstatus: This issue is a regression from a previous build or release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions