3

I installed .NET Core following the instructions at the link below

http://dotnet.github.io/getting-started/

and I was able to get my 'hello world' working using 'dotnet run'. However, I couldn't see an exe file that all the documentation around the internet seems to indicate it would generate.

Running 'dotnet publish' pretty much copies those files into a different folder with 2 less files (removes the pdb file and the extra dev configs).

What am I missing?

Update 1

Here is the project.json file I have

{
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true
  },
  "dependencies": {
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0-rc2-23930"
    }
  },
  "frameworks": {
    "netstandard1.5": {}
  }
}
1
  • Users should now upgrade to RC2 bits from nightly, dot.net Commented May 22, 2016 at 13:40

2 Answers 2

3

You will only get a binary executable (exe file on Windows) when publishing a "self-contained" application (See Types of portability in .NET Core). Note: I'm using the current preview1 build version (1.0.0-rc2-3002702) for all Microsoft.NetCore.App references, but the same changes apply to other versions.

Basically, your project.json file should have the following changes:

1. Add a new section called runtimes:

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

2. Remove the platform part of the Microsoft.NETCore.App dependency:

"Microsoft.NETCore.App": {
  "type": "platform",
  "version": "1.0.0-rc2-3002702"
}

Changes to:

"Microsoft.NETCore.App": "1.0.0-rc2-3002702"

3. Ensure that you are targetting netcoreapp1.0 and not netstandard1.*, netstandard1.* indicates that you are compiling a class library and not a standalone executable program. Your frameworks section should then look like:

"frameworks": {
  "netcoreapp1.0": {}
}

Once these changes are made, you can then publish your app as a binary executable ("self-contained") application with this command:

dotnet publish -r win7-x64

Sign up to request clarification or add additional context in comments.

3 Comments

Somehow completely missed this answer! Thanks!
Solved my problem.For Ubuntu runtime is named "ubuntu.16.04-x64"
ubuntu.14.04-x64 for Ubuntu 14.04 64-bit and ubuntu.16.04-x64 for Ubuntu 16.04 64-bit
-1

The exe should be under the bin\Debug folder. However, you'll only get an exe if you add emitEntryPoint:true in project.json like here

1 Comment

That is exactly what all the documentation says but no exe. The 'dotnet new' request does that automatically (adds emitEntryPoint:true) all by itself but still, no exe. I will update the question with my project.json

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.