4

Converted an old .NET Framework project to .NET Core 3.1 yesterday. The application runs fine on my own machine and debugs correctly.

I have put both the following into my .vbproj/.csproj

<PublishSingleFile>true</PublishSingleFile>
<RuntimeIdentifier>win81-x64</RuntimeIdentifier>

However when I move the .EXE to a remote machine and attempt to run said EXE on that remote machine I get told that the DLL (for the project in question) does not exists.

I moved the .dll to the same directory that the exe is in (not ideal) and get the following error instead

A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\Program Files\dotnet'.

I used to use Costura.Fody to create a single file exe without any issues in .NET Framework, I was under the impression the above would do the same for the .NET Core packages.

Can someone point me in the right direction please.

riQQ
  • 9,878
  • 7
  • 49
  • 66
Lynchie
  • 1,077
  • 2
  • 20
  • 36

2 Answers2

6

For anyone else that may find this question and find it useless.

I was 'Building' the project instead of 'Publishing' the project, this in-turn wasn't creating the self-contained exe properly.

Don't be a donut like me.

Lynchie
  • 1,077
  • 2
  • 20
  • 36
0

In Visual Studio 2019, go to Build > Publish MyApp. This will open a tab in the editor area. Click on Show all settings to open the Profile settings dialog. Then click on File publish options and check Produce single file.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268