Manually change Framework in runtimeconfig.json?
See original GitHub issueHi, I’m working on upgrading our legacy Windows app to .NET 5.
In our legacy architecture, we used to have WinForms and WPF in many assemblies. At the same time, we had a headless version of our app that was running the same assemblies but detouring the UI code in runtime. That worked well on Linux under Mono.
In .NET 5, I see that as soon as I enable WPF and/or WinForms for the project, its target Framework changes to Microsoft.WindowsDesktop.App
. With this, the app cannot be run on Linux.
However, if I manually change the Framework in runtimeconfig.json to Microsoft.NETCore.App
, the app loads and our detour code seems to work as it did before.
I wonder if there’s an official/supported way to implement this scenario?
Thanks!
Issue Analytics
- State:
- Created 2 years ago
- Comments:20 (10 by maintainers)
Top Results From Across the Web
NET Runtime configuration settings
Learn how to configure the .NET runtime using configuration settings.
Read more >Deep-dive into .NET Core primitives, part 3: runtimeconfig. ...
NET Core applications contain a file named <something>.runtimeconfig.json . This file can be used to control a variety of options.
Read more >Select which .NET version to use
Learn how .NET automatically finds and chooses runtime versions for your program. Additionally, this article teaches you how to force a ...
Read more >How to build App without App.runtimeconfig.json?
I want to keep only App.exe and App.dll in my folder, what do I have to do to get rid of that App.runtimeconfig.json...
Read more >.NET Core Run-time Settings | Documentation
NET 5+ applications can use the "runtimeconfig.json" file, MSBuild properties and environment variables to set various run-time settings.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sfoslund Hi, sorry for the late reply. Yes, I’d say we’ve found a workaround. We have to manually patch
runtimeconfig.json
anddeps.json
to include dependency on mocked System.Windows.Forms.dll, but that should work for us for now.Please feel free to close this issue. I’ll reopen it shall I need further assistance 🙂 Thank you!
What if you needed to manually have the project use the runtimeconfig.json file manually created because the SDK incorrectly list the wrong framework last which is a problem because that runtimeconfig.json is itself part of another framework which then gets used in a project which results in the the host (fxr) to incorrectly look for hostpolicy in the wrong framework? I tried to work around it myself by adding the NETCore.App framework last manually to no success as the runtimeconfig.json file still generates with it listed first instead of last.