Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Martin Griffiths 826 posts 1269 karma points c-trib
    Nov 09, 2022 @ 16:23
    Martin Griffiths
    0

    .net 6 & 7 build/runtime pains

    Apologies for this not being massively Umbraco specific, but i've just installed the final .net7 SDK along with a Visual Studio upgrade and now seem to be having some problems....

    Upon re-opening my .net 6/Umbraco 10 project I can no longer use dotnet watch run and get the following error:

    Unhandled exception. System.IO.FileNotFoundException: Could not find file or assembly 'System.Runtime, Version=7.0.0.0.

    So, two things. 1. I'm not using .net7 in this project and 2. I have .net 7 installed and it's complaining I don't, but I guess it's because the project targets .net 6.

    If I use dotnet build and dotnet build run....all is good! Any help much appreciated.

  • Anders Bjerner 487 posts 2990 karma points MVP 8x admin c-trib
    Nov 09, 2022 @ 21:40
    Anders Bjerner
    100

    Hi Martin

    This appears to be an issue with the .NET SDK. You can see an issue for it here: https://github.com/dotnet/sdk/issues/28942

    For now, a solution could be adding a global.json file at the root of your project with the following content:

    {
        "sdk": {
            "version": "6.0.403"
        }
    }
    

    This tells .NET to use a specific SDK rather than the newest. I think 6.0.403 is the newest version of .NET 6, but in my case, mine was a bit older. If you don't have the specified version, dotnet watch will result in an error but also list of versions that you do have installed.

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Nov 09, 2022 @ 22:21
    Martin Griffiths
    0

    Anders you star!

    This had me scratching my head all afternoon, even after intense googling!

    Thank you!

    Martin

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Nov 10, 2022 @ 10:16
    Sebastiaan Janssen
    0

    To make that global.json less version-specific you can do:

    {
      "sdk": {
        "allowPrerelease": false,
        "version": "6.0.0",
        "rollForward": "latestMinor"
      }
    }
    

    So that would pick whatever the newest 6.x is installed on the machine.

    Please do use 6.0.403! It fixes a nasty bug with System.Globalization.AppLocalIcu which Umbraco uses (ps. the advertised .NET version number for that is 6.0.11, I don't know why the SDK / Core have a different version number).

Please Sign in or register to post replies

Write your reply to:

Draft