Microsoft.WinFX.targets Unknown build error Could not find assembly 'mscorlib'
See original GitHub issue- .NET Core Version: Version: 3.1.301, Commit: 7feb845744
Base Path: C:\Program Files\dotnet\sdk\3.1.301
Host (useful for support): Version: 3.1.5, Commit: 65cd789777 - Windows version: Win 10 (1909) 10.0.18363
- Does the bug reproduce also in WPF for .NET Framework 4.8?: Not when creating a classic WPF full Framework project
- Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc…)? no,
dotnet build
fails (without VS being involved)
Problem description:
WPF core app doesn’t build when adding a direct <Reference .../>
to an old .Net 2.0 framework dll.
(Why would you do that? Expensive, proprietary dll from 3rd party, we can’t live without it, author has retired)
Actual behavior:
dotnet build
fails with
C:\Program Files\dotnet\sdk\3.1.301\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets(225,9):
error MC1000: Unknown build error, 'Could not find assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac'. Either explicitly load this assembly using a method such as LoadFromAssemblyPath() or use a MetadataAssemblyResolver that returns a valid assembly.' [D:\Downloads\DotnetWpfCoreProblem\DotnetWpfCoreProblem.csproj]
Expected behavior: It builds fine.
Minimal repro:
Create a new WPF core project: dotnet new wpf
which will target netcoreapp3.1
at the time of writing.
Add a library reference to an old .Net Framework 2.0 WinCE library. Something like
<Reference Include="SomethingOld" HintPath="SomethingOld.dll" />
Try to build. Unfortunately I can’t publish the proprietary dll here. It is built for .Net Framework 2 with WinCE compatibility.
Related Issues I found similar topics where the build failed with the same error (mscorlib not found), but they seem to be resolved. https://github.com/dotnet/wpf/issues/1451 https://github.com/dotnet/wpf/issues/2274
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (2 by maintainers)
Top GitHub Comments
@wldevries If you just updated Visual Studio you are more likely hitting this: https://github.com/dotnet/sdk/issues/12710
Switching the
TargetFramework
to net5.0 doesn’t make a difference. @ryalanms commented Please reactivate, if you see it again. but I cannot change the ticket status.