Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publishsinglefile causes runtime failure of hostpolicy.dll not found for dotnet 9.0.100 #44992

Open
jsahaj opened this issue Nov 20, 2024 · 0 comments
Labels
Area-NetSDK untriaged Request triage from a team member

Comments

@jsahaj
Copy link

jsahaj commented Nov 20, 2024

HelloWorldExample1.zip
When doing publishsinglefile=true and running resulting exe we get a runtime failure of hostpolicy.dll not found for dotnet 9.0.100. This is a regression from net8, where it builds and runs fine.

With C# project file is defined as:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType> <TargetFramework>net8.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> <PlatformTarget>x64</PlatformTarget> <PublishSingleFile>true</PublishSingleFile> <SelfContained>true</SelfContained> <PublishTrimmed>true</PublishTrimmed> <RuntimeIdentifier>win-x64</RuntimeIdentifier> </PropertyGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="dotnet publish --configuration $(Configuration) --runtime win-x64 --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=true --no-build --output=$(EXEOUT) HelloWorldExample1.csproj" />
</Target>
</Project>

Set EXEOUT to some directory and build the project. Go to exeout directory at command prompt and run the executable and to get error:

c:\Temp\exeout>HelloWorldExample1.exe
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:\Temp\exeout\HelloWorldExample1.runtimeconfig.json' was not found.
  • If this should be a framework-dependent app, add the 'c:\Temp\exeout\HelloWorldExample1.runtimeconfig.json' file and specify the appropriate framework.

Removing the publishsinglefile allows program to run without error.

Versions:
dotnet 9.0.100
VS 17.12.1
csc 4.12.0-3.24558.5

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-NetSDK untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

1 participant