Skip to content

Commit 6cd9b40

Browse files
committed
Updated to use .NET 9
1 parent 3120f7d commit 6cd9b40

20 files changed

Lines changed: 179 additions & 53 deletions

.devcontainer/devcontainer.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet
3+
{
4+
"name": ".net dev",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"image": "mcr.microsoft.com/devcontainers/dotnet:1-9.0-bookworm",
7+
"features": {
8+
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
9+
},
10+
11+
// Configure tool-specific properties.
12+
"customizations": {
13+
"vscode": {
14+
"extensions": [
15+
"GitHub.copilot-chat",
16+
"ms-dotnettools.csdevkit",
17+
"humao.rest-client",
18+
"EditorConfig.EditorConfig",
19+
"heaths.vscode-guid",
20+
"redhat.vscode-xml"
21+
]
22+
}
23+
}
24+
25+
// Features to add to the dev container. More info: https://containers.dev/features.
26+
// "features": {},
27+
28+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
29+
// "forwardPorts": [5000, 5001],
30+
// "portsAttributes": {
31+
// "5001": {
32+
// "protocol": "https"
33+
// }
34+
// }
35+
36+
// Use 'postCreateCommand' to run commands after the container is created.
37+
// "postCreateCommand": "dotnet restore",
38+
39+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
40+
// "remoteUser": "root"
41+
}

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for more information:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
# https://containers.dev/guide/dependabot
6+
7+
version: 2
8+
updates:
9+
- package-ecosystem: "devcontainers"
10+
directory: "/"
11+
schedule:
12+
interval: weekly

.vscode/launch.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Console",
6+
"type": "coreclr",
7+
"request": "launch",
8+
"preLaunchTask": "build",
9+
"program": "${workspaceFolder}/src/ConsoleApp/bin/Debug/net9.0/ConsoleApp.dll",
10+
"args": [],
11+
"cwd": "${workspaceFolder}/src",
12+
"stopAtEntry": false,
13+
"console": "internalConsole"
14+
}
15+
]
16+
}

.vscode/tasks.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "build",
6+
"command": "dotnet",
7+
"type": "process",
8+
"args": [
9+
"build",
10+
"${workspaceFolder}/src/dotnet-basic-console.sln",
11+
"/property:GenerateFullPaths=true",
12+
"/consoleloggerparameters:NoSummary;ForceNoAlign"
13+
],
14+
"problemMatcher": "$msCompile"
15+
}
16+
]
17+
}

ConsoleApp/ConsoleApp.csproj

Lines changed: 0 additions & 27 deletions
This file was deleted.

ConsoleApp/Dockerfile

Lines changed: 0 additions & 20 deletions
This file was deleted.

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
# Basic .NET 8 Console App
1+
# Basic .NET 9 Console App
22

33
Yes, there are much less verbose starting projects. No, you do not need all this stuff to play with .NET.
44

5-
Quickly clone this repository to get a .NET 8 console app which:
5+
Quickly clone this repository to get a .NET 9 console app which:
66

77
1. Has dependency injection usage examples ([DemoService](./ConsoleApp/Services/DemoService.cs))
88
1. Docker container support
99
1. Has GitHub actions to build a container
10+
1. Uses centralized package management
11+
1. Has a VSCode launch profile
12+
1. Has a devcontainer to launch in GitHub Codespaces or within VSCode itself as a remote container
1013
1. Example getting AccessToken from Azure AD following client credentials flow (for daemons)
1114
* Built-in example assumes Azure App Registration has `Microsoft Graph : User.Read.All` application permission granted.
12-
1. devcontainer configured - only need container runtime, not dotnet locally installed (TODO)
1315

14-
## Build & Run Docker container
16+
## Build & Run as Docker container
1517

1618
```bash
17-
cd BasicConsole/
19+
cd src/
1820
docker build -t dotnet-basic-console:latest .
1921
docker run --rm dotnet-basic-console:latest
20-
```
22+
```
File renamed without changes.

src/ConsoleApp/ConsoleApp.csproj

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<UserSecretsId>5440f379-b40c-4853-99bc-c7d796915584</UserSecretsId>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="BenchmarkDotNet" />
10+
<PackageReference Include="Microsoft.Extensions.Hosting" />
11+
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" />
12+
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" />
13+
<PackageReference Include="Microsoft.Extensions.Http" />
14+
<PackageReference Include="Serilog" />
15+
<PackageReference Include="Serilog.Extensions.Hosting" />
16+
<PackageReference Include="Serilog.Settings.Configuration" />
17+
<PackageReference Include="Serilog.Sinks.Console" />
18+
</ItemGroup>
19+
20+
<ItemGroup>
21+
<None Update="appsettings.json">
22+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
23+
</None>
24+
</ItemGroup>
25+
</Project>

ConsoleApp/Models/Configuration/ConsoleAppSettings.cs renamed to src/ConsoleApp/Models/Configuration/ConsoleAppSettings.cs

File renamed without changes.

0 commit comments

Comments
 (0)