Skip to content

Commit 68e7588

Browse files
Fix devcontainer for private NuGet feed authentication and .NET 9.0 support
Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
1 parent a412152 commit 68e7588

3 files changed

Lines changed: 100 additions & 5 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
"image": "mcr.microsoft.com/devcontainers/dotnet",
33
"features": {
44
"ghcr.io/devcontainers/features/dotnet:2": {
5-
"version": "latest"
5+
"version": "9.0"
66
}
77
},
8-
"postCreateCommand": "dotnet --list-sdks"
8+
"containerEnv": {
9+
"NUGET_AUTH_TOKEN": "${localEnv:AZURE_DEVOPS_PAT}"
10+
},
11+
"postCreateCommand": "bash .devcontainer/setup.sh"
912
}

.devcontainer/setup.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
echo "🔧 Setting up EssentialCSharp.Web development environment..."
4+
5+
# Verify .NET SDK version
6+
echo "📋 Checking .NET SDK version..."
7+
dotnet --version
8+
9+
# List available SDKs
10+
echo "📋 Available .NET SDKs:"
11+
dotnet --list-sdks
12+
13+
# Check if we have the Azure DevOps PAT token
14+
if [ -z "$NUGET_AUTH_TOKEN" ]; then
15+
echo "⚠️ WARNING: AZURE_DEVOPS_PAT environment variable is not set!"
16+
echo " Private NuGet packages from Azure DevOps will not be accessible."
17+
echo " Please set the AZURE_DEVOPS_PAT environment variable with your Azure DevOps Personal Access Token."
18+
echo " See README.md for setup instructions."
19+
echo ""
20+
echo "🔧 Restoring packages without private feed access..."
21+
dotnet restore -p:AccessToNugetFeed=false
22+
else
23+
echo "✅ Azure DevOps PAT token found - configuring private NuGet feed..."
24+
25+
# Configure Azure DevOps NuGet source with authentication
26+
dotnet nuget add source "https://pkgs.dev.azure.com/intelliTect/_packaging/EssentialCSharp/nuget/v3/index.json" \
27+
--name "EssentialCSharp" \
28+
--username "devcontainer" \
29+
--password "$NUGET_AUTH_TOKEN" \
30+
--store-password-in-clear-text \
31+
--configfile nuget.config
32+
33+
echo "🔧 Restoring packages with private feed access..."
34+
dotnet restore -p:AccessToNugetFeed=true
35+
fi
36+
37+
echo "✅ Setup complete!"
38+
echo ""
39+
echo "🚀 Ready to develop! You can now:"
40+
echo " - Build: dotnet build"
41+
echo " - Test: dotnet test"
42+
echo " - Run web app: dotnet run --project EssentialCSharp.Web"
43+
echo " - Run chat app: dotnet run --project EssentialCSharp.Chat"

README.md

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,41 @@ For any bugs, questions, or anything else with specifically the code found insid
1717
To get the site that is seen at [essentialcsharp.com](https://essentialcsharp.com/):
1818

1919
1. Clone Repository locally.
20-
2. Set any needed secrets
21-
3. If you have do not have access to the private nuget feed, change the line `<AccessToNugetFeed>true</AccessToNugetFeed>` to `<AccessToNugetFeed>false</AccessToNugetFeed>` in [Directory.Packages.props](https://github.com/IntelliTect/EssentialCSharp.Web/blob/main/Directory.Packages.props).
20+
2. Set any needed secrets (see Environment Prerequisites below)
21+
3. If you do not have access to the private nuget feed, change the line `<AccessToNugetFeed>true</AccessToNugetFeed>` to `<AccessToNugetFeed>false</AccessToNugetFeed>` in [Directory.Packages.props](https://github.com/IntelliTect/EssentialCSharp.Web/blob/main/Directory.Packages.props).
2222

23-
## Environment Prequisites
23+
## Development Container Setup
24+
25+
This project includes a VS Code devcontainer for consistent development environments. To use it:
26+
27+
### With Private NuGet Feed Access
28+
29+
If you have access to the IntelliTect private Azure DevOps NuGet feed:
30+
31+
1. Create an Azure DevOps Personal Access Token (PAT) with **Packaging (Read)** permissions
32+
2. Set the environment variable before opening the devcontainer:
33+
```bash
34+
export AZURE_DEVOPS_PAT="your-azure-devops-pat-token"
35+
```
36+
Or add it to your shell profile (`.bashrc`, `.zshrc`, etc.)
37+
3. Open the project in VS Code and select "Reopen in Container" when prompted
38+
39+
### Without Private NuGet Feed Access
40+
41+
If you don't have access to the private feed:
42+
43+
1. Update `Directory.Packages.props` and set `<AccessToNugetFeed>false</AccessToNugetFeed>`
44+
2. Open the project in VS Code and select "Reopen in Container" when prompted
45+
46+
The devcontainer will automatically:
47+
- Install the correct .NET 9.0 SDK
48+
- Configure NuGet authentication (if PAT token is provided)
49+
- Restore all packages
50+
- Set up the development environment
51+
52+
## Environment Prerequisites
53+
54+
### Application Secrets
2455

2556
Make sure the following secrets are set:
2657
In local development this ideally should be done using the dotnet secret manager. Additional information can be found at the [documentation](https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets#set-a-secret)
@@ -37,6 +68,24 @@ HCaptcha:SiteKey = captchaSiteKey
3768
HCaptcha:SecretKey = captchaSecretKey
3869
APPLICATIONINSIGHTS_CONNECTION_STRING = "InstrumentationKey=your-instrumentation-key-here;IngestionEndpoint=https://region.in.applicationinsights.azure.com/;LiveEndpoint=https://region.livediagnostics.monitor.azure.com/"
3970

71+
### Private NuGet Feed Access
72+
73+
For developers with access to IntelliTect's private Azure DevOps NuGet feed, you'll need to set up authentication:
74+
75+
**For DevContainer/Local Development:**
76+
Set the `AZURE_DEVOPS_PAT` environment variable with your Azure DevOps Personal Access Token:
77+
```bash
78+
export AZURE_DEVOPS_PAT="your-azure-devops-pat-token"
79+
```
80+
81+
**Creating an Azure DevOps PAT:**
82+
1. Go to Azure DevOps → User Settings → Personal Access Tokens
83+
2. Create a new token with **Packaging (Read)** permissions
84+
3. Copy the token and set it as the environment variable above
85+
86+
**Without Private Feed Access:**
87+
If you don't have access to the private feed, set `<AccessToNugetFeed>false</AccessToNugetFeed>` in `Directory.Packages.props`
88+
4089
Testing Secret Values:
4190
Some Value Secrets for Testing/Development Purposes:
4291
HCaptcha: https://docs.hcaptcha.com/#integration-testing-test-keys

0 commit comments

Comments
 (0)