Skip to content

Non-selfcontained RID-specific app should copy host executable to build output #1905

@dasMulli

Description

@dasMulli

TL;DR
Combination of RuntimeIdentifier + SelfContained=false doesn't work well for development work (dotnet run, visual studio F5).

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <RuntimeIdentifier>win-x86</RuntimeIdentifier>
    <SelfContained>false</SelfContained>
  </PropertyGroup>

Scenario / Repro steps:

  • Create a console app
  • Add native 32-bit dlls to PInvoke into
  • Realize you now need to make sure you run 32bit only and are locked into a RID
    • add <RuntimeIdentifier>win-x86</RuntimeIdentifier> to the csproj
  • dotnet run works just fine now since there is a 32 bit host executable copied to the output directory which resolves the 32bit runtime. Visual Studio also runs the app just fine.
  • Publish once and realize you don't need to publish self-contained. Or have problems using dotnet publish --self-contained because it is passed as a global parameter to all reference projects and some may error out (Cannot publish core console app + core app library tests #1834)
    • Put <SelfContained>false</SelfContained> into the csproj file.
  • dotnet run and Visual Studio run no longer work because it falls back to calling dotnet the.dll which fails to load 32-bit (native) assemblies.

Can the generation of the native host be turned on even though SelfContained is false for build output only?

There may be some additional advantages in also copying this host without the self-contained framework for publish - (https://github.com/dotnet/cli/issues/6237)

The advantage of this host is that it launches with the right bitness and there is no need to put the 32bit dotnet.exe on the PATH or use a 32bit SDK.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions