Announcing New White Paper: Transforming DBL Applications with Distributed Computing
October 29, 2024We wanted to make everyone aware of a situation involving Visual Studio upgrades that could potentially cause an unexpected runtime error for Synergy .NET applications that are deployed using the PublishSingleFile feature. This issue was recently reported to Microsoft: Single file self-contained failing after upgrading Visual Studio to 17.12.0. It affects .NET 9.0.100 but will be fixed for 9.0.200 and later.
One of our C# applications uses the PublishSingleFile feature as a post-build step within the project along with the no-build option. This approach allows MSBuild to build the application before the publish organizes it into a single file for deployment. Recently, after we upgraded to Visual Studio 17.12 (which also includes .NET 9), when we ran that application after rebuilding it, we encountered the following error:
A fatal error was encountered. The library ‘hostpolicy.dll’ required to execute the application was not found in ‘C:\Program Files\dotnet’. Failed to run as a self-contained app. - The application was run as a self-contained app because ‘c:\dev\x86\dbl\bin\asm2dbp.runtimeconfig.json’ did not specify a framework. - If this should be a framework-dependent app, specify the appropriate framework in ‘c:\dev\x86\dbl\bin\asm2dbp.runtimeconfig.json’.
There are two workarounds for this issue. One option is to add the following to your project file:
<Target Name="_WorkaroundIncorrectSingleFileHost" BeforeTargets="_GetComHostPaths">
<CallTarget Targets="_GetAppHostCreationConfiguration" />
</Target>
The other option is to remove the “dotnet publish” from the project’s post-build step and instead call dotnet publish separately after the build (in a script or makefile). When adding the dotnet publish command to the script or makefile, remove the –no-build option so it will both build and publish the application.