Skip to content

Updating to 16.4 from 16.3.x causes build issues with WPF project file. #2274

Closed

Description

@simon-jefferies

When building a WPF project the following error is shown, this built fine in the last 16.3.x version that was released.

C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets(225,9): error MC1000: Unknown build error, 'Could not find assembly 'mscorlib, 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.'

The project file:

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

  <PropertyGroup>
    <OutputType>Library</OutputType>
    <TargetFramework>net461</TargetFramework>
    <UseWPF>true</UseWPF>
    <Platforms>x86</Platforms>
    <GeneratePackageOnBuild>false</GeneratePackageOnBuild>
    <Version>1.0.0</Version>
    <Description></Description>
    <FileVersion>1.0.0.0</FileVersion>
    <AssemblyVersion>1.0.0.0</AssemblyVersion>
    <ApplicationIcon />
    <StartupObject />
  </PropertyGroup>

</Project>

Activity

  1. zplan commented on Dec 4, 2019

    @zplan

    Same issue here

    <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> <PropertyGroup> <TargetFramework>net472</TargetFramework> <UseWPF>true</UseWPF> <FileVersion>0.0.0.9999</FileVersion> <AssemblyVersion>0.0.0.9999</AssemblyVersion> </PropertyGroup>

    Workaround:
    Because only sdk 3.1.100 is installed after the update, I installed "dotnet-sdk-3.0.101-win-x64" and added a global.json with 3.0.101 to the project root. Now at least it compiles again (but with 3.0)

  2. simon-jefferies commented on Dec 4, 2019

    @simon-jefferies
    Author

    Yes i added the following global.json alongside my solution:

    {
        "sdk": {
          "version": "3.0.100"
        }
      }
    
  3. zplan commented on Dec 4, 2019

    @zplan

    But this is hopefully not the solution we have to accept...

  4. vatsan-madhavan commented on Dec 4, 2019

    @vatsan-madhavan
    Member

    <TargetFramework>net461</TargetFramework>
    <TargetFramework>net472</TargetFramework>

    C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets(225,9): error MC1000: Unknown build error, 'Could not find assembly 'mscorlib, 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.'

    Microsoft.WinFX.targets(225,9) is MarkupCompilePass1; When building a project for TargetFrameowrk=net472, it usually resolves mscorlib to a path like this:

    Input: Assembly Reference file: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.7.2\mscorlib.dll'.

    @olivegamestudio, @zplan, are you sure that .NET 4.6.1 and .NET 4.7.2 targeting packs are installed for you respectively?

    image

  5. vatsan-madhavan commented on Dec 4, 2019

    @vatsan-madhavan
    Member

    Because only sdk 3.1.100 is installed after the update, I installed "dotnet-sdk-3.0.101-win-x64" and added a global.json with 3.0.101 to the project root

    @livarcocc, @nguerrera, @chabiss, is it expected that 3.0.100 or 3.0.101 SDK vanishes when upgrading from Dev16.3.x --> Dev16.4?

  6. simon-jefferies commented on Dec 4, 2019

    @simon-jefferies
    Author

    Yes double-checked. When I change my target to 471 it compiles okay. Seems that the latest update has made that the minimum .NET version? Unfortunately, I can't target 471 and need 461. But this all worked under the last 16.3 update, it's only broke since updating to 16.4.

  7. nguerrera commented on Dec 4, 2019

    @nguerrera

    Yes, beginning with VS 16.3, VS will only "root" the one SDK it comes with. If VS installed an SDK and you upgrade to a VS that brings a newer SDK, it will remove the older SDK and add the newer one. There is ref counting so that if you install an SDK standalone, it will never be uninstalled by VS. VS gets one ref count and the standalone install gets another. If you have scenarios where you need multiple SDKs, you have to install the other ones standalone.

    This came after a TON of feedback against leaving SDKs behind from VS upgrades.

    I am advocating that the global.json default policy should allow roll forward to any newer version by default. You now have control over the roll forward, but the default is very restrictive and will only roll across the xx in A.B.Cxx if the matching version is not found.

    cc @KathleenDollard

  8. njannink commented on Dec 4, 2019

    @njannink

    Im having the same issue. This is currently blocking my work. I checked VS Installer and I have all required targetting packs and NetCore SDK 3.1

    What is the proposed solution / workaround or is it possible to rollback a Visual Studio update?

  9. nguerrera commented on Dec 4, 2019

    @nguerrera

    Installing the 3.0.101 SDK and using global.json to force it, is a viable workaround that does not require rolling back all of VS, while we look at the issue and work on fixing it.

  10. nguerrera commented on Dec 5, 2019

    @nguerrera

    It would be very helpful if someone who is hitting this could provide a binlog with the failure.

  11. zplan commented on Dec 6, 2019

    @zplan

    See the attached project.

    I could reproduce it with an almost plain WPF project and a reference to Unit v4.0.1. I know, this is a very old version but for legacy reason I have to stick to this version. Before the VS 16.4 update it was no problem to build the project with this reference.

    <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
      <PropertyGroup>
        <TargetFramework>net472</TargetFramework>
        <RootNamespace>Test</RootNamespace>
        <AssemblyName>Test</AssemblyName>
        <OutputType>WinExe</OutputType>
        <UseWPF>true</UseWPF>
        <FileVersion>0.0.0.9999</FileVersion>
        <AssemblyVersion>0.0.0.9999</AssemblyVersion>
      </PropertyGroup>
    
      <ItemGroup>
        <PackageReference Include="Unity" Version="4.0.1" />
      </ItemGroup>
    
    </Project>

    project.zip

  12. pieterphilippaerts commented on Dec 6, 2019

    @pieterphilippaerts

    I had the same problem too. I fixed it, as mentioned above, by installing the .NET Core 3.0.101 SDK and adding a global.json file. However, why do I have to install a .NET Core SDK if my project isn't targetting .NET core at all?

  13. added
    issue-type-tracking-external
    on Dec 12, 2019
  14. added this to the 3.1.2 milestone on Dec 12, 2019
  15. siegfriedpammer commented on Dec 13, 2019

    @siegfriedpammer

    @pieterphilippaerts

    However, why do I have to install a .NET Core SDK if my project isn't targetting .NET core at all?

    From my experience, that's because you are using the new "SDK-style" projects, which by definition use the .NET Core SDK/build system. When using the old ".NET Framework" project files, it will work fine.

  16. 44 remaining items

  17. vatsan-madhavan commented on Mar 20, 2020

    @vatsan-madhavan
    Member

    Can you shed some light on the ETA or is it too early to tell?

    @GeertvanHorrik as things stand, we are hoping for for 24/03/2020 (assuming that factors outside our control do not change this plan, of course 😄).

  18. bclothier commented on Mar 24, 2020

    @bclothier

    To clarify, as a part of Visual Studio 16.5 update?

  19. weltkante commented on Mar 24, 2020

    @weltkante

    .NET Core Runtime/SDK installers are also available separately, so you don't have to wait for a VS update if you don't want to. (Assuming the fix "being in 3.1.3" means its fixed in the SDK and not in VS)

  20. vatsan-madhavan commented on Mar 25, 2020

    @vatsan-madhavan
    Member
  21. GeertvanHorrik commented on Mar 25, 2020

    @GeertvanHorrik

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

  22. vatsan-madhavan commented on Apr 14, 2020

    @vatsan-madhavan
    Member

    Closing as this is now fixed.

  23. Kerfluffel commented on May 28, 2020

    @Kerfluffel

    Using Visual Studio 16.6, migrating WPF app to target .netcore3.1(.300). Cannot compile with error below:

    Error MC1000 Unknown build error, 'Could not find assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Either explicitly load this assembly using a method such as LoadFromAssemblyPath() or use a MetadataAssemblyResolver that returns a valid assembly.' MyApp C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets 225

    Is this the same issue? I seem to have most current .netcore (3.1.300) and VS16.6.0.

    Any suggestions how to get compiled?

  24. nirzaf commented on May 29, 2020

    @nirzaf

    Still, No Fixes Microsoft is working on this issue slower than windows 10, Better you migrate to Java

  25. weltkante commented on May 29, 2020

    @weltkante

    @Kerfluffel no this is not the same issue, I suspect System.Web is not part of .NET Core (probably discontinued), so this error would be expected.

  26. MatthewSteeples commented on Aug 6, 2020

    @MatthewSteeples

    This looks to have regressed with 3.1.400 (16.7 release)

  27. jnm2 commented on Aug 7, 2020

    @jnm2

    Same here. All WPF projects that reference DevExpress WPF libraries started failing to build after updating from 3.1.302 to 3.1.400:

    C:\Program Files\dotnet\sdk\3.1.400\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets(225,9): error
    MC1000: Unknown build error, 'Could not find assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec
    85d7bea7798e'. Either explicitly load this assembly using a method such as LoadFromAssemblyPath() or use a MetadataAsse
    mblyResolver that returns a valid assembly.'

  28. jnm2 commented on Aug 10, 2020

    @jnm2

    An open issue where this is being tracked is #3312.

  29. ghost locked as resolved and limited conversation to collaborators on Apr 13, 2022
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions