Description
- .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:
- Sdk version 3.1
- use
Microsoft.NET.Sdk.WindowsDesktopSdk andUseWpf - targeting
net46/net452/net451/net45 - 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:
- Create a new WPF project via the Visual Studio WPF App (.NET Core) template;
- Edit the csproj file to targeting net46 and reference
System.ValueTuple; - Compile this project.
You can view the minimal project here:
Activity
vatsan-madhavan commentedon Dec 16, 2019
Probably a facet of #2274; If I'm correct about it, this is being fixed by dotnet/runtime#730 in an upcoming servicing release.
lindexi commentedon Feb 5, 2020
How to fix?
Add the global.json file and add the code
Goto https://dotnet.microsoft.com/download/dotnet-core and download install the dotnet core 3.0.102
lindexi commentedon Feb 5, 2020
@vatsan-madhavan I think this issues can be closed. @walterlv
weltkante commentedon Feb 5, 2020
@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
walterlv commentedon Feb 5, 2020
@lindexi @weltkante Just wait for the 3.1.2
vatsan-madhavan commentedon Feb 5, 2020
…which should be out in a week (assuming nothing happens to upset that schedule 😉 )
GeertvanHorrik commentedon Feb 19, 2020
Note that this has not been fixed with 3.1.2. See #2274 for all the details.
lindexi commentedon Mar 2, 2020
@GeertvanHorrik I find the 3.1.102 published.
GeertvanHorrik commentedon Mar 25, 2020
I can confirm this has been fixed in 3.1.103, great work, thanks!
walterlv commentedon May 6, 2020
Yes! This issue has been fixed since 3.1.103.
MatthewSteeples commentedon Aug 6, 2020
This looks to have regressed with 3.1.400 (16.7 release)
walterlv commentedon Aug 10, 2020
@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.
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 .
lindexi commentedon Aug 10, 2020
Thank you @walterlv
It is break