Starting a project correctly is about more than just code; it's about the **environment**. In this guide, we’ll build a professional-grade solution using **Microsoft Entra ID** for security, a separate **Class Library** for logic, and the modern **Microsoft Testing Framework** for high-performance test execution—all without leaving the command line.

### Step 1: The Foundations (Prerequisites)

Before we touch the command line, ensure your toolkit is up to date. You'll need these three pillars installed:

##### .NET 10 SDK

The core engine. Download the latest SDK to access new performance features and the `dotnet` CLI tools.

##### VS Code

Install the **C# Dev Kit** extension. It provides the "Solution Explorer" feel directly inside VS Code.

##### Git

Required for version control and for many .NET templates to initialize correctly during project creation.

### Step 2: Entra ID App Registration

We need to register our app in Azure to get the **Tenant ID** and **Client ID** needed for authentication.

##### 1\. Create Registration

- Go to the **Microsoft Entra admin center**.
- Navigate to **Applications > App registrations**.
- Click **New registration**. Name it "MyEnterpriseApp".
- Redirect URI: Select **Web** and enter `https://localhost:7123/signin-oidc`.

##### 2\. Define App Roles

- Inside your new app, go to **App roles**.
- Click **Create app role**.
- Display Name: `Admin`, Value: `Admin`.
- Allowed member types: **Users/Groups**.
- Repeat for a `User` role.

###### Checkpoint

Copy your **Application (client) ID** and **Directory (tenant) ID** from the Overview page. You'll need these for the CLI commands!

### Step 3: Building the Solution via CLI

##### The Terminal Commands

Run these commands in order. Replace the placeholders with your Azure IDs from Step 2.

# Create Solution Folder

mkdir MyEnterpriseSolution && cd MyEnterpriseSolution

# Create Solution File

dotnet new sln

# Create MVC Web App with Entra Auth

dotnet new mvc -o MyWebApp --auth SingleOrg \
   --client-id "YOUR\_CLIENT\_ID" \
   --tenant-id "YOUR\_TENANT\_ID"

# Create Class Library and Test Project

dotnet new classlib -o MyBusinessLogic

dotnet new mstest -o MyTests

# Stitch it together

dotnet sln add MyWebApp MyBusinessLogic MyTests
dotnet add MyWebApp reference MyBusinessLogic
dotnet add MyTests reference MyBusinessLogic

##### Why this structure?

By using a **Solution (.sln)**, you manage multiple projects as one unit.

The **Class Library** keeps your core code clean, and **MSTest** ensures it stays working.

* * *

Enable EXE Testing:

In .NET 10, your test project can be an `exe`. Ensure `MyTests.csproj` contains:

`
                        <OutputType>Exe</OutputType>
`

### Step 4: Using the Roles

Now that Entra ID knows about the "Admin" role, apply it to your controllers for instant security.

\[Authorize(Roles = "Admin")\]

public class AdminController : Controller
{

public IActionResult Index() => View();

}

Don't forget to assign yourself the role in the **Enterprise Applications** section of the Azure Portal!

## Step 5: Control Center

Run and test your new .NET 10 solution from the terminal.

| Goal | Command |
| --- | --- |
| **Run the Web App** | `dotnet run --project MyWebApp` |
| **Run Tests (Modern)**<br>Executes tests directly as an EXE | `dotnet run --project MyTests` |
| **Build Everything** | `dotnet build` |
