-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Update Devcontainer Configuration #25274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
cacde42
Modernize Dev Container Configuration for PowerShell Development
JustinGrote 129db4e
Further Devcontainer Updates
JustinGrote 59286fb
Add debug symbolic link to enable easy access to published image
JustinGrote 0916b2b
Remove PrelaunchTask requirement for debug
JustinGrote 6e24c4b
Add debug symlink to poststart
JustinGrote 6e3f10a
Convert to Dockerfile based devcontainer to embed startup scripts
JustinGrote b3e68d3
Supress progress cluttering the codespaces prebuild logs
JustinGrote d577ec3
Revise tasks to use the shell at the default pwsh path (to allow cust…
JustinGrote 4583361
More terminal fixes
JustinGrote 1bb7e39
Fix debug pwsh to use absolute path
JustinGrote b5e94bf
Update default formatters for various languages
JustinGrote b1211f1
Remove typo
JustinGrote d5db1e7
Add back workspacemount to account for codespaces
JustinGrote 1624058
Build: Add `-PublishLinkPath` to `Start-PSBuild`
JustinGrote dcc1fdd
Better symbolic linking to deal with named volumes etc.
JustinGrote 37e354e
Fix target and swallow output object
JustinGrote 9672ec7
Use relative path for debug
JustinGrote 2ecffef
Absolute path to symlinked terminal
JustinGrote f9f777c
Suppress moduleload and exceptions in PowerShell Dev Console Launch C…
JustinGrote f16e7d5
Update extensions
JustinGrote 8e0068f
Remove "JG" prefix
JustinGrote bd407bd
Change name to "PowerShell Dev"
JustinGrote File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,5 @@ | ||
| #------------------------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. | ||
| #------------------------------------------------------------------------------------------------------------- | ||
| ARG VARIANT=preview | ||
| FROM mcr.microsoft.com/devcontainers/dotnet:${VARIANT} | ||
|
|
||
| FROM mcr.microsoft.com/powershell/test-deps:ubuntu-20.04@sha256:d1609c57d2426b9cfffa3a3ab7bda5ebc4448700f8ba8ef377692c4a70e64b8c | ||
|
|
||
| # Avoid warnings by switching to noninteractive | ||
| ENV DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| # Configure apt and install packages | ||
| RUN apt-get update \ | ||
| && apt-get -y upgrade \ | ||
| && apt-get -y install --no-install-recommends apt-utils 2>&1 \ | ||
| # | ||
| # Verify git, process tools, lsb-release (common in install instructions for CLIs) installed | ||
| && apt-get -y install --no-install-recommends git procps lsb-release \ | ||
| # | ||
| # Clean up | ||
| && apt-get autoremove -y \ | ||
| && apt-get clean -y \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Switch back to dialog for any ad-hoc use of apt-get | ||
| ENV DEBIAN_FRONTEND=dialog | ||
| # This is a workaround for https://github.com/microsoft/vscode-remote-release/issues/10934 | ||
| ADD ./scripts /devcontainer/scripts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #Docs: https://containers.dev/implementors/json_reference/#lifecycle-scripts | ||
| $ErrorActionPreference = 'Stop' | ||
| $ProgressPreference = 'SilentlyContinue' | ||
|
|
||
| # The workspace folder name can be variable, we need a stable target for some settings like terminal path | ||
| $absolutePath = '/powershell' | ||
| . $PSScriptRoot/shared.ps1 | ||
|
|
||
| if ($PWD -ne $absolutePath) { | ||
| log "Linking $SCRIPT:WorkspaceFolder to $absolutePath" | ||
| sudo ln -s $SCRIPT:WorkspaceFolder /powershell | ||
| log "Adding $absolutePath to git safe directories" | ||
| git config --global --add safe.directory $absolutePath | ||
| } | ||
|
|
||
| log "Adding $SCRIPT:WorkspaceFolder to git safe directories" | ||
| git config --global --add safe.directory $SCRIPT:WorkspaceFolder | ||
|
|
||
|
|
||
| # NOTE: We override the Azure Devops private feed as it may not be up to date with the required packages | ||
| # This is only for development and not builds so any potential vulnerabilities will be caught at CI time | ||
| # If you want to restore private restore behavior for testing, perform the following: | ||
| # PS> dotnet nuget disable source nuget.org;dotnet nuget enable source powershell | ||
|
|
||
| #Because several PowerSHell build steps request you to use -UseNugetOrg, these files get changed when you do that. We ignore this in the codespaces so they do not get accidentally committed to PRs. You can always use --no-skip-worktree after build if you intentionally want to modify these files. | ||
| log 'Ignoring nuget.config changes' | ||
| git update-index --skip-worktree nuget.config src/Modules/nuget.config test/tools/Modules/nuget.config | ||
|
|
||
| log 'Switching to Nuget.Org Packages Only for Codespaces Development' | ||
| Import-Module ./build.psm1 | ||
| Switch-PSNugetConfig -Source NuGetOnly |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| #Docs: https://containers.dev/implementors/json_reference/#lifecycle-scripts | ||
| $ErrorActionPreference = 'Stop' | ||
| $ProgressPreference = 'SilentlyContinue' | ||
|
|
||
| . $PSScriptRoot/shared.ps1 | ||
| Import-Module -Force ./build.psm1 | ||
|
|
||
| #If doing a clone into devcontainer, VSCode defaults to a shallow clone. The build process does not support shallow | ||
| #clones due to the use of git tag describe, so we must "unshallow" it if this occurs | ||
| if ((git rev-parse --is-shallow-repository) -ne 'false') { | ||
| log 'Shallow Clone detected, this is not supported by the PowerShell build process. Unshallowing...' | ||
| git fetch --unshallow | ||
| } | ||
|
|
||
| # Fetch upstream tags. The PowerShell dotnet restore requires this (GetPSCoreVersionFromGit) | ||
| log 'Syncing PowerShell Git Tags from Remote' | ||
| Sync-PSTags -AddRemoteIfMissing | ||
|
|
||
| log 'Bootstrap PowerShell Build Prerequisites' | ||
|
|
||
| Start-PSBootstrap -Scenario DotNet | ||
|
|
||
| #Ping is needed for tests but is not included in the .NET SDK devcontainer and PSBootstrap doesn't cover it | ||
| log 'Installing iputils (for the ping utility)' | ||
| sudo apt install iputils-ping -y | ||
|
|
||
| # Perform an initial build of PowerShell, this is needed so the "pwsh dev" terminal and debug launch tasks are available on first run | ||
| log "Building PowerShell" | ||
| Start-PSBuild -UseNugetOrg -Clean -PublishLinkPath debug | ||
|
|
||
| # Prebuild more if in a codespace, otherwise leave this to the user to optimize local startup time | ||
| if ($ENV:CODESPACES) { | ||
| log 'Prebuilding Tests' | ||
| dotnet build test/xUnit | ||
| log 'Fetching Pester for Tests' | ||
| Restore-PSPester | ||
| log 'Build Testing Tools' | ||
| Publish-PSTestTools | ||
| Publish-CustomConnectionTestModule | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #Docs: https://containers.dev/implementors/json_reference/#lifecycle-scripts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #Docs: https://containers.dev/implementors/json_reference/#lifecycle-scripts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #Docs: https://containers.dev/implementors/json_reference/#lifecycle-scripts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| function log ([string[]]$message) { | ||
| $message = $message -join ' ' | ||
| Write-Host -ForegroundColor Cyan $message | ||
| } | ||
|
|
||
| #Devcontainer scripts should have their CWD set to the workspace folder, so we use this for our needed paths | ||
| $SCRIPT:WorkspaceFolder = $PWD | ||
|
|
||
| # Suppresses ANSI Output in Codespaces Build Output | ||
| # $env:CODESPACES is a "magic variable" in the codespaces CI that can be used to detect it | ||
| if ($env:CODESPACES) { | ||
| [Environment]::SetEnvironmentVariable('TERM', 'dumb', [EnvironmentVariableTarget]::User) | ||
| [Environment]::SetEnvironmentVariable('TERM', 'dumb', [EnvironmentVariableTarget]::Process) | ||
| $ENV:TERM = 'dumb' | ||
| $ENV:NO_COLOR = $true | ||
| $ENV:DOTNET_CLI_CONTEXT_ANSI_PASS_THRU = $false | ||
| $ENV:DOTNET_CLI_CONTEXT_VERBOSE = $false | ||
| $PSStyle.OutputRendering = 'PlainText' | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ obj/ | |
| project.lock.json | ||
| *-tests.xml | ||
| /debug/ | ||
| /debug | ||
| /staging/ | ||
| /Packages/ | ||
| *.nuget.props | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.