Control the name of the dotnet core application output

November 29, 2016 by Anuraj

ASP.NET Core .NET Core dotnet

This post is about configuring the output filename of a .NET Core application. By default compiling a .NET Core application, the output filename will be the project directory name. So if you are compiling the application from a directory abc, the output dll name will be abc.dll. This can cause an issue when using CI where you may not control the folder structure in which the command is executed. This can be fixed using buildOptions configuration in the project.json file.

"version": "1.0.0-*",
"buildOptions": {
  "debugType": "portable",
  "emitEntryPoint": true,
  "outputName": "HelloWorld"
}

If you are using Visual Studio code, while changing the outputName configuration, you also need to modify program configuration value it in the launch.json file as well. Otherwise you will get a file doesn’t exists error from VS Code.

Here is the change in the launch.json file.

{
    "name": ".NET Core Launch (console)",
    "type": "coreclr",
    "request": "launch",
    "preLaunchTask": "build",
    "program": "${workspaceRoot}\\bin\\Debug\\netcoreapp1.1\\HelloWorld.dll",
    "args": [],
    "cwd": "${workspaceRoot}",
    "externalConsole": false,
    "stopAtEntry": false,
    "internalConsoleOptions": "openOnSessionStart"
}

And if you are using Visual Studio, it may break debugging feature. - https://github.com/dotnet/cli/issues/4198

Happy Programming :)

Copyright © 2024 Anuraj. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Powered by Jekyll. Hosted with ❤ by GitHub