. net core 1.0 create self contained console application


Development machine: win7-x64
. net core version: 1.0.0-preview2-003121
Visual Studio Code:1.2.1 

For the self contained application type and its difference from portable application type, please refer to another article:. net core application types (portable apps & self contained apps), this article is just a complete demo for your reference.

1. Create a HelloWorld directory in the specified directory, use the command line to switch to this directory, and execute: dotnet new to create a new console project.

The dotnet new command will generate two files in the HelloWorld Directory: 1. Program.cs 2. Project.json.

2. Modify the default generated project.json file as follows:

 "version": "1.0.0-*",
 "buildOptions": {
 "emitEntryPoint": true
 "dependencies": {
 "Microsoft.NETCore.App": {
  "version": "1.0.0"
 "frameworks": {
 "netcoreapp1.0": {
  "imports": "dnxcore50"
 "runtimes": {
 "win7-x64": {},
 "osx.10.11-x64": {}

3. Usedotnet restoreCommand to recover the dependent nuget package

4. Usedotnet publish/dotnet publish -r win7-x64Command to publish the program

Files generated for publishing in D: \ HelloWorld \ bin \ debug \ netcoreapp1.0 \ win7-x64 \ publish directory

5. Usedotnet HelloWorld.dllperhaps./HelloWorldTo run the console program

The above program is executed as a foreground process. If the background process executes, execute the command:dotnet HelloWorld.dll &or ./HelloWorld & Just.

Redirect the standard output of the console to a file (> to create or overwrite; > > to append), and execute the naming:./HelloWorld >> outfile &

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support developpaer.