Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
"image": "mcr.microsoft.com/devcontainers/dotnet",
"features": {
"ghcr.io/devcontainers/features/dotnet:2": {
"version": "latest"
"version": "9.0"
}
},
"postCreateCommand": "dotnet --list-sdks"
"containerEnv": {
"NUGET_AUTH_TOKEN": "${localEnv:AZURE_DEVOPS_PAT}"
},
"postCreateCommand": "bash .devcontainer/setup.sh"
}
53 changes: 53 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

echo "🔧 Setting up EssentialCSharp.Web development environment..."

# Verify .NET SDK version
echo "📋 Checking .NET SDK version..."
dotnet --version

# List available SDKs
echo "📋 Available .NET SDKs:"
dotnet --list-sdks

# Check if we have the Azure DevOps PAT token
if [ -z "$NUGET_AUTH_TOKEN" ]; then
echo "⚠️ WARNING: AZURE_DEVOPS_PAT environment variable is not set!"
echo " Private NuGet packages from Azure DevOps will not be accessible."
echo " Please set the AZURE_DEVOPS_PAT environment variable with your Azure DevOps Personal Access Token."
echo " See README.md for setup instructions."
echo ""
echo "🔧 Restoring packages without private feed access..."
dotnet restore -p:AccessToNugetFeed=false
else
echo "✅ Azure DevOps PAT token found - configuring private NuGet feed..."

# Remove existing source if it exists, then add with authentication
dotnet nuget remove source "EssentialCSharp" --configfile nuget.config 2>/dev/null || true

# Configure Azure DevOps NuGet source with authentication
dotnet nuget add source "https://pkgs.dev.azure.com/intelliTect/_packaging/EssentialCSharp/nuget/v3/index.json" \
--name "EssentialCSharp" \
--username "devcontainer" \
--password "$NUGET_AUTH_TOKEN" \
--store-password-in-clear-text \
--configfile nuget.config

echo "🔧 Restoring packages with private feed access..."
if dotnet restore -p:AccessToNugetFeed=true; then
echo "✅ Package restore successful with private feed access!"
else
echo "⚠️ Package restore failed with private feed access."
echo " This might indicate an authentication issue with the Azure DevOps PAT token."
echo " Falling back to public packages only..."
dotnet restore -p:AccessToNugetFeed=false
fi
fi

echo "✅ Setup complete!"
echo ""
echo "🚀 Ready to develop! You can now:"
echo " - Build: dotnet build"
echo " - Test: dotnet test"
echo " - Run web app: dotnet run --project EssentialCSharp.Web"
echo " - Run chat app: dotnet run --project EssentialCSharp.Chat"
55 changes: 52 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,41 @@ For any bugs, questions, or anything else with specifically the code found insid
To get the site that is seen at [essentialcsharp.com](https://essentialcsharp.com/):

1. Clone Repository locally.
2. Set any needed secrets
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).
2. Set any needed secrets (see Environment Prerequisites below)
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).

## Environment Prequisites
## Development Container Setup

This project includes a VS Code devcontainer for consistent development environments. To use it:

### With Private NuGet Feed Access

If you have access to the IntelliTect private Azure DevOps NuGet feed:

1. Create an Azure DevOps Personal Access Token (PAT) with **Packaging (Read)** permissions
2. Set the environment variable before opening the devcontainer:
```bash
export AZURE_DEVOPS_PAT="your-azure-devops-pat-token"
```
Or add it to your shell profile (`.bashrc`, `.zshrc`, etc.)
3. Open the project in VS Code and select "Reopen in Container" when prompted

### Without Private NuGet Feed Access

If you don't have access to the private feed:

1. Update `Directory.Packages.props` and set `<AccessToNugetFeed>false</AccessToNugetFeed>`
2. Open the project in VS Code and select "Reopen in Container" when prompted

The devcontainer will automatically:
- Install the correct .NET 9.0 SDK
- Configure NuGet authentication (if PAT token is provided)
- Restore all packages
- Set up the development environment

## Environment Prerequisites

### Application Secrets

Make sure the following secrets are set:
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)
Expand All @@ -37,6 +68,24 @@ HCaptcha:SiteKey = captchaSiteKey
HCaptcha:SecretKey = captchaSecretKey
APPLICATIONINSIGHTS_CONNECTION_STRING = "InstrumentationKey=your-instrumentation-key-here;IngestionEndpoint=https://region.in.applicationinsights.azure.com/;LiveEndpoint=https://region.livediagnostics.monitor.azure.com/"

### Private NuGet Feed Access

For developers with access to IntelliTect's private Azure DevOps NuGet feed, you'll need to set up authentication:

**For DevContainer/Local Development:**
Set the `AZURE_DEVOPS_PAT` environment variable with your Azure DevOps Personal Access Token:
```bash
export AZURE_DEVOPS_PAT="your-azure-devops-pat-token"
```

**Creating an Azure DevOps PAT:**
1. Go to Azure DevOps → User Settings → Personal Access Tokens
2. Create a new token with **Packaging (Read)** permissions
3. Copy the token and set it as the environment variable above

**Without Private Feed Access:**
If you don't have access to the private feed, set `<AccessToNugetFeed>false</AccessToNugetFeed>` in `Directory.Packages.props`

Testing Secret Values:
Some Value Secrets for Testing/Development Purposes:
HCaptcha: https://docs.hcaptcha.com/#integration-testing-test-keys
Expand Down
6 changes: 6 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@
<package pattern="ContentFeedNuget" />
</packageSource>
</packageSourceMapping>
<packageSourceCredentials>
<EssentialCSharp>
<add key="Username" value="devcontainer" />
<add key="ClearTextPassword" value="test-token" />
</EssentialCSharp>
</packageSourceCredentials>
</configuration>