Create A New ASP.NET Core Solution Folder Structure

Create A New ASP.NET Core Solution Folder Structure

This will be the first of many blog posts where I will develop my new approach to developing ASP.NET Core 1.1.0 enterprise-ready on-premise web services and web applications. Since most of my examples will be geared towards enterprise developers, I will be using Visual Studio for most tasks. I will start by creating a new solution folder using Visual Studio 2015.

From the File menu, select to File->New->Project menu item, and the New Project dialog box appears.

create-new-solution

Navigate to the Templates->Other Project Types->Visual Studio Solutions folder.

In the middle window area, choose the Blank Solution option.

In the input form area at the bottom of the dialog, do the following:

  • Enter a name for the solution. I specified AspNetCoreEnterprise for my solution name.
  • Enter or browse for a root folder location in which to create your solution folder.
  • The Solution drop-down list should be set to Create new solution.
  • Ensure the Create directory for solution checkbox is checked.
  • Ensure the Create new Git repository checkbox is checked.

Click the OK button, and the new solution should appear in the Visual Studio – Solution Explorer window.

new-solution-created

Right-click on the name of the solution and a context menu appears.

Choose Add->Existing Item… and the Add Existing Item – Solution Items dialog box appears.

add-git-files-to-solution

Select the files called .gitignore and .gitattributes and click the Add button.

.gitignore

The purpose of the .gitignore file is to allow you to ignore files, such as editor backup files, build products or local configuration overrides that you never want to commit into a repository. Without matching .gitignore rules, these files will appear in the “untracked files” section of git status output.

Click here to find more information on the .gitignore file.

Click here to find other .gitignore templates that you may need to add into your existing file to support ignorning file fror other IDEs and tools (e.g., npm, node.js, bower, etc)

Some common .gitignore setting I personally use come from the following sources:

Visual Studio .gitignore file settings

Visual Studio Code .gitignore file settings

Node.js .gitignore settings

SASS .gitignore file settings

Yeoman .gitignore file settings

In general, you should consider merging all of your desired .gitignore file settings into a single file at the root of you Git repository.

.gitattributes

Provide settings for a path so that Git applies those settings only for a subdirectory or subset of files. These path-specific settings are called Git attributes and are set either in a .gitattributes file in one of your directories (normally the root of your project) or in the .git/info/attributes file if you don’t want the attributes file committed with your project.

Using attributes, you can do things like specify separate merge strategies for individual files or directories in your project, tell Git how to diff non-text files, or have Git filter content before you check it into or out of Git. In this section, you’ll learn about some of the attributes you can set on your paths in your Git project and see a few examples of using this feature in practice.

Click here to find more information on the .attributes file.

A new folder appears in the solution called Solution Items which contains the .gitignore and .gitattributes files.

added-git-files-to-solution

Right-click on the name of the solution and a context menu appears.

Choose Add->New Item… and the Add New Item – Solution Items dialog box appears.

add-global-json

In the middle view pane, select the Text File item.

In the Name field at the bottom of the dialog box, enter global.json.

Click the Add button.

The global.json file appears in the Solution Items folder.

added-global-json

A new code window called global.json appears in Visual Studio.

global.json

The global.json file is used on .NET Core projects to define the solution metadata. This file is used when the dotnet-restore command is invoked to restore the dependencies of a .NET Core project.

Click here to find more information on the global.json file.

Enter the following data into the global.json code window:

add-data-to-global-json

Please note that the current SDK version of 1.0.0-preview2-1-003177 is the correct setting for .NET Core 1.1.0.

Right-click on the name of the solution and a context menu appears.

Choose Add->New Solution Folder and a new folder appears in the Solution Explorer window.

Rename this folder to “src“.

This is where we will put all of our web service and web application projects.

Right-click on the name of the solution and a context menu appears.

Choose Add->New Solution Folder and a new folder appears in the Solution Explorer window.

Rename this folder to “test“.

This is where we will put all of our unit and integration test projects.

The Solution Explorer windows should now appear something like the following:

new-solution-explorer-folder-structure

This completes the basic setup of a basic folder structure for an extremely basic ASP.NET Core solution folder structure using a Git repository.

You can find a copy of this solution at my GitHub site.

Source Code: Basic Asp Net Core Solution Structure

Next steps are to commit your source code changes to your local Git repository and commence adding new ASP.NET Core projects to the solution.

 

 

 

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