2

I've created a simple .NET core console app targeting .NET Core Framework 1.1. When I build it, it creates an assembly file named DotNetCoreConsoleApp.dll in the \bin\debug folder. So there is nothing that I can double click and run directly but interestingly when I start debugging the project by pressing F5 then Visual Studio is able to launch a process.

Project configuration of my project is as below:

enter image description here

How windows will be able to launch such an application process without any exe file? I understand that Windows only understands a file as starting point of a process if it contains PE header.

RBT
  • 24,161
  • 21
  • 159
  • 240
  • Project is not setup to compile as library and still does not produce an exe (no core experience here)? – Patrick Artner Nov 21 '17 at 06:10
  • You need to publish it as per [here](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish?tabs=netcore2x). – ProgrammingLlama Nov 21 '17 at 06:13
  • @PatrickArtner I've added a snapshot into the post showing my project configuration. – RBT Nov 21 '17 at 06:13
  • 2
    Publish it using `dotnet publish -c release -r OSnameGoesHere`. Take a look at [my post](https://stackoverflow.com/questions/47386585/automate-multiple-dotnet-core-commands/47386996#47386996) if in future you may develop in Visual Studio Code. I use VS Code and have successfully published for Windows OS, which creates an `.exe` – boop_the_snoot Nov 21 '17 at 06:14
  • Here is some more info: https://stackoverflow.com/questions/36516848/how-to-run-a-net-core-dll#36518972 – Stefan Nov 21 '17 at 06:16
  • @john publish process is also creating *.dll files only. – RBT Nov 21 '17 at 06:17
  • @RBT What about `dotnet publish -r win-x64`? – ProgrammingLlama Nov 21 '17 at 06:18
  • @RBT: thanks for sharing, that is most peculiar – Patrick Artner Nov 21 '17 at 06:20
  • @john this command `dotnet publish -r win-x64` results in error `error : Assets file 'C:\Users\rasik.bihari\source\repos\App1\DotNetCoreConsoleApp\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v1.1/win-x64'. Ensure you have restored this project for TargetFramework='netcoreapp1.1' and RuntimeIdentifier='win-x64'. [C:\Users\rasik.bihari\source\repos\App1\DotNetCoreConsoleApp\DotNetCoreConsoleApp.csproj]` – RBT Nov 21 '17 at 06:33
  • I assumed you were doing restore first, since you said you had already tried publish? Run `dotnet restore -r win-x64` first, and then publish. – ProgrammingLlama Nov 21 '17 at 06:34
  • ok @john. So now the `dotnet publish -r win-x64` command worked after doing `dotnet restore -r win-x64` but it is still creating a dll file inside `\bin\Debug\netcoreapp1.1\win-x64` directory. – RBT Nov 21 '17 at 06:39
  • @RBT The .exe is some kind of pre-built Microsoft wrapper around the DLL. As far as I can tell, it just looks for a DLL with the same name as itself, and then loads that and executes it. You can substitue the DLL to change the program that's executed. It's how things are now, it seems. – ProgrammingLlama Nov 21 '17 at 06:41

1 Answers1

8

There is no exe file.

From msdn: "Short answer, there isn’t one. When you compile your .NET Core console application for example, you get a DLL. Then you execute it using the DOTNET command from the .NET Core SDK found here."

From a different answer on stackoverflow (Visual Studio 2017 missing exe file): You have two options:

  1. If you want an EXE, you need to target the .NET Framework.
  2. If you don't want to change your code, then you need to install .NET Core on the server and run dotnet pathToDll on a command line

https://blogs.msdn.microsoft.com/benjaminperkins/2017/03/07/net-core-application-where-is-my-exe-how-to-publish/

Ronald Meijboom
  • 1,534
  • 3
  • 17
  • 37