2

I have an ASP.NET Core 7.0 web project (C#) that I publish to an Azure App Service. It has been working fine, until a bad surprise happened.

I published the project, and it I was greeted with this error:

App: C:\home\site\wwwroot\MySuper.dll
Architecture: x86
Framework: 'Microsoft.WindowsDesktop.App', version '7.0.0' (x86)
.NET location: C:\Program Files (x86)\dotnet\

No frameworks were found.

Learn more:
https://aka.ms/dotnet/app-launch-failed

To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.WindowsDesktop.App&framework_version=7.0.0&arch=x86&rid=win-x86&os=win10
You must install or update .NET to run this application.

Now, this caused a bit of panic which I would prefer not to repeat. I ended up fixing the problem by restoring from the backup and have not published since this mistake. Of course, this means new code is not getting deployed to production.

So, before I publish the website again, I would like to be extremely sure that I know which framework(s) will be required.

By the way, I believe the problem was that another dev on the project had added EntityFramework, which it seems depends on 'Microsoft.WindowsDesktop.App', so the WindowsDesktop.App framework was added incidentally (but still blew up my app just the same).

I assume the necessary frameworks are stored somewhere in some file in the project folder. However, which file and where is it?

5
  • Not sure if it will help but the info is probably stored in the compiled dll/exe. Check stackoverflow.com/questions/325918/… Commented Jun 18, 2024 at 14:54
  • 1) .NET 7 reached end of life, so using it now isn't good for you. 2) People need to review your code base to learn why Microsoft.WindowsDesktop.App is being needed (maybe you misused certain types from the desktop API profile, which is a common mistake to make). 3) Entity Framework doesn't depend on the desktop profile and is widely used in web apps. So if you want to make this question answerable, some edits are required. Commented Jun 18, 2024 at 22:25
  • @LexLi It was this answer that made me think that EntityFramework referenced the WindowsDesktop.App framework. Regardless, my question is Where can I look to see which frameworks will be required when I publish this project? So, rather than posting a project with about 90 files in it, I would like to know how the deployment or runtime system knows which frameworks are required. This must be in some file somewhere, right? Commented Jun 19, 2024 at 1:10
  • There are quite a few indicators you can see from the project folder (project files, obj\project.assets.json, etc.), but I don't think there are articles from Microsoft Learn that cover your question. Commented Jun 19, 2024 at 1:17
  • @LexLi Even without formal documentation from Microsoft, I would hope that some dev out there would have figured this out. I was reading this and now I'm wondering if it is projectname.runtime.json that I am looking for? Commented Jun 19, 2024 at 1:29

1 Answer 1

0

After digging around, it seems like the information is in the file [projectname].runtimeconfig.json.

This file is under the [projectname]\bin\release

I see the old one looked like this:

{
  "runtimeOptions": {
    "tfm": "net7.0",
    "includedFrameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "7.0.16"
      },
      {
        "name": "Microsoft.WindowsDesktop.App",
        "version": "7.0.16"
      },
      {
        "name": "Microsoft.AspNetCore.App",
        "version": "7.0.16"
      }
    ],
    "configProperties": {
      "System.GC.Server": true,
      "System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
      "System.Reflection.NullabilityInfoContext.IsSupported": true,
      "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
    }
  }
}

Once I removed a few dependencies it now looks like this.

{
  "runtimeOptions": {
    "tfm": "net7.0",
    "frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "7.0.0"
      },
      {
        "name": "Microsoft.AspNetCore.App",
        "version": "7.0.0"
      }
    ],
    "configProperties": {
      "System.GC.Server": true,
      "System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
      "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
    }
  }
}

Most importantly, I could deploy without it saying I needed the Microsoft.WindowsDesktop.App framework installed on the server.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.