How do I change the name of my ASP.NET Core project?

By default, the project output name when building your .NET Core project is the same name as the directory/folder that contains the project.json (which will be back to *.csproj) as of Visual Studio 2017.  So if you’re like me, and you keep your projects like so:

ProjectName
- src
|
 \
  - project.json
  - ProjectName.xproj
  -  <snip>Lots of *.cs files and folders</snip>
- tests
- Dockerfile

Then you’re going to run into a problem because the name of your output file will be src.dll, since the containing directory is src. Not what you want.
To fix this, you can change a setting in the project.json (or the ProjectName.csproj file):
For project.json, under the buildOptions object:

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true,
    "outputName":  "MyProjectName"       //add this
  },

Add the outputName property, and your string value will be the name you want to be emitted for your DLLs and settings.
For ProjectName.csproj in Visual Studio 2017, it’s the same property:

  <OutputName>MyProjectName</OutputName>

This will allow you to name the project whatever you want, and not be dependent upon the convention of the folder name as project name.

One thought on “How do I change the name of my ASP.NET Core project?”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.