Skip to content
Merged
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
9 changes: 9 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Dockerfile for Azure PowerShell devcontainer
# Use official .NET 8.0 image for amd64 architecture
FROM --platform=linux/amd64 mcr.microsoft.com/devcontainers/dotnet:1-8.0

# Set working directory
WORKDIR /workspace

Comment on lines +5 to +7
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The working directory is set to /workspace, but the devcontainer.json mounts the workspace at /workspaces/${localWorkspaceFolderBasename} (note the plural "workspaces"). This mismatch means the WORKDIR directive has no practical effect since the actual workspace will be mounted at a different location.

Consider either:

  1. Removing this WORKDIR directive as it's not needed (the devcontainer will automatically set the working directory to the mounted workspace), or
  2. Changing it to match the actual mount point if you need to ensure consistency
Suggested change
# Set working directory
WORKDIR /workspace

Copilot uses AI. Check for mistakes.
# Set default user to root for pwsh compatibility
USER root
Comment on lines +7 to +9
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The USER root directive is redundant here because the base image mcr.microsoft.com/devcontainers/dotnet:1-8.0 already runs as a non-root user by default, and the devcontainer.json explicitly sets "remoteUser": "root" on line 47, which will override any USER directive in the Dockerfile.

This line can be safely removed as it has no effect given the devcontainer.json configuration.

Suggested change
# Set default user to root for pwsh compatibility
USER root

Copilot uses AI. Check for mistakes.
35 changes: 22 additions & 13 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet
{
"name": "C# (.NET)",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/dotnet:1-8.0",
// Use a Dockerfile for custom configuration

"context": "..",

"dockerFile": "Dockerfile",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
Expand All @@ -15,28 +18,34 @@
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [5000, 5001],
// "portsAttributes": {
// "5001": {
// "protocol": "https"
// }
// }

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npm install -g autorest",
"postCreateCommand": "./.devcontainer/post-create.ps1",

// Configure tool-specific properties.
"customizations": {
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-dotnettools.csharp"
]
],
// Minimal settings to improve file search and git performance
"settings": {
"files.watcherExclude": {
"**/artifacts/**": true,
"**/.git/objects/**": true,
"**/node_modules/**": true
},
"search.exclude": {
"**/artifacts/**": true
}
}
}
},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// this will allow us to call pwsh in scripts
"remoteUser": "root"
"remoteUser": "root",

// Mount optimization for macOS
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind,consistency=cached"
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The workspaceMount uses the deprecated "consistency" option with value "cached". Docker Desktop for Mac deprecated the consistency flags (cached, delegated, consistent) in favor of automatic optimization. Modern versions of Docker Desktop ignore these flags, and they have no effect on Linux or Windows.

This option can be safely removed from the workspaceMount configuration as it no longer provides any benefit and may cause warnings in newer Docker versions.

Suggested change
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind,consistency=cached"
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind"

Copilot uses AI. Check for mistakes.
}
27 changes: 27 additions & 0 deletions .devcontainer/post-create.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env pwsh
#Requires -Version 7.0

$ErrorActionPreference = "Stop"
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The script uses Set-StrictMode is missing, which is a PowerShell best practice for catching errors early. According to the coding guidelines for PowerShell scripts in this repository, scripts should include Set-StrictMode -Version 2.0 (or higher) for better error catching.

Add Set-StrictMode -Version 2.0 after the ErrorActionPreference setting.

Suggested change
$ErrorActionPreference = "Stop"
$ErrorActionPreference = "Stop"
Set-StrictMode -Version 2.0

Copilot uses AI. Check for mistakes.

Write-Host "📦 Updating npm..." -ForegroundColor Cyan
npm update -g npm
if ($LASTEXITCODE -ne 0) {
throw "Failed to update npm"
}

Write-Host "🚀 Installing AutoRest..." -ForegroundColor Cyan
npm install -g autorest
if ($LASTEXITCODE -ne 0) {
throw "Failed to install AutoRest"
Comment on lines +6 to +15
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The script includes proper error handling with $ErrorActionPreference = "Stop", try-catch blocks for exit codes, and -ErrorAction Stop for PowerShell cmdlets. However, the npm update and npm install commands could fail in non-obvious ways. Consider adding informative error messages that include troubleshooting hints, such as checking network connectivity or npm installation.

For example, wrap the npm operations in a try-catch that provides more context about common failure scenarios.

Suggested change
Write-Host "📦 Updating npm..." -ForegroundColor Cyan
npm update -g npm
if ($LASTEXITCODE -ne 0) {
throw "Failed to update npm"
}
Write-Host "🚀 Installing AutoRest..." -ForegroundColor Cyan
npm install -g autorest
if ($LASTEXITCODE -ne 0) {
throw "Failed to install AutoRest"
try {
Write-Host "📦 Updating npm..." -ForegroundColor Cyan
npm update -g npm
if ($LASTEXITCODE -ne 0) {
throw "npm update failed with exit code $LASTEXITCODE"
}
Write-Host "🚀 Installing AutoRest..." -ForegroundColor Cyan
npm install -g autorest
if ($LASTEXITCODE -ne 0) {
throw "AutoRest installation failed with exit code $LASTEXITCODE"
}
} catch {
Write-Error "npm tooling setup failed: $($_.Exception.Message)"
Write-Error ("Troubleshooting tips:`n" +
" - Verify that Node.js and npm are installed and on the PATH (run 'npm --version').`n" +
" - Check your network connectivity and any proxy/firewall settings that might block npm.`n" +
" - If behind a proxy, configure npm to use it (e.g. 'npm config set proxy <url>').`n" +
" - Retry this script after addressing the above issues.")
exit 1

Copilot uses AI. Check for mistakes.
}

Write-Host "⚡ Installing platyPS..." -ForegroundColor Cyan
Install-Module -Name platyPS -Force -Scope CurrentUser -ErrorAction Stop

Write-Host "🔐 Installing Az.Accounts for authentication..." -ForegroundColor Cyan
Install-Module -Name Az.Accounts -Force -Scope CurrentUser -ErrorAction Stop

Write-Host "🧪 Installing PSScriptAnalyzer for static analysis..." -ForegroundColor Cyan
Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser -ErrorAction Stop

Write-Host "✅ Post-create setup completed successfully!" -ForegroundColor Green
Loading