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.
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’.
A potential workaround to this issue for any developer is to remove the “dotnet publish” out of 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, drop the no-build option so it will both build and publish the application.
Making dotnet publish both build and publish (with PublishSingleFile) allowed our application that was built under this new VS/.NET 9 configuration to work as expected.