diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index aecaa942..1aa53f2e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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" } diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh new file mode 100755 index 00000000..295d487e --- /dev/null +++ b/.devcontainer/setup.sh @@ -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" \ No newline at end of file diff --git a/README.md b/README.md index 13a5319b..19c1b1fb 100644 --- a/README.md +++ b/README.md @@ -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 `true` to `false` 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 `true` to `false` 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 `false` +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) @@ -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 `false` in `Directory.Packages.props` + Testing Secret Values: Some Value Secrets for Testing/Development Purposes: HCaptcha: https://docs.hcaptcha.com/#integration-testing-test-keys diff --git a/nuget.config b/nuget.config index 65bcde44..5de97691 100644 --- a/nuget.config +++ b/nuget.config @@ -14,4 +14,10 @@ + + + + + +