Skip to content

Any WPF project lower than net461 with System.ValueTuple cannot be compiled #2320

Open

Description

@walterlv
  • .NET Core Version (❌=break, ✔️=work):
    • ✔️ 3.1.401
    • ❌ 3.1.400
    • ✔️ 3.1.302 3.1.106
    • ✔️ 3.1.301 3.1.105
    • ✔️ 3.1.300 3.1.202 3.1.104
    • ✔️ 3.1.201 3.1.103
    • ✔️ 3.1.200 3.1.102
    • ❌ 3.1.101
    • ❌ 3.1.100
    • ✔️ 3.0.103
  • Windows version: 10.0.18363.535 (1909)
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
  • Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)?: No
  • Security issues and bugs should be reported privately, learn more via our responsible disclosure guidelines.

Problem description:

If a WPF project uses Microsoft.NET.Sdk.WindowsDesktop as its Sdk, and targets lower than net461, then it can never be compiled when referencing System.ValueTuple.

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net46</TargetFramework>
    <UseWPF>true</UseWPF>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.ValueTuple" Version="4.5.0" />
  </ItemGroup>

</Project>

Necessary conditions:

  1. Sdk version 3.1
  2. use Microsoft.NET.Sdk.WindowsDesktop Sdk and UseWpf
  3. targeting net46/net452/net451/net45
  4. Package reference the System.ValueTuple

This issue is introduced in 3.1 and everything works fine in 3.0.

Actual behavior:

Error MC1000 Unkown build error “Could not find assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. Either explicitly load this assembly using a method such as LoadFromAssemblyPath() or use a MetadataAssemblyResolver that returns a valid assembly.” Walterlv.Demo.CannotCompileWithValueTuple C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets 225

Expected behavior:

The project should be compiled correctly.

Minimal repro:

  1. Create a new WPF project via the Visual Studio WPF App (.NET Core) template;
  2. Edit the csproj file to targeting net46 and reference System.ValueTuple;
  3. Compile this project.

You can view the minimal project here:

Activity

  1. vatsan-madhavan commented on Dec 16, 2019

    @vatsan-madhavan
    Member

    Probably a facet of #2274; If I'm correct about it, this is being fixed by dotnet/runtime#730 in an upcoming servicing release.

  2. added
    issue-type-tracking-external
    on Dec 17, 2019
  3. added this to the 3.1.2 milestone on Dec 17, 2019
  4. lindexi commented on Feb 5, 2020

    @lindexi
    Member

    How to fix?

    Add the global.json file and add the code

    {
        "sdk": 
        {
            "version": "3.0.102"
        }
    }
    

    Goto https://dotnet.microsoft.com/download/dotnet-core and download install the dotnet core 3.0.102

  5. lindexi commented on Feb 5, 2020

    @lindexi
    Member

    @vatsan-madhavan I think this issues can be closed. @walterlv

  6. weltkante commented on Feb 5, 2020

    @weltkante

    How to fix?

    @lindexi you are downgrading not fixing the problem in 3.1 so this is just a workaround, if OP needs features from 3.1 this won't work for him, so it is not a general solution

  7. walterlv commented on Feb 5, 2020

    @walterlv
    ContributorAuthor

    @lindexi @weltkante Just wait for the 3.1.2

  8. vatsan-madhavan commented on Feb 5, 2020

    @vatsan-madhavan
    Member

    Just wait for the 3.1.2

    …which should be out in a week (assuming nothing happens to upset that schedule 😉 )

  9. GeertvanHorrik commented on Feb 19, 2020

    @GeertvanHorrik

    Note that this has not been fixed with 3.1.2. See #2274 for all the details.

  10. lindexi commented on Mar 2, 2020

    @lindexi
    Member

    @GeertvanHorrik I find the 3.1.102 published.

  11. GeertvanHorrik commented on Mar 25, 2020

    @GeertvanHorrik

    I can confirm this has been fixed in 3.1.103, great work, thanks!

  12. walterlv commented on May 6, 2020

    @walterlv
    ContributorAuthor

    Yes! This issue has been fixed since 3.1.103.

  13. MatthewSteeples commented on Aug 6, 2020

    @MatthewSteeples

    This looks to have regressed with 3.1.400 (16.7 release)

  14. walterlv commented on Aug 10, 2020

    @walterlv
    ContributorAuthor

    @MatthewSteeples Yes! This issue resurrects with 3.1.400 (16.7 release).

    What makes worse is that the embedded .NET Core version is newer than the .NET Core download page version here so that we cannot uninstall it to fix this issue temporarily.

    unable to uninstall

    The global.json still works but this makes projects unable to be compiled (via CI) a few months later, just like what I meet after this issue first occurred last year.

    Note: This update (3.1.400) introduces two issues to breaks my project compilation. This one and another https://github.com/dotnet/sdk/issues/12842 .

  15. lindexi commented on Aug 10, 2020

    @lindexi
    Member

    Thank you @walterlv

    It is break

  16. removed this from the 3.1.2 milestone on Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue-type-tracking-external

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions