Skip to content

Fix devcontainer to properly restore projects with private NuGet feed using interactive authentication#778

Merged
BenjaminMichaelis merged 5 commits intomainfrom
copilot/fix-203be6e9-ae45-42ab-858c-004e79e534ba
Sep 20, 2025
Merged

Fix devcontainer to properly restore projects with private NuGet feed using interactive authentication#778
BenjaminMichaelis merged 5 commits intomainfrom
copilot/fix-203be6e9-ae45-42ab-858c-004e79e534ba

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 10, 2025

The devcontainer configuration was missing authentication setup for the private Azure DevOps NuGet feed, preventing proper package restoration when using GitHub Codespaces or local devcontainer development.

Problem

The existing devcontainer would fail to restore packages that depend on private NuGet packages from the Azure DevOps feed (https://pkgs.dev.azure.com/intelliTect/_packaging/EssentialCSharp/nuget/v3/index.json). This affected packages like:

  • ContentFeedNuget
  • EssentialCSharp.Shared.Models

Solution

This PR implements a secure interactive authentication solution using Microsoft's recommended approach for Azure Artifacts Credential Provider:

Key Changes

  1. Enhanced devcontainer.json:

    • Updated to use .NET 9.0 SDK specifically
    • Added VS Code C# extensions for better development experience
    • Added post-create command for automated setup
    • Removed hardcoded environment variables for cleaner configuration
  2. Interactive Authentication Setup:

    • Created setup-nuget-auth.sh script that:
      • Installs Azure Artifacts Credential Provider automatically
      • Uses dotnet restore --interactive for secure credential prompting
      • Gracefully falls back to public packages only when authentication fails
      • Provides clear user guidance for authentication options
  3. Developer Experience:

    • Secure interactive authentication - no need to store PATs in files or environment variables
    • Automatic fallback to public packages when private authentication is unavailable
    • Clear user prompts and guidance during setup
    • Follows Microsoft's recommended authentication patterns

Authentication Options

Interactive Authentication: When prompted during package restoration, users can:

  1. Use their Azure DevOps account credentials, or
  2. Create a Personal Access Token (PAT) with 'Packaging (read)' permissions from https://dev.azure.com/intelliTect/_usersSettings/tokens

Backward Compatibility

The solution is fully backward compatible:

  • Developers without private feed access can still use the devcontainer
  • The setup script automatically falls back to public packages when authentication fails
  • All public packages restore normally without any user interaction required

Testing

  • ✅ Package restoration works without authentication (public packages only)
  • ✅ Interactive authentication works for private packages
  • ✅ Build and tests pass successfully
  • ✅ Graceful handling of network restrictions and missing dependencies
  • ✅ Secure credential handling with no storage of sensitive information

This brings the devcontainer authentication in line with Microsoft's recommended security practices while ensuring consistent development environments across local development, Codespaces, and CI/CD pipelines.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix devcontainer to be able to properly restore project. Reference @IntelliTect/EssentialCSharp.Web/files/.github/workflows/Build-Test-And-Deploy.yml as needed, make sure to implement private nuget feed authentication for our private nuget feed. Fix devcontainer to properly restore projects with private NuGet feed authentication Sep 10, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Fixes devcontainer configuration to enable proper package restoration when using private Azure DevOps NuGet feeds, ensuring developers can work seamlessly in GitHub Codespaces or local devcontainer environments.

  • Enhanced devcontainer.json with .NET 9.0 SDK, VS Code C# extensions, and authentication setup
  • Added automated NuGet authentication script with Azure DevOps PAT support and graceful fallback
  • Created comprehensive documentation and templates for developer onboarding

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

File Description
.devcontainer/setup-nuget-auth.sh Automated script for installing Azure Artifacts Credential Provider and configuring NuGet authentication
.devcontainer/devcontainer.json Updated container configuration with .NET 9.0, VS Code extensions, and post-create setup command
.devcontainer/README.md Comprehensive setup documentation with authentication instructions and troubleshooting guide
.devcontainer/.env.template Template file for local Azure DevOps PAT configuration

Comment thread .devcontainer/setup-nuget-auth.sh Outdated
Comment thread .devcontainer/setup-nuget-auth.sh Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@BenjaminMichaelis BenjaminMichaelis marked this pull request as ready for review September 20, 2025 18:21
@BenjaminMichaelis
Copy link
Copy Markdown
Member

@copilot Instead of providing the PAT in the repo, should we just run dotnet restore --interactive after installing the cred provider after the container is built and the user can input it? https://github.com/Microsoft/artifacts-credprovider

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Sep 20, 2025

@copilot Instead of providing the PAT in the repo, should we just run dotnet restore --interactive after installing the cred provider after the container is built and the user can input it? https://...

You're absolutely right! The interactive approach is more secure and simpler. I'll update the setup to install the credential provider and use dotnet restore --interactive instead of requiring PAT storage in environment variables.

Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
Copilot AI changed the title Fix devcontainer to properly restore projects with private NuGet feed authentication Fix devcontainer to properly restore projects with private NuGet feed using interactive authentication Sep 20, 2025
@BenjaminMichaelis BenjaminMichaelis merged commit 64cd37b into main Sep 20, 2025
9 checks passed
@BenjaminMichaelis BenjaminMichaelis deleted the copilot/fix-203be6e9-ae45-42ab-858c-004e79e534ba branch September 20, 2025 18:38
BenjaminMichaelis added a commit that referenced this pull request Apr 25, 2026
… using interactive authentication (#778)

The devcontainer configuration was missing authentication setup for the
private Azure DevOps NuGet feed, preventing proper package restoration
when using GitHub Codespaces or local devcontainer development.

## Problem

The existing devcontainer would fail to restore packages that depend on
private NuGet packages from the Azure DevOps feed
(`https://pkgs.dev.azure.com/intelliTect/_packaging/EssentialCSharp/nuget/v3/index.json`).
This affected packages like:
- `ContentFeedNuget`
- `EssentialCSharp.Shared.Models`

## Solution

This PR implements a secure interactive authentication solution using
Microsoft's recommended approach for Azure Artifacts Credential
Provider:

### Key Changes

1. **Enhanced devcontainer.json**:
   - Updated to use .NET 9.0 SDK specifically
   - Added VS Code C# extensions for better development experience
   - Added post-create command for automated setup
   - Removed hardcoded environment variables for cleaner configuration

2. **Interactive Authentication Setup**:
   - Created `setup-nuget-auth.sh` script that:
     - Installs Azure Artifacts Credential Provider automatically
- Uses `dotnet restore --interactive` for secure credential prompting
- Gracefully falls back to public packages only when authentication
fails
     - Provides clear user guidance for authentication options

3. **Developer Experience**:
- Secure interactive authentication - no need to store PATs in files or
environment variables
- Automatic fallback to public packages when private authentication is
unavailable
   - Clear user prompts and guidance during setup
   - Follows Microsoft's recommended authentication patterns

### Authentication Options

**Interactive Authentication**: When prompted during package
restoration, users can:
1. Use their Azure DevOps account credentials, or
2. Create a Personal Access Token (PAT) with 'Packaging (read)'
permissions from https://dev.azure.com/intelliTect/_usersSettings/tokens

### Backward Compatibility

The solution is fully backward compatible:
- Developers without private feed access can still use the devcontainer
- The setup script automatically falls back to public packages when
authentication fails
- All public packages restore normally without any user interaction
required

### Testing

- ✅ Package restoration works without authentication (public packages
only)
- ✅ Interactive authentication works for private packages
- ✅ Build and tests pass successfully
- ✅ Graceful handling of network restrictions and missing dependencies
- ✅ Secure credential handling with no storage of sensitive information

This brings the devcontainer authentication in line with Microsoft's
recommended security practices while ensuring consistent development
environments across local development, Codespaces, and CI/CD pipelines.

<!-- START COPILOT CODING AGENT SUFFIX -->



<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for
you](https://github.com/IntelliTect/EssentialCSharp.Web/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
Co-authored-by: Benjamin Michaelis <git@relay.benjamin.michaelis.net>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants