Any WPF project lower than net461 with System.ValueTuple cannot be compiled
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
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](https://github.com/dotnet/wpf/blob/master/README.md#reporting-security-issues-and-security-bugs).
**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`.
```xml
WinExe
net46
true
```
Necessary conditions:
1. Sdk version 3.1
1. use `Microsoft.NET.Sdk.WindowsDesktop` Sdk and `UseWpf`
1. targeting `net46`/`net452`/`net451`/`net45`
1. 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:
- [walterlv/Walterlv.Demo.CannotCompileWithValueTuple](https://github.com/walterlv/Walterlv.Demo.CannotCompileWithValueTuple)
Contributor guide
Assessment
This issue has not been assessed yet.