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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s