CoreConsole.exe not working but CoreRun.exe does
Hi,
I'm trying to run a console application, using the instructions provided in "Get .NET Core on Windows - Raw Experience". Renaming CoreConsole.exe doesn't work, there is no output and the error code is -1. However, if I used CoreRun.exe as suggested in "Build CoreCLR on Windows" the application works as expected. Is CoreConsole.exe still supported?
Thanks.
CoreConsole.exe should work fine, depending on what you are doing. I did file this issue (#1253) yesterday, but it's easy to work around and there is already a fix available. You may be hitting that since it causes the process to crash and print nothing.
Other things to keep in mind:
- The "real" .NET assembly to be executed needs to be built as an exe, with an entrypoint method in it. That means passing /target:exe into the compiler, or setting the right project property (OutputType=exe) . It needs to be renamed to "foo.dll"
- CoreConsole.exe needs to be renamed to "foo.exe"
- Invoke with full file name, including ".exe" until that fix is in.
Thanks for your answer, but unfortunately I couldn't make it work.
With the following code:
using System;
namespace Tool.Translator
{
public static class Program
{
public static int Main(string[] args)
{
Console.WriteLine("Hello");
return 0;
}
}
}
I used the following flags when compiling with csc.exe:
/noconfig
/out:
I tried renaming CoreConsole.exe from a cloned repo and also the one in the NuGet package, with no success. Is there any way to get a log to see what is going on?
I assume you're running this from a command line window or powershell or something as otherwise you wouldn't know the return code? I only ask as the two instances I can see where coreconsole can return -1 is either when it's showing help, stating you must have the .exe extension (see https://github.com/dotnet/coreclr/blob/master/src/coreclr/hosts/coreconsole/coreconsole.cpp#L601 and https://github.com/dotnet/coreclr/blob/master/src/coreclr/hosts/coreconsole/coreconsole.cpp#L641 ), or when your application actually returns -1. Running with /_v or -_v should enable the logging in coreconsole itself and may give some insight as to what is going on.
Thanks @mellinoe and @benpye! When running with /_v I found out that the coreclr.dll was missing. The reason was that in Build on Windows it says explicitly copy the coreclr.dll and in Get .NET Core on Windows it is included in one of the packages which I missed to see.