I am happy to see that a new version of Monogame has been released recently.
I updated the references for my project and unfortunately the build result is no longer executable just showing the following error on Windows Event Viewer:
Description: A .NET application failed.
Application: Game.exe
Path: C:PathToPublishGame.exe
Message: The required library C:PathToPublishhostfxr.dll does not support single-file apps.
You must install or update .NET to run this application.
The problem appears to occur if the project file contains any of the following:
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>true</PublishReadyToRun>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
The following is the smallest project file I tried:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<DisableWinExeOutputInference>true</DisableWinExeOutputInference>
<TargetFramework>net8.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<Platforms>x64</Platforms>
<!-- <PublishSingleFile>true</PublishSingleFile> -->
<SelfContained>false</SelfContained>
<!-- <RuntimeIdentifier>win-x64</RuntimeIdentifier> -->
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
<!-- <PublishReadyToRun>true</PublishReadyToRun> -->
<TieredCompilation>false</TieredCompilation>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MonoGame.Framework.WindowsDX" Version="3.8.2.1105" />
</ItemGroup>
</Project>
With:
- Visual Studio 2022(17.11.3)
- Monogame 3.8.2.1105
Although it does not appear to be strictly a Monogame issue.
But referencing a package that is referenced by a Monogame project file instead of Monogame itself does not cause this problem; referencing Monogame does.
Version 3.8.1.303 did not have this problem.
I would like the game to be built as a single file with ReadyToRun enabled. I also do not like extra files for other platforms as it is enough to run on Windows(x64).
1