Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Minimal repro: unable to upgrade solution to 4.7.2 #895

Closed
wokwokwok1 opened this issue Oct 10, 2018 · 4 comments
Closed

Minimal repro: unable to upgrade solution to 4.7.2 #895

wokwokwok1 opened this issue Oct 10, 2018 · 4 comments

Comments

@wokwokwok1
Copy link

wokwokwok1 commented Oct 10, 2018

This relates to #481

Here is a minimal example that run successfully on .Net 4.6, and fails to run after upgrading to .Net 4.7.2
https://github.com/wokwokwok1/dotnet-46-project-upgrade-repro

You can view the various steps taken and the snapshot of the broken project as various phases through-out the upgrade attempt:

Re-targeting to 4.7.2

project snapshot:
https://github.com/wokwokwok1/dotnet-46-project-upgrade-repro/tree/net472_001_retarget

detail:
https://raw.githubusercontent.com/wokwokwok1/dotnet-46-project-upgrade-repro/net472_001_retarget/DemoApp/README.md

summary:

This does not work.

Compiler Error Message: CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

upgrading to package reference, as suggested in #481

project snapshot:
https://github.com/wokwokwok1/dotnet-46-project-upgrade-repro/tree/net472_002_migratePackages

detail:
https://raw.githubusercontent.com/wokwokwok1/dotnet-46-project-upgrade-repro/net472_002_migratePackages/DemoApp/README.md

summary:

This does not work.

Compiler Error Message: CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

attempting to manually pin dependency versions

project snapshot:
https://github.com/wokwokwok1/dotnet-46-project-upgrade-repro/tree/net472_003_manualDependencyResolution

detail:
https://raw.githubusercontent.com/wokwokwok1/dotnet-46-project-upgrade-repro/net472_003_manualDependencyResolution/DemoApp/README.md

summary:

This does not work, but a new error is seen.

Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

upgrading the project dependencies and applying 'magic' web.config fix

project snapshot:
https://github.com/wokwokwok1/dotnet-46-project-upgrade-repro/tree/net472_004_upgradeEverything

detail:
https://raw.githubusercontent.com/wokwokwok1/dotnet-46-project-upgrade-repro/net472_004_upgradeEverything/DemoApp/README.md

summary:

This resolved the issue and application now functions correctly.

The key to resolving this issue is from #542, where it was suggested to add assembly references directly to the web.config, like this:

 <system.web>
  <compilation debug="true" targetFramework="4.7.2">
    <assemblies>
      <add assembly="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"/>
    </assemblies>
  </compilation>
  <httpRuntime targetFramework="4.7.2"/>
  <httpModules/>
</system.web>

However, this was only a partial fix, and the complete fix required the addition of System.Runtime as well, like this:

<system.web>
  <compilation debug="true" targetFramework="4.7.2">
    <assemblies>
      <add assembly="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"/>
      <add assembly="System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
    </assemblies>
  </compilation>
  <httpRuntime targetFramework="4.7.2"/>
  <httpModules/>
</system.web>

This appears to full resolve the issue.

However, it is unclear why this is required, and is simply a random lucky guess that putting the dependency here will resolve the issue.

I leave this repro here, because I believe this is a bug.

@wokwokwok1
Copy link
Author

Note: This repro has ~170 dependencies and is based off of a legacy .csproj template from a real project; however, it is extremely difficult to generate a reproducible failure condition from a 'fresh' branch new project. I've done the best I can here, hopefully it is enough to help identify some kind of root cause.

@GSPP
Copy link

GSPP commented Oct 15, 2018

@GSPP
Copy link

GSPP commented Oct 15, 2018

it is extremely difficult to generate a reproducible failure condition

That might be because you have to delete the bin and obj folders:

Delete bin/obj folders (this often makes a difference because old assemblies are left there. VS clean does not remove them! This can make you believe that your solution works but it really just depends on old assemblies. I always have deleted these folders between tests to be sure.)

Fyi, my central list of workarounds has grown a bit with new ideas.

@wtgodbe
Copy link
Member

wtgodbe commented May 30, 2019

We have many issues related to this problem in the repro, I'm consolidating them into #936

@wtgodbe wtgodbe closed this as completed May 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants