How to create a C # executable with .NET Core?

-1

I'm developing an introduction to programming material using .NET Core. I have read the documentation on creating and running web projects, but I have found nothing that addresses how to create a project from a console application and generate a .EXE from it.

I figured that with namespace ConsoleApplication the code would generate an executable, but in fact it creates a .DLL that can be executed with dotnet programa.dll .

What should I do to make the project create an executable?

    
asked by anonymous 12.10.2016 / 17:28

2 answers

0

I found it.

First the project must be created with dotnet new -t console

Since the default framework is netcoreapp1.0 , when dotnet build is invoked, it will compile Program.cs as a dll. To compile an executable:

In the project.json file, navigate to the "frameworks" option, open a new line, and include “net461”:{}, (with a comma). Remove the "type": "platform", option and add

"runtimes": {     "win7-x64":{}   }

After declaring imports . Regenerate the project with dotnet restore . After that, dotnet build will compile Project.cs as an executable.

    
13.10.2016 / 01:53
-1

When you create a new project you have to choose the "Console Application" option in the project type.

    
12.10.2016 / 17:31