Hangman Hangman - 1 year ago 116
C# Question

Why does .Net Core CLI in VSCode put release folder in the debug directory

I feel like I'm missing something obvious, but searching google, this site and the .Net Core SLI issues section on GitHub did not immediately return an answer, nor did reading the documentation for the .Net Core project.json format.

In plain old C# projects (regular .Net, not Core) scaffolded by Visual Studio (not VSCode), usually running a build will put files in

%project root%/bin/Debug

out of the box, or

%project root%/bin/Release

if you choose publish.

In VSCode with .Net Core, by default build puts files in

%project root%/bin/Debug/netcoreapp1.0.

however if you run

dotnet publish

on the command line, it will put the files in a release folder inside

%project root%/bin/Debug/netcoreapp1.0.

resulting in a structure like

%project root%/bin/Debug/netcoreapp1.0/release.

If you have specified to build for a specific platform target in your project.json then it will similarly put the files in

%project root%/bin/Debug/netcoreapp1.0/PlatformName.

For example

%project root%/bin/Debug/netcoreapp1.0/win7-x64.

My question is, why does .Net Core put the release folder inside the debug folder and since I prefer the old directory structure, is there a way I can tell .Net Core to do it that way instead, say via some project.json property or cli flag similar to how say typescript allows you to specify an outDir?

Testing this with the default hello world project provided by 'dotnet new', my modified project.json looks like this:

"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
//"type": "platform",
"version": "1.0.0"
"imports": "dnxcore50"
"runtimes": {
"win7-x64": { }

Jcl Jcl
Answer Source

According to the documentation (bold is mine):

dotnet publish [--framework] [--runtime] [--build-base-path] [--output] [--version-suffix] [--configuration] []


-c, --configuration [Debug|Release]

Configuration to use when publishing. The default value is Debug.

So you need to use:

dotnet publish -c Release

(there's also the --output parameter to specify the destination folder: the documentation also states the default, which matches what you are seeing)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download