C# project with a package reference to a nuget with an exe assembly
06:14 21 Nov 2025

I know that in the early times of .NET Framework, you could build an assembly into EXE and then use that "EXE assembly" as a dependency of another .NET Framework assembly which, too, could be an "EXE assembly", for example.

A decade or so later, NuGet packages appeared and people went from .NET Framework over to .NET Core, or today, to .NET 8 or 9 or even 10...

My questions are:

  • Is it possible to create and publish a NuGet package with just one assembly inside which, however, is of OutputType EXE?
  • And then, is it possible to create another C# project with a dependency on that NuGet package and actually on that EXE-assembly in it?

I'm using .NET Core (.NET 8 or 9) on Linux, and it appears that I'm not able to build the depending project unless I accept weird compiler warnings like:

Warning MSB3246 : Resolved file has a bad image, no metadata, or is otherwise inaccessible. PE image does not have metadata. PE image does not have metadata.
Warning MSB3243 : No way to resolve conflict between "MyCompany.MyNugetPackage, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" and "MyCompany.MyNugetPackage". Choosing "MyCompany.MyNugetPackage, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" arbitrarily.

It seems to me that the thing which obstructs a warning-less build is the fact there are two "similar" files in that NuGet package:

  • MyCompany.MyNugetPackage.exe
  • MyCompany.MyNugetPackage.dll

Assembly information (version, culture etc.) is contained only in the DLL file whereas the EXE file is actually not regognized as an assembly (by the ILDasm tool, at least). Nevertheless, I suspect the MSBuild (or whatever builds my project) is not able to tell which of the two files to use during the build process.

Any ideas?

c# .net msbuild nuget .net-assembly