diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index e3a2fb57f..000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,21 +0,0 @@ -version: 2 -updates: -- package-ecosystem: nuget - directory: "/" - labels: [ ] - schedule: - interval: weekly - open-pull-requests-limit: 10 - groups: - OmniSharp: - patterns: - - "OmniSharp.Extensions.*" - xUnit: - patterns: - - "xunit" - - "xunit.*" -- package-ecosystem: github-actions - directory: "/" - labels: [ ] - schedule: - interval: weekly diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index ceec61b37..2c504a075 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -30,16 +30,15 @@ jobs: with: cache: true cache-dependency-path: '**/*.csproj' - dotnet-version: | - 6.0.x - 7.0.x - 8.0.x + dotnet-version: 6.0.x + global-json-file: "./global.json" - name: Install PSResources shell: pwsh run: ./tools/installPSResources.ps1 - name: Download daily install script + if: ${{ github.event_name == 'schedule' || github.event_name == 'merge_group' }} uses: actions/checkout@v4 with: repository: PowerShell/PowerShell @@ -47,14 +46,20 @@ jobs: sparse-checkout: tools/install-powershell.ps1 sparse-checkout-cone-mode: false + - name: Install daily + if: ${{ github.event_name == 'schedule' || github.event_name == 'merge_group' }} + continue-on-error: true + shell: pwsh + run: ./pwsh/tools/install-powershell.ps1 -Daily + - name: Build and test shell: pwsh run: Invoke-Build -Configuration Release ${{ github.event_name == 'merge_group' && 'TestFull' || 'Test' }} - - name: Test with daily + - name: Test daily if: ${{ github.event_name == 'schedule' }} shell: pwsh - run: ./pwsh/tools/install-powershell.ps1 -Daily && Invoke-Build -Configuration Release TestE2EDaily + run: Invoke-Build -Configuration Release TestE2EDaily - name: Upload build artifacts if: always() diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 81deb8c41..000000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: CodeQL Analysis - -on: - push: - branches: [ main ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ main ] - paths-ignore: [ '**/*.md' ] - schedule: - - cron: '35 13 * * 4' - -jobs: - analyze: - name: analyze - strategy: - fail-fast: false - matrix: - language: [ csharp ] - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - env: - DOTNET_NOLOGO: true - DOTNET_GENERATE_ASPNET_CERTIFICATE: false - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Install dotnet - uses: actions/setup-dotnet@v4 - with: - cache: true - cache-dependency-path: '**/*.csproj' - - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - - - name: Install PSResources - shell: pwsh - run: tools/installPSResources.ps1 - - - name: Build - shell: pwsh - run: Invoke-Build Build - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: '/language:${{matrix.language}}' diff --git a/.github/workflows/emacs-test.yml b/.github/workflows/emacs-test.yml index 351b233f9..b7ac6da9f 100644 --- a/.github/workflows/emacs-test.yml +++ b/.github/workflows/emacs-test.yml @@ -6,7 +6,6 @@ on: pull_request: # The branches below must be a subset of the branches above branches: [ main ] - paths-ignore: [ '**/*.md' ] merge_group: types: [ checks_requested ] diff --git a/.github/workflows/vim-test.yml b/.github/workflows/vim-test.yml index 90898830d..982049e6f 100644 --- a/.github/workflows/vim-test.yml +++ b/.github/workflows/vim-test.yml @@ -6,7 +6,6 @@ on: pull_request: # The branches below must be a subset of the branches above branches: [ main ] - paths-ignore: [ '**/*.md' ] merge_group: types: [ checks_requested ] @@ -36,7 +35,10 @@ jobs: run: Invoke-Build Build - name: Install Vim + id: vim uses: rhysd/action-setup-vim@v1 + with: + version: nightly - name: Checkout vim-ps1 uses: actions/checkout@v4 @@ -60,6 +62,9 @@ jobs: repository: thinca/vim-themis path: vim-themis + # - name: Debug if run with debugging enabled + # uses: lhotari/action-upterm@v1 + - name: Run Themis with full CLI env: THEMIS_VIM: ${{ steps.vim.outputs.executable }} diff --git a/.gitignore b/.gitignore index ae0c4384b..d8c2d5b16 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,4 @@ bin/ obj/ -module/PowerShellEditorServices/NOTICE.txt -module/PowerShellEditorServices/Commands/en-US/ -module/Plaster/ -module/PSReadLine/ -module/PSScriptAnalyzer/ +module/ TestResults/ diff --git a/.pipelines/PowerShellEditorServices-Official.yml b/.pipelines/PowerShellEditorServices-Official.yml index 4e9a8743a..79e2a85a3 100644 --- a/.pipelines/PowerShellEditorServices-Official.yml +++ b/.pipelines/PowerShellEditorServices-Official.yml @@ -8,7 +8,16 @@ # Support: https://aka.ms/onebranchsup # ################################################################################# -trigger: none +trigger: +- main + +schedules: +- cron: '35 13 * * 4' + displayName: Weekly CodeQL + branches: + include: + - main + always: true parameters: - name: debug @@ -19,7 +28,7 @@ parameters: variables: system.debug: ${{ parameters.debug }} BuildConfiguration: Release - WindowsContainerImage: onebranch.azurecr.io/windows/ltsc2019/vse2022:latest + WindowsContainerImage: onebranch.azurecr.io/windows/ltsc2022/vse2022:latest DOTNET_NOLOGO: true DOTNET_GENERATE_ASPNET_CERTIFICATE: false @@ -38,6 +47,13 @@ extends: asyncSdl: enabled: true forStages: [build] + featureFlags: + EnableCDPxPAT: false + WindowsHostVersion: + Version: 2022 + Network: KS3 + release: + category: NonAzure stages: - stage: build jobs: @@ -46,7 +62,7 @@ extends: pool: type: windows variables: - ob_outputDirectory: $(Build.SourcesDirectory)/module + ob_outputDirectory: $(Build.SourcesDirectory)/out steps: - pwsh: | [xml]$xml = Get-Content PowerShellEditorServices.Common.props @@ -66,23 +82,18 @@ extends: displayName: Use .NET 8.x SDK inputs: packageType: sdk - version: 8.x - - task: UseDotNet@2 - displayName: Use .NET 7.x runtime (for tests) - inputs: - packageType: runtime - version: 7.x + useGlobalJson: true - task: UseDotNet@2 displayName: Use .NET 6.x runtime (for tests) inputs: packageType: runtime version: 6.x - - task: PowerShell@2 + - pwsh: | + Register-PSRepository -Name CFS -SourceLocation "https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/nuget/v2" -InstallationPolicy Trusted + Install-Module -Repository CFS -Name Microsoft.PowerShell.PSResourceGet + ./tools/installPSResources.ps1 -PSRepository CFS displayName: Install PSResources - inputs: - pwsh: true - filePath: tools/installPSResources.ps1 - - pwsh: Invoke-Build TestFull -Configuration $(BuildConfiguration) + - pwsh: Invoke-Build TestFull -Configuration $(BuildConfiguration) -PSRepository CFS displayName: Build and test - task: PublishTestResults@2 displayName: Publish test results @@ -123,35 +134,37 @@ extends: **/OmniSharp.Extensions*.dll; **/Serilog*.dll; **/System.Reactive.dll; + - task: ArchiveFiles@2 + displayName: Zip signed artifacts + inputs: + rootFolderOrFile: $(Build.SourcesDirectory)/module + includeRootFolder: false + archiveType: zip + archiveFile: out/PowerShellEditorServices.zip - stage: release dependsOn: build + condition: eq(variables['Build.Reason'], 'Manual') variables: + ob_release_environment: Production version: $[ stageDependencies.build.main.outputs['package.version'] ] prerelease: $[ stageDependencies.build.main.outputs['package.prerelease'] ] - drop: $(Pipeline.Workspace)/drop_build_main jobs: - job: github displayName: Publish draft to GitHub pool: - type: windows - variables: - ob_outputDirectory: $(Build.SourcesDirectory)/out - steps: - - download: current - displayName: Download artifacts - - task: ArchiveFiles@2 - displayName: Zip signed artifacts + type: release + templateContext: inputs: - rootFolderOrFile: $(drop) - includeRootFolder: false - archiveType: zip - archiveFile: out/PowerShellEditorServices.zip + - input: pipelineArtifact + artifactName: drop_build_main + steps: - task: GitHubRelease@1 displayName: Create GitHub release inputs: gitHubConnection: GitHub repositoryName: PowerShell/PowerShellEditorServices - assets: out/PowerShellEditorServices.zip + target: main + assets: $(Pipeline.Workspace)/PowerShellEditorServices.zip tagSource: userSpecifiedTag tag: v$(version) isDraft: true diff --git a/CHANGELOG.md b/CHANGELOG.md index e9dffa950..b44fa94b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # PowerShell Editor Services Release History +## v3.21.0 +### Wednesday, October 30, 2024 + +See more details at the GitHub Release for [v3.21.0](https://github.com/PowerShell/PowerShellEditorServices/releases/tag/v3.21.0). + +Updates to PSScriptAnalyzer and Call-operator support + ## v3.20.1 ### Friday, May 03, 2024 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index dddfa22df..686e5e7a0 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,8 +1,10 @@ -# Code of Conduct +# Microsoft Open Source Code of Conduct -This project has adopted the [Microsoft Open Source Code of Conduct][conduct-code]. -For more information see the [Code of Conduct FAQ][conduct-FAQ] or contact [opencode@microsoft.com][conduct-email] with any additional questions or comments. +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -[conduct-code]: http://opensource.microsoft.com/codeofconduct/ -[conduct-FAQ]: http://opensource.microsoft.com/codeofconduct/faq/ -[conduct-email]: mailto:opencode@microsoft.com +Resources: + +- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) +- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns +- Employees can reach out at [aka.ms/opensource/moderation-support](https://aka.ms/opensource/moderation-support) diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 000000000..193280892 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,5 @@ + + + true + + diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 000000000..92a025bed --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PowerShellEditorServices.Common.props b/PowerShellEditorServices.Common.props index 0abe50b0f..cc0dc7531 100644 --- a/PowerShellEditorServices.Common.props +++ b/PowerShellEditorServices.Common.props @@ -1,6 +1,6 @@ - 3.20.1 + 3.21.0 Microsoft © Microsoft Corporation. diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index fecc39a01..02a5d6436 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -7,11 +7,7 @@ param( [switch]$LocalOmniSharp, - [string]$PsesSubmodulePath = "$PSScriptRoot/module", - - [string]$ModulesJsonPath = "$PSScriptRoot/modules.json", - - [string]$DefaultModuleRepository = "PSGallery", + [string]$PSRepository = "PSGallery", [string]$Verbosity = "minimal", @@ -22,8 +18,8 @@ param( [string[]]$TestArgs = @("--logger", "console;verbosity=minimal", "--logger", "trx") ) -#Requires -Modules @{ModuleName="InvokeBuild"; ModuleVersion="5.0.0"} -#Requires -Modules @{ModuleName="platyPS"; ModuleVersion="0.14.0"} +#Requires -Modules @{ModuleName = "InvokeBuild"; ModuleVersion = "5.0.0"} +#Requires -Modules @{ModuleName = "platyPS"; ModuleVersion = "0.14.2"} $script:dotnetBuildArgs = @( "--verbosity" @@ -40,29 +36,22 @@ $script:dotnetTestArgs = @("test") + $script:dotnetBuildArgs + $TestArgs + @( ) $script:IsNix = $IsLinux -or $IsMacOS -# For Apple M1, pwsh might be getting emulated, in which case we need to check -# for the proc_translated flag, otherwise we can check the architecture. -$script:IsAppleM1 = $IsMacOS -and ((sysctl -n sysctl.proc_translated 2> $null) -eq 1 -or - [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture -eq "Arm64") -$script:IsArm64 = -not $script:IsNix -and @("ARM64") -contains $env:PROCESSOR_ARCHITECTURE -$script:BuildInfoPath = [System.IO.Path]::Combine($PSScriptRoot, "src", "PowerShellEditorServices.Hosting", "BuildInfo.cs") -$script:PsesCommonProps = [xml](Get-Content -Raw "$PSScriptRoot/PowerShellEditorServices.Common.props") +$script:BuildInfoPath = "src/PowerShellEditorServices.Hosting/BuildInfo.cs" $script:NetFramework = @{ PS51 = 'net462' PS72 = 'net6.0' - PS73 = 'net7.0' PS74 = 'net8.0' Standard = 'netstandard2.0' } -$script:HostCoreOutput = "$PSScriptRoot/src/PowerShellEditorServices.Hosting/bin/$Configuration/$($script:NetFramework.PS72)/publish" -$script:HostDeskOutput = "$PSScriptRoot/src/PowerShellEditorServices.Hosting/bin/$Configuration/$($script:NetFramework.PS51)/publish" -$script:PsesOutput = "$PSScriptRoot/src/PowerShellEditorServices/bin/$Configuration/$($script:NetFramework.Standard)/publish" +$script:HostCoreOutput = "src/PowerShellEditorServices.Hosting/bin/$Configuration/$($script:NetFramework.PS72)/publish" +$script:HostDeskOutput = "src/PowerShellEditorServices.Hosting/bin/$Configuration/$($script:NetFramework.PS51)/publish" +$script:PsesOutput = "src/PowerShellEditorServices/bin/$Configuration/$($script:NetFramework.Standard)/publish" if (Get-Command git -ErrorAction SilentlyContinue) { # ignore changes to this file - git update-index --assume-unchanged "$PSScriptRoot/src/PowerShellEditorServices.Hosting/BuildInfo.cs" + git update-index --assume-unchanged $script:BuildInfoPath } Task FindDotNet { @@ -72,61 +61,36 @@ Task FindDotNet { [Version]$existingVersion, $null = (dotnet --version) -split " " -split "-" Assert ($existingVersion -ge [Version]("8.0")) ".NET SDK 8.0 or higher is required, please update it: https://aka.ms/dotnet-cli" - Write-Host "Using dotnet v$(dotnet --version) at path $((Get-Command dotnet).Source)" -ForegroundColor Green + Write-Build DarkGreen "Using dotnet v$(dotnet --version) at path $((Get-Command dotnet).Source)" } -Task BinClean { - Remove-BuildItem $PSScriptRoot\.tmp - Remove-BuildItem $PSScriptRoot\module\PowerShellEditorServices\bin -} - -Task Clean FindDotNet, BinClean, { +Task Clean FindDotNet, { + Write-Build DarkMagenta "Cleaning PowerShellEditorServices" Invoke-BuildExec { & dotnet clean --verbosity $Verbosity } - Remove-BuildItem $PSScriptRoot\src\*.nupkg - Remove-BuildItem $PSScriptRoot\PowerShellEditorServices*.zip - Remove-BuildItem $PSScriptRoot\module\PowerShellEditorServices\Commands\en-US\*-help.xml - - # Remove bundled component modules - $moduleJsonPath = "$PSScriptRoot\modules.json" - if (Test-Path $moduleJsonPath) { - Get-Content -Raw $moduleJsonPath | - ConvertFrom-Json | - ForEach-Object { $_.PSObject.Properties.Name } | - ForEach-Object { Remove-BuildItem -Path "$PSScriptRoot/module/$_" } - } + Remove-BuildItem module/PowerShellEditorServices/bin + Remove-BuildItem module/PowerShellEditorServices/Commands/en-US/*-help.xml + Remove-BuildItem module/PSReadLine + Remove-BuildItem module/PSScriptAnalyzer } Task CreateBuildInfo { - $buildVersion = "" $buildOrigin = "Development" $buildCommit = git rev-parse HEAD + [xml]$xml = Get-Content "PowerShellEditorServices.Common.props" + $buildVersion = $xml.Project.PropertyGroup.VersionPrefix + $prerelease = $xml.Project.PropertyGroup.VersionSuffix + if ($prerelease) { $buildVersion += "-$prerelease" } + # Set build info fields on build platforms - if ($env:TF_BUILD) { - if ($env:BUILD_BUILDNUMBER -like "PR-*") { - $buildOrigin = "PR" - } elseif ($env:BUILD_DEFINITIONNAME -like "*-CI") { - $buildOrigin = "CI" - } else { + if ($env:TF_BUILD) { # Azure DevOps AKA OneBranch + if ($env:BUILD_REASON -like "Manual") { $buildOrigin = "Release" + } else { + $buildOrigin = "AzureDevOps-CI" } - - $propsXml = [xml](Get-Content -Raw -LiteralPath "$PSScriptRoot/PowerShellEditorServices.Common.props") - $propsBody = $propsXml.Project.PropertyGroup - $buildVersion = $propsBody.VersionPrefix - - if ($propsBody.VersionSuffix) { - $buildVersion += '-' + $propsBody.VersionSuffix - } - } - - # Allow override of build info fields (except date) - if ($env:PSES_BUILD_VERSION) { - $buildVersion = $env:PSES_BUILD_VERSION - } - - if ($env:PSES_BUILD_ORIGIN) { - $buildOrigin = $env:PSES_BUILD_ORIGIN + } elseif ($env:GITHUB_ACTIONS) { + $buildOrigin = "GitHub-CI" } [string]$buildTime = [datetime]::Today.ToString("s", [System.Globalization.CultureInfo]::InvariantCulture) @@ -150,49 +114,100 @@ namespace Microsoft.PowerShell.EditorServices.Hosting "@ if (Compare-Object $buildInfoContents.Split([Environment]::NewLine) (Get-Content $script:BuildInfoPath)) { - Write-Host "Updating build info." + Write-Build DarkMagenta "Updating build info" Set-Content -LiteralPath $script:BuildInfoPath -Value $buildInfoContents -Force } } -Task SetupHelpForTests { - # TODO: Check if it must be updated in a compatible way! - Write-Host "Updating help for tests." - Update-Help -Module Microsoft.PowerShell.Management,Microsoft.PowerShell.Utility -Force -Scope CurrentUser -UICulture en-US +task RestorePsesModules -If (-not (Test-Path "module/PSReadLine") -or -not (Test-Path "module/PSScriptAnalyzer")) { + Write-Build DarkMagenta "Restoring bundled modules" + Save-Module -Path module -Repository $PSRepository -Name PSScriptAnalyzer -RequiredVersion "1.23.0" -Verbose + Save-Module -Path module -Repository $PSRepository -Name PSReadLine -RequiredVersion "2.4.0-beta0" -AllowPrerelease -Verbose } -Task Build FindDotNet, CreateBuildInfo, { - Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script:NetFramework.Standard } - Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetFramework.PS72 } +Task Build FindDotNet, CreateBuildInfo, RestorePsesModules, { + Write-Build DarkGreen "Building PowerShellEditorServices" + Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs ./src/PowerShellEditorServices/PowerShellEditorServices.csproj -f $script:NetFramework.Standard } + Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs ./src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj -f $script:NetFramework.PS72 } if (-not $script:IsNix) { - Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetFramework.PS51 } + Invoke-BuildExec { & dotnet publish $script:dotnetBuildArgs ./src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj -f $script:NetFramework.PS51 } } } -# The concise set of tests (for pull requests) -Task Test TestPS74, TestE2EPwsh, TestPS51, TestE2EPowerShell +Task AssembleModule -After Build { + Write-Build DarkGreen "Assembling PowerShellEditorServices module" + $psesOutputPath = "./module/PowerShellEditorServices" + $psesBinOutputPath = "$psesOutputPath/bin" + $psesDepsPath = "$psesBinOutputPath/Common" + $psesCoreHostPath = "$psesBinOutputPath/Core" + $psesDeskHostPath = "$psesBinOutputPath/Desktop" -# Every combination of tests (for main branch) -Task TestFull Test, TestPS73, TestPS72, TestE2EPwshCLM, TestE2EPowerShellCLM + foreach ($dir in $psesDepsPath, $psesCoreHostPath, $psesDeskHostPath) { + New-Item -Force -Path $dir -ItemType Directory | Out-Null + } -Task TestPS74 Build, SetupHelpForTests, { - Set-Location .\test\PowerShellEditorServices.Test\ - Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetFramework.PS74 } + # Copy documents to module root + foreach ($document in @("LICENSE", "NOTICE.txt", "README.md", "SECURITY.md")) { + Copy-Item -Force -Path $document -Destination "./module" + } + + # Assemble PSES module + $includedDlls = [System.Collections.Generic.HashSet[string]]::new() + [void]$includedDlls.Add('System.Management.Automation.dll') + + # PSES/bin/Common + foreach ($psesComponent in Get-ChildItem $script:PsesOutput) { + if ($psesComponent.Name -eq 'System.Management.Automation.dll' -or + $psesComponent.Name -eq 'System.Runtime.InteropServices.RuntimeInformation.dll') { + continue + } + + if ($psesComponent.Extension) { + [void]$includedDlls.Add($psesComponent.Name) + Copy-Item -Path $psesComponent.FullName -Destination $psesDepsPath -Force + } + } + + # PSES/bin/Core + foreach ($hostComponent in Get-ChildItem $script:HostCoreOutput) { + if (-not $includedDlls.Contains($hostComponent.Name)) { + Copy-Item -Path $hostComponent.FullName -Destination $psesCoreHostPath -Force + } + } + + # PSES/bin/Desktop + if (-not $script:IsNix) { + foreach ($hostComponent in Get-ChildItem $script:HostDeskOutput) { + if (-not $includedDlls.Contains($hostComponent.Name)) { + Copy-Item -Path $hostComponent.FullName -Destination $psesDeskHostPath -Force + } + } + } +} + +Task BuildCmdletHelp -After AssembleModule { + Write-Build DarkGreen "Building cmdlet help" + New-ExternalHelp -Path ./module/docs -OutputPath ./module/PowerShellEditorServices/Commands/en-US -Force } -Task TestPS73 Build, SetupHelpForTests, { - Set-Location .\test\PowerShellEditorServices.Test\ - Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetFramework.PS73 } +Task SetupHelpForTests { + Write-Build DarkMagenta "Updating help (for tests)" + Update-Help -Module Microsoft.PowerShell.Management,Microsoft.PowerShell.Utility -Force -Scope CurrentUser -UICulture en-US +} + +Task TestPS74 Build, SetupHelpForTests, { + Set-Location ./test/PowerShellEditorServices.Test/ + Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetFramework.PS74 } } Task TestPS72 Build, SetupHelpForTests, { - Set-Location .\test\PowerShellEditorServices.Test\ + Set-Location ./test/PowerShellEditorServices.Test/ Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetFramework.PS72 } } Task TestPS51 -If (-not $script:IsNix) Build, SetupHelpForTests, { - Set-Location .\test\PowerShellEditorServices.Test\ + Set-Location ./test/PowerShellEditorServices.Test/ # TODO: See https://github.com/dotnet/sdk/issues/18353 for x64 test host # that is debuggable! If architecture is added, the assembly path gets an # additional folder, necessitating fixes to find the commands definition @@ -211,7 +226,7 @@ Task TestPS51 -If (-not $script:IsNix) Build, SetupHelpForTests, { # NOTE: The framework for the E2E tests applies to the mock client, and so # should just be the latest supported framework. Task TestE2EPwsh Build, SetupHelpForTests, { - Set-Location .\test\PowerShellEditorServices.Test.E2E\ + Set-Location ./test/PowerShellEditorServices.Test.E2E/ $env:PWSH_EXE_NAME = "pwsh" Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetFramework.PS74 } } @@ -219,18 +234,18 @@ Task TestE2EPwsh Build, SetupHelpForTests, { $PwshDaily = if ($script:IsNix) { "$HOME/.powershell-daily/pwsh" } else { - "$env:LOCALAPPDATA\Microsoft\powershell-daily\pwsh.exe" + "$env:LOCALAPPDATA/Microsoft/powershell-daily/pwsh.exe" } Task TestE2EDaily -If (Test-Path $PwshDaily) Build, SetupHelpForTests, { - Set-Location .\test\PowerShellEditorServices.Test.E2E\ + Set-Location ./test/PowerShellEditorServices.Test.E2E/ $env:PWSH_EXE_NAME = $PwshDaily - Write-Host "Running end-to-end tests with: $(& $PwshDaily --version)" + Write-Build DarkGreen "Running end-to-end tests with: $(& $PwshDaily --version)" Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetFramework.PS74 } } Task TestE2EPowerShell -If (-not $script:IsNix) Build, SetupHelpForTests, { - Set-Location .\test\PowerShellEditorServices.Test.E2E\ + Set-Location ./test/PowerShellEditorServices.Test.E2E/ $env:PWSH_EXE_NAME = "powershell" try { # TODO: See https://github.com/PowerShell/vscode-powershell/issues/3886 @@ -244,16 +259,16 @@ Task TestE2EPowerShell -If (-not $script:IsNix) Build, SetupHelpForTests, { } Task TestE2EPwshCLM -If (-not $script:IsNix) Build, SetupHelpForTests, { - Set-Location .\test\PowerShellEditorServices.Test.E2E\ + Set-Location ./test/PowerShellEditorServices.Test.E2E/ $env:PWSH_EXE_NAME = "pwsh" if (-not [Security.Principal.WindowsIdentity]::GetCurrent().Owner.IsWellKnown("BuiltInAdministratorsSid")) { - Write-Warning "Skipping Constrained Language Mode tests as they must be ran in an elevated process." + Write-Build DarkRed "Skipping Constrained Language Mode tests as they must be ran in an elevated process" return } try { - Write-Host "Running end-to-end tests in Constrained Language Mode." + Write-Build DarkGreen "Running end-to-end tests in Constrained Language Mode" [System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", "0x80000007", [System.EnvironmentVariableTarget]::Machine) Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetFramework.PS74 } } finally { @@ -262,16 +277,16 @@ Task TestE2EPwshCLM -If (-not $script:IsNix) Build, SetupHelpForTests, { } Task TestE2EPowerShellCLM -If (-not $script:IsNix) Build, SetupHelpForTests, { - Set-Location .\test\PowerShellEditorServices.Test.E2E\ + Set-Location ./test/PowerShellEditorServices.Test.E2E/ $env:PWSH_EXE_NAME = "powershell" if (-not [Security.Principal.WindowsIdentity]::GetCurrent().Owner.IsWellKnown("BuiltInAdministratorsSid")) { - Write-Warning "Skipping Constrained Language Mode tests as they must be ran in an elevated process." + Write-Build DarkRed "Skipping Constrained Language Mode tests as they must be ran in an elevated process" return } try { - Write-Host "Running end-to-end tests in Constrained Language Mode." + Write-Build DarkGreen "Running end-to-end tests in Constrained Language Mode" [System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", "0x80000007", [System.EnvironmentVariableTarget]::Machine) # TODO: See https://github.com/PowerShell/vscode-powershell/issues/3886 # Inheriting the module path for powershell.exe breaks things! @@ -284,110 +299,8 @@ Task TestE2EPowerShellCLM -If (-not $script:IsNix) Build, SetupHelpForTests, { } } -Task LayoutModule -After Build { - $modulesDir = "$PSScriptRoot/module" - $psesOutputPath = "$modulesDir/PowerShellEditorServices" - $psesBinOutputPath = "$PSScriptRoot/module/PowerShellEditorServices/bin" - $psesDepsPath = "$psesBinOutputPath/Common" - $psesCoreHostPath = "$psesBinOutputPath/Core" - $psesDeskHostPath = "$psesBinOutputPath/Desktop" - - foreach ($dir in $psesDepsPath, $psesCoreHostPath, $psesDeskHostPath) { - New-Item -Force -Path $dir -ItemType Directory | Out-Null - } - - # Copy third party notices to module folder - Copy-Item -Force -Path "$PSScriptRoot\NOTICE.txt" -Destination $psesOutputPath - - # Assemble PSES module - - $includedDlls = [System.Collections.Generic.HashSet[string]]::new() - [void]$includedDlls.Add('System.Management.Automation.dll') - - # PSES/bin/Common - foreach ($psesComponent in Get-ChildItem $script:PsesOutput) { - if ($psesComponent.Name -eq 'System.Management.Automation.dll' -or - $psesComponent.Name -eq 'System.Runtime.InteropServices.RuntimeInformation.dll') { - continue - } - - if ($psesComponent.Extension) { - [void]$includedDlls.Add($psesComponent.Name) - Copy-Item -Path $psesComponent.FullName -Destination $psesDepsPath -Force - } - } - - # PSES/bin/Core - foreach ($hostComponent in Get-ChildItem $script:HostCoreOutput) { - if (-not $includedDlls.Contains($hostComponent.Name)) { - Copy-Item -Path $hostComponent.FullName -Destination $psesCoreHostPath -Force - } - } - - # PSES/bin/Desktop - if (-not $script:IsNix) { - foreach ($hostComponent in Get-ChildItem $script:HostDeskOutput) { - if (-not $includedDlls.Contains($hostComponent.Name)) { - Copy-Item -Path $hostComponent.FullName -Destination $psesDeskHostPath -Force - } - } - } -} - -task RestorePsesModules -After Build { - $submodulePath = (Resolve-Path $PsesSubmodulePath).Path + [IO.Path]::DirectorySeparatorChar - Write-Host "Restoring EditorServices modules..." - - # Read in the modules.json file as a hashtable so it can be splatted - $moduleInfos = @{} - - (Get-Content -Raw $ModulesJsonPath | ConvertFrom-Json).PSObject.Properties | ForEach-Object { - $name = $_.Name - $body = @{ - Name = $name - Version = $_.Value.Version - AllowPrerelease = $_.Value.AllowPrerelease - Repository = if ($_.Value.Repository) { $_.Value.Repository } else { $DefaultModuleRepository } - Path = $submodulePath - } - - if (-not $name) { - throw "EditorServices module listed without name in '$ModulesJsonPath'" - } - - $moduleInfos.Add($name, $body) - } - - # Save each module in the modules.json file - foreach ($moduleName in $moduleInfos.Keys) { - if (Test-Path -Path (Join-Path -Path $submodulePath -ChildPath $moduleName)) { - Write-Host "`tModule '${moduleName}' already detected, skipping!" - continue - } - - $moduleInstallDetails = $moduleInfos[$moduleName] - - $splatParameters = @{ - Name = $moduleName - RequiredVersion = $moduleInstallDetails.Version - Repository = if ($moduleInstallDetails.Repository) { $moduleInstallDetails.Repository } else { $DefaultModuleRepository } - Path = $submodulePath - } - - # There's a bug in PowerShell get where this argument isn't correctly translated when it's false. - if ($moduleInstallDetails.AllowPrerelease) { - $splatParameters["AllowPrerelease"] = $moduleInstallDetails.AllowPrerelease - } - - Write-Host "`tInstalling module: ${moduleName} with arguments $(ConvertTo-Json $splatParameters)" +Task Test TestPS72, TestPS74, TestE2EPwsh, TestPS51, TestE2EPowerShell - Save-Module @splatParameters - } -} - -Task BuildCmdletHelp -After LayoutModule { - New-ExternalHelp -Path $PSScriptRoot\module\docs -OutputPath $PSScriptRoot\module\PowerShellEditorServices\Commands\en-US -Force | Out-Null -} +Task TestFull Test, TestE2EDaily, TestE2EPwshCLM, TestE2EPowerShellCLM -# The default task is to run the entire CI build Task . Clean, Build, Test diff --git a/PowerShellEditorServices.sln b/PowerShellEditorServices.sln index c41d92df0..754851233 100644 --- a/PowerShellEditorServices.sln +++ b/PowerShellEditorServices.sln @@ -3,158 +3,55 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F594E7FD-1E72-4E51-A496-B019C2BA3180}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{F46EF430-95AA-4386-9259-292A443AB715}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{422E561A-8118-4BE7-A54F-9309E4F03AAE}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellEditorServices.Test.Shared", "test\PowerShellEditorServices.Test.Shared\PowerShellEditorServices.Test.Shared.csproj", "{9D307AF9-D1F7-4185-AE9B-2DD3F178832C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerShellEditorServices.Test", "test\PowerShellEditorServices.Test\PowerShellEditorServices.Test.csproj", "{8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellEditorServices.Test", "test\PowerShellEditorServices.Test\PowerShellEditorServices.Test.csproj", "{DFD3C9C2-F9E6-4EE3-B614-A8EA7D1E1A98}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerShellEditorServices.Test.Shared", "test\PowerShellEditorServices.Test.Shared\PowerShellEditorServices.Test.Shared.csproj", "{6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellEditorServices.Test.E2E", "test\PowerShellEditorServices.Test.E2E\PowerShellEditorServices.Test.E2E.csproj", "{AA007633-5178-4D73-A262-CCE7247BDE93}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{E2316F5C-A551-4A8D-8103-E42CA6D757E2}" - ProjectSection(SolutionItems) = preProject - scripts\AddCopyrightHeaders.ps1 = scripts\AddCopyrightHeaders.ps1 - EndProjectSection +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F40C4EC9-AE86-4A26-974F-95381888DCDC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerShellEditorServices", "src\PowerShellEditorServices\PowerShellEditorServices.csproj", "{29EEDF03-0990-45F4-846E-2616970D1FA2}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellEditorServices", "src\PowerShellEditorServices\PowerShellEditorServices.csproj", "{B4431254-9A2F-43DE-A998-12B22A1593CE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerShellEditorServices.Test.E2E", "test\PowerShellEditorServices.Test.E2E\PowerShellEditorServices.Test.E2E.csproj", "{2561F253-8F72-436A-BCC3-AA63AB82EDC0}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerShellEditorServices.Hosting", "src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj", "{3CC791E7-6FC9-4DDE-B4A2-547266977E4E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellEditorServices.Hosting", "src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj", "{983D05F2-3C77-4B51-9A28-A8C6595911BA}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - CoreCLR|Any CPU = CoreCLR|Any CPU - CoreCLR|x64 = CoreCLR|x64 - CoreCLR|x86 = CoreCLR|x86 Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.CoreCLR|Any CPU.ActiveCfg = Release|Any CPU - {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.CoreCLR|Any CPU.Build.0 = Release|Any CPU - {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.CoreCLR|x64.ActiveCfg = Release|Any CPU - {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.CoreCLR|x64.Build.0 = Release|Any CPU - {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.CoreCLR|x86.ActiveCfg = Release|Any CPU - {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.CoreCLR|x86.Build.0 = Release|Any CPU - {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.Debug|x64.ActiveCfg = Debug|Any CPU - {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.Debug|x64.Build.0 = Debug|Any CPU - {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.Debug|x86.ActiveCfg = Debug|Any CPU - {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.Debug|x86.Build.0 = Debug|Any CPU - {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.Release|Any CPU.Build.0 = Release|Any CPU - {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.Release|x64.ActiveCfg = Release|Any CPU - {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.Release|x64.Build.0 = Release|Any CPU - {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.Release|x86.ActiveCfg = Release|Any CPU - {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.Release|x86.Build.0 = Release|Any CPU - {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.CoreCLR|Any CPU.ActiveCfg = Release|Any CPU - {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.CoreCLR|Any CPU.Build.0 = Release|Any CPU - {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.CoreCLR|x64.ActiveCfg = Release|Any CPU - {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.CoreCLR|x64.Build.0 = Release|Any CPU - {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.CoreCLR|x86.ActiveCfg = Release|Any CPU - {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.CoreCLR|x86.Build.0 = Release|Any CPU - {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Debug|x64.ActiveCfg = Debug|Any CPU - {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Debug|x64.Build.0 = Debug|Any CPU - {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Debug|x86.ActiveCfg = Debug|Any CPU - {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Debug|x86.Build.0 = Debug|Any CPU - {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Release|Any CPU.Build.0 = Release|Any CPU - {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Release|x64.ActiveCfg = Release|Any CPU - {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Release|x64.Build.0 = Release|Any CPU - {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Release|x86.ActiveCfg = Release|Any CPU - {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}.Release|x86.Build.0 = Release|Any CPU - {3B38E8DA-8BFF-4264-AF16-47929E6398A3}.CoreCLR|Any CPU.ActiveCfg = CoreCLR|Any CPU - {3B38E8DA-8BFF-4264-AF16-47929E6398A3}.CoreCLR|Any CPU.Build.0 = CoreCLR|Any CPU - {3B38E8DA-8BFF-4264-AF16-47929E6398A3}.CoreCLR|x64.ActiveCfg = CoreCLR|Any CPU - {3B38E8DA-8BFF-4264-AF16-47929E6398A3}.CoreCLR|x64.Build.0 = CoreCLR|Any CPU - {3B38E8DA-8BFF-4264-AF16-47929E6398A3}.CoreCLR|x86.ActiveCfg = CoreCLR|Any CPU - {3B38E8DA-8BFF-4264-AF16-47929E6398A3}.CoreCLR|x86.Build.0 = CoreCLR|Any CPU - {3B38E8DA-8BFF-4264-AF16-47929E6398A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3B38E8DA-8BFF-4264-AF16-47929E6398A3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3B38E8DA-8BFF-4264-AF16-47929E6398A3}.Debug|x64.ActiveCfg = Debug|Any CPU - {3B38E8DA-8BFF-4264-AF16-47929E6398A3}.Debug|x64.Build.0 = Debug|Any CPU - {3B38E8DA-8BFF-4264-AF16-47929E6398A3}.Debug|x86.ActiveCfg = Debug|Any CPU - {3B38E8DA-8BFF-4264-AF16-47929E6398A3}.Debug|x86.Build.0 = Debug|Any CPU - {3B38E8DA-8BFF-4264-AF16-47929E6398A3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3B38E8DA-8BFF-4264-AF16-47929E6398A3}.Release|Any CPU.Build.0 = Release|Any CPU - {3B38E8DA-8BFF-4264-AF16-47929E6398A3}.Release|x64.ActiveCfg = Release|Any CPU - {3B38E8DA-8BFF-4264-AF16-47929E6398A3}.Release|x64.Build.0 = Release|Any CPU - {3B38E8DA-8BFF-4264-AF16-47929E6398A3}.Release|x86.ActiveCfg = Release|Any CPU - {3B38E8DA-8BFF-4264-AF16-47929E6398A3}.Release|x86.Build.0 = Release|Any CPU - {29EEDF03-0990-45F4-846E-2616970D1FA2}.CoreCLR|Any CPU.ActiveCfg = Release|Any CPU - {29EEDF03-0990-45F4-846E-2616970D1FA2}.CoreCLR|Any CPU.Build.0 = Release|Any CPU - {29EEDF03-0990-45F4-846E-2616970D1FA2}.CoreCLR|x64.ActiveCfg = Release|Any CPU - {29EEDF03-0990-45F4-846E-2616970D1FA2}.CoreCLR|x64.Build.0 = Release|Any CPU - {29EEDF03-0990-45F4-846E-2616970D1FA2}.CoreCLR|x86.ActiveCfg = Release|Any CPU - {29EEDF03-0990-45F4-846E-2616970D1FA2}.CoreCLR|x86.Build.0 = Release|Any CPU - {29EEDF03-0990-45F4-846E-2616970D1FA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {29EEDF03-0990-45F4-846E-2616970D1FA2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {29EEDF03-0990-45F4-846E-2616970D1FA2}.Debug|x64.ActiveCfg = Debug|Any CPU - {29EEDF03-0990-45F4-846E-2616970D1FA2}.Debug|x64.Build.0 = Debug|Any CPU - {29EEDF03-0990-45F4-846E-2616970D1FA2}.Debug|x86.ActiveCfg = Debug|Any CPU - {29EEDF03-0990-45F4-846E-2616970D1FA2}.Debug|x86.Build.0 = Debug|Any CPU - {29EEDF03-0990-45F4-846E-2616970D1FA2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {29EEDF03-0990-45F4-846E-2616970D1FA2}.Release|Any CPU.Build.0 = Release|Any CPU - {29EEDF03-0990-45F4-846E-2616970D1FA2}.Release|x64.ActiveCfg = Release|Any CPU - {29EEDF03-0990-45F4-846E-2616970D1FA2}.Release|x64.Build.0 = Release|Any CPU - {29EEDF03-0990-45F4-846E-2616970D1FA2}.Release|x86.ActiveCfg = Release|Any CPU - {29EEDF03-0990-45F4-846E-2616970D1FA2}.Release|x86.Build.0 = Release|Any CPU - {2561F253-8F72-436A-BCC3-AA63AB82EDC0}.CoreCLR|Any CPU.ActiveCfg = Release|Any CPU - {2561F253-8F72-436A-BCC3-AA63AB82EDC0}.CoreCLR|Any CPU.Build.0 = Release|Any CPU - {2561F253-8F72-436A-BCC3-AA63AB82EDC0}.CoreCLR|x64.ActiveCfg = Release|Any CPU - {2561F253-8F72-436A-BCC3-AA63AB82EDC0}.CoreCLR|x64.Build.0 = Release|Any CPU - {2561F253-8F72-436A-BCC3-AA63AB82EDC0}.CoreCLR|x86.ActiveCfg = Release|Any CPU - {2561F253-8F72-436A-BCC3-AA63AB82EDC0}.CoreCLR|x86.Build.0 = Release|Any CPU - {2561F253-8F72-436A-BCC3-AA63AB82EDC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2561F253-8F72-436A-BCC3-AA63AB82EDC0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2561F253-8F72-436A-BCC3-AA63AB82EDC0}.Debug|x64.ActiveCfg = Debug|Any CPU - {2561F253-8F72-436A-BCC3-AA63AB82EDC0}.Debug|x64.Build.0 = Debug|Any CPU - {2561F253-8F72-436A-BCC3-AA63AB82EDC0}.Debug|x86.ActiveCfg = Debug|Any CPU - {2561F253-8F72-436A-BCC3-AA63AB82EDC0}.Debug|x86.Build.0 = Debug|Any CPU - {2561F253-8F72-436A-BCC3-AA63AB82EDC0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2561F253-8F72-436A-BCC3-AA63AB82EDC0}.Release|Any CPU.Build.0 = Release|Any CPU - {2561F253-8F72-436A-BCC3-AA63AB82EDC0}.Release|x64.ActiveCfg = Release|Any CPU - {2561F253-8F72-436A-BCC3-AA63AB82EDC0}.Release|x64.Build.0 = Release|Any CPU - {2561F253-8F72-436A-BCC3-AA63AB82EDC0}.Release|x86.ActiveCfg = Release|Any CPU - {2561F253-8F72-436A-BCC3-AA63AB82EDC0}.Release|x86.Build.0 = Release|Any CPU - {3CC791E7-6FC9-4DDE-B4A2-547266977E4E}.CoreCLR|Any CPU.ActiveCfg = Release|Any CPU - {3CC791E7-6FC9-4DDE-B4A2-547266977E4E}.CoreCLR|Any CPU.Build.0 = Release|Any CPU - {3CC791E7-6FC9-4DDE-B4A2-547266977E4E}.CoreCLR|x64.ActiveCfg = Release|Any CPU - {3CC791E7-6FC9-4DDE-B4A2-547266977E4E}.CoreCLR|x64.Build.0 = Release|Any CPU - {3CC791E7-6FC9-4DDE-B4A2-547266977E4E}.CoreCLR|x86.ActiveCfg = Release|Any CPU - {3CC791E7-6FC9-4DDE-B4A2-547266977E4E}.CoreCLR|x86.Build.0 = Release|Any CPU - {3CC791E7-6FC9-4DDE-B4A2-547266977E4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3CC791E7-6FC9-4DDE-B4A2-547266977E4E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3CC791E7-6FC9-4DDE-B4A2-547266977E4E}.Debug|x64.ActiveCfg = Debug|Any CPU - {3CC791E7-6FC9-4DDE-B4A2-547266977E4E}.Debug|x64.Build.0 = Debug|Any CPU - {3CC791E7-6FC9-4DDE-B4A2-547266977E4E}.Debug|x86.ActiveCfg = Debug|Any CPU - {3CC791E7-6FC9-4DDE-B4A2-547266977E4E}.Debug|x86.Build.0 = Debug|Any CPU - {3CC791E7-6FC9-4DDE-B4A2-547266977E4E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3CC791E7-6FC9-4DDE-B4A2-547266977E4E}.Release|Any CPU.Build.0 = Release|Any CPU - {3CC791E7-6FC9-4DDE-B4A2-547266977E4E}.Release|x64.ActiveCfg = Release|Any CPU - {3CC791E7-6FC9-4DDE-B4A2-547266977E4E}.Release|x64.Build.0 = Release|Any CPU - {3CC791E7-6FC9-4DDE-B4A2-547266977E4E}.Release|x86.ActiveCfg = Release|Any CPU - {3CC791E7-6FC9-4DDE-B4A2-547266977E4E}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {8ED116F4-9DDF-4C49-AB96-AE462E3D64C3} = {422E561A-8118-4BE7-A54F-9309E4F03AAE} - {6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA} = {422E561A-8118-4BE7-A54F-9309E4F03AAE} - {29EEDF03-0990-45F4-846E-2616970D1FA2} = {F594E7FD-1E72-4E51-A496-B019C2BA3180} - {2561F253-8F72-436A-BCC3-AA63AB82EDC0} = {422E561A-8118-4BE7-A54F-9309E4F03AAE} - {3CC791E7-6FC9-4DDE-B4A2-547266977E4E} = {F594E7FD-1E72-4E51-A496-B019C2BA3180} + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9D307AF9-D1F7-4185-AE9B-2DD3F178832C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9D307AF9-D1F7-4185-AE9B-2DD3F178832C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9D307AF9-D1F7-4185-AE9B-2DD3F178832C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9D307AF9-D1F7-4185-AE9B-2DD3F178832C}.Release|Any CPU.Build.0 = Release|Any CPU + {DFD3C9C2-F9E6-4EE3-B614-A8EA7D1E1A98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DFD3C9C2-F9E6-4EE3-B614-A8EA7D1E1A98}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DFD3C9C2-F9E6-4EE3-B614-A8EA7D1E1A98}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DFD3C9C2-F9E6-4EE3-B614-A8EA7D1E1A98}.Release|Any CPU.Build.0 = Release|Any CPU + {AA007633-5178-4D73-A262-CCE7247BDE93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AA007633-5178-4D73-A262-CCE7247BDE93}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AA007633-5178-4D73-A262-CCE7247BDE93}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AA007633-5178-4D73-A262-CCE7247BDE93}.Release|Any CPU.Build.0 = Release|Any CPU + {B4431254-9A2F-43DE-A998-12B22A1593CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B4431254-9A2F-43DE-A998-12B22A1593CE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B4431254-9A2F-43DE-A998-12B22A1593CE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B4431254-9A2F-43DE-A998-12B22A1593CE}.Release|Any CPU.Build.0 = Release|Any CPU + {983D05F2-3C77-4B51-9A28-A8C6595911BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {983D05F2-3C77-4B51-9A28-A8C6595911BA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {983D05F2-3C77-4B51-9A28-A8C6595911BA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {983D05F2-3C77-4B51-9A28-A8C6595911BA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {3B9E8987-D4AC-426B-86F6-889126243A9A} + GlobalSection(NestedProjects) = preSolution + {9D307AF9-D1F7-4185-AE9B-2DD3F178832C} = {F46EF430-95AA-4386-9259-292A443AB715} + {DFD3C9C2-F9E6-4EE3-B614-A8EA7D1E1A98} = {F46EF430-95AA-4386-9259-292A443AB715} + {AA007633-5178-4D73-A262-CCE7247BDE93} = {F46EF430-95AA-4386-9259-292A443AB715} + {B4431254-9A2F-43DE-A998-12B22A1593CE} = {F40C4EC9-AE86-4A26-974F-95381888DCDC} + {983D05F2-3C77-4B51-9A28-A8C6595911BA} = {F40C4EC9-AE86-4A26-974F-95381888DCDC} EndGlobalSection EndGlobal diff --git a/README.md b/README.md index 614f81096..6dec799a5 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ The functionality in PowerShell Editor Services is available in the following ed - [lsp-pwsh](https://github.com/emacs-lsp/lsp-mode/blob/master/clients/lsp-pwsh.el), an Emacs PowerShell plugin - [intellij-powershell](https://github.com/ant-druha/intellij-powershell), adds PowerShell language support to IntelliJ-based IDEs - [coc-powershell](https://github.com/yatli/coc-powershell), a Vim and Neovim plugin +- [powershell.nvim](https://github.com/TheLeoP/powershell.nvim) a Neovim plugin Please note that other than PowerShell for Visual Studio Code, these clients are community maintained and may be very out of date. It is recommended that you simply use an LSP plugin for your editor and configure it as demonstrated [below](#Usage). @@ -55,7 +56,7 @@ The start script, `Start-EditorServices.ps1`, is found in the `PowerShellEditorS The session details (which named pipes were created) will be written to the given session details path, and the client needs to point to these in order to connect. -The Visual Studio Code, Vim, and IntelliJ extensions use named pipes. +The Visual Studio Code, Vim, Neovim, and IntelliJ extensions use named pipes. ### Standard Input and Output @@ -66,7 +67,7 @@ This is because because these two features require their own IO streams and stdi Please see the [emacs-simple-test.el](test/emacs-simple-test.el), [emacs-test.el](test/emacs-test.el), -[vim-simple-test.el](test/vim-simple-test.vim) and [vim-test.vim](test/vim-test.vim) for examples of end-to-end tested configurations. +[vim-simple-test.vim](test/vim-simple-test.vim) and [vim-test.vim](test/vim-test.vim) for examples of end-to-end tested configurations. They use [eglot for Emacs](https://github.com/joaotavora/eglot) and [LanguageClient-neovim](https://github.com/autozimu/LanguageClient-neovim). ### Advanced Usage @@ -130,6 +131,8 @@ The debugging functionality in PowerShell Editor Services is available in the fo - [PowerShell for Visual Studio Code](https://github.com/PowerShell/vscode-powershell) - [nvim-dap-powershell for Neovim](https://github.com/Willem-J-an/nvim-dap-powershell) +- [powershell.nvim for Neovim](https://github.com/TheLeoP/powershell.nvim) +- [intellij-powershell](https://github.com/ant-druha/intellij-powershell) ## API Usage @@ -188,33 +191,34 @@ PS C:\path\to\PowerShellEditorServices> Invoke-Build Build Open the PowerShellEditorServices folder that you cloned locally and press Ctrl+Shift+B (or Cmd+Shift+B on macOS). +## Code of Conduct + +Please see our [Code of Conduct](CODE_OF_CONDUCT.md) before participating in this project. + ## Contributions Welcome -We would love to incorporate community contributions into this project. If you would like to -contribute code, documentation, tests, or bug reports, please read our [Contribution Guide](https://github.com/PowerShell/PowerShellEditorServices/blob/main/CONTRIBUTING.md) to learn more. +We would love to incorporate community contributions into this project. If you would like to +contribute code, documentation, tests, or bug reports, please read our [Contribution Guide](CONTRIBUTING.md) to learn more. + +## Security Note + +For any security issues, please see [here](SECURITY.md). ## Maintainers -- [Justin Grote](https://github.com/JustinGrote) - [@JustinWGrote](https://twitter.com/justinwgrote) -- [Patrick Meinecke](https://github.com/SeeminglyScience) - [@SeeminglyScienc](http://twitter.com/SeeminglyScienc) -- [Andy Jordan](https://github.com/andschwa) - [andyleejordan.com](https://andyleejordan.com/) +- Andy Jordan - [@andyleejordan](https://github.com/andyleejordan) +- Patrick Meinecke - [@SeeminglyScience](https://github.com/SeeminglyScience) +- Sydney Smith - [@SydneyhSmith](https://github.com/SydneyhSmith) +- Justin Grote - [@JustinGrote](https://github.com/JustinGrote) ### Emeriti -- [Rob Holt](https://github.com/rjmholt) - [@rjmholt](https://twitter.com/rjmholt) -- [Tyler Leonhardt](https://github.com/TylerLeonhardt) - [tylerleonhardt.com](https://tylerleonhardt.com) -- [David Wilson](https://github.com/daviwil) - [@daviwil](https://twitter.com/daviwil) +- Rob Holt - [@rjmholt](https://github.com/rjmholt) +- Tyler Leonhardt - [@TylerLeonhardt](https://github.com/TylerLeonhardt) +- David Wilson - [@daviwil](https://github.com/daviwil) ## License -This project is [licensed under the MIT License](LICENSE). - -## [Code of Conduct][conduct-md] - -This project has adopted the [Microsoft Open Source Code of Conduct][conduct-code]. -For more information, see the [Code of Conduct FAQ][conduct-FAQ] or contact [opencode@microsoft.com][conduct-email] with any additional questions or comments. - -[conduct-code]: http://opensource.microsoft.com/codeofconduct/ -[conduct-FAQ]: http://opensource.microsoft.com/codeofconduct/faq/ -[conduct-email]: mailto:opencode@microsoft.com -[conduct-md]: https://github.com/PowerShell/PowerShellEditorServices/blob/main/CODE_OF_CONDUCT.md +This project is [licensed under the MIT License](LICENSE). Please see the +[third-party notices](NOTICE.txt) file for details on the third-party +binaries that we include with releases of this project. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..f941d308b --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,41 @@ + + +## Security + +Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin) and [PowerShell](https://github.com/PowerShell). + +If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), please report it to us as described below. + +## Reporting Security Issues + +**Please do not report security vulnerabilities through public GitHub issues.** + +Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report). + +If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp). + +You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). + +Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: + + * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) + * Full paths of source file(s) related to the manifestation of the issue + * The location of the affected source code (tag/branch/commit or direct URL) + * Any special configuration required to reproduce the issue + * Step-by-step instructions to reproduce the issue + * Proof-of-concept or exploit code (if possible) + * Impact of the issue, including how an attacker might exploit the issue + +This information will help us triage your report more quickly. + +If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for more details about our active programs. + +## Preferred Languages + +We prefer all communications to be in English. + +## Policy + +Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd). + + diff --git a/global.json b/global.json index 4c4c3ae5e..892db14b0 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.100", + "version": "8.0.110", "rollForward": "latestFeature", "allowPrerelease": false } diff --git a/module/PowerShellEditorServices/PowerShellEditorServices.psd1 b/module/PowerShellEditorServices/PowerShellEditorServices.psd1 index 7aab2416a..02e3385b6 100644 --- a/module/PowerShellEditorServices/PowerShellEditorServices.psd1 +++ b/module/PowerShellEditorServices/PowerShellEditorServices.psd1 @@ -19,7 +19,7 @@ RootModule = if ($PSEdition -eq 'Core') } # Version number of this module. -ModuleVersion = '3.20.1' +ModuleVersion = '3.21.0' # ID used to uniquely identify this module GUID = '9ca15887-53a2-479a-9cda-48d26bcb6c47' diff --git a/modules.json b/modules.json deleted file mode 100644 index f72a38714..000000000 --- a/modules.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "PSScriptAnalyzer": { - "Version": "1.22.0", - "AllowPrerelease": false - }, - "PSReadLine": { - "Version": "2.4.0-beta0", - "AllowPrerelease": true - } -} diff --git a/src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj b/src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj index 5c31f0758..8233ead02 100644 --- a/src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj +++ b/src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj @@ -11,10 +11,9 @@ - - - - + + + @@ -22,7 +21,7 @@ - + diff --git a/src/PowerShellEditorServices/PowerShellEditorServices.csproj b/src/PowerShellEditorServices/PowerShellEditorServices.csproj index 8581053ff..9a1771500 100644 --- a/src/PowerShellEditorServices/PowerShellEditorServices.csproj +++ b/src/PowerShellEditorServices/PowerShellEditorServices.csproj @@ -32,17 +32,17 @@ - - - - - - - - - - - + + + + + + + + + + + @@ -54,16 +54,9 @@ - - + + - - - - - - - diff --git a/src/PowerShellEditorServices/Services/DebugAdapter/DebugStateService.cs b/src/PowerShellEditorServices/Services/DebugAdapter/DebugStateService.cs index f1bf3199e..9736b3e85 100644 --- a/src/PowerShellEditorServices/Services/DebugAdapter/DebugStateService.cs +++ b/src/PowerShellEditorServices/Services/DebugAdapter/DebugStateService.cs @@ -34,6 +34,8 @@ internal class DebugStateService internal bool IsUsingTempIntegratedConsole { get; set; } + internal string ExecuteMode { get; set; } + // This gets set at the end of the Launch/Attach handler which set debug state. internal TaskCompletionSource ServerStarted { get; set; } diff --git a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs index df8165319..038f61955 100644 --- a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs +++ b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs @@ -110,9 +110,11 @@ internal async Task LaunchScriptAsync(string scriptToLaunch) PSCommand command; if (System.IO.File.Exists(scriptToLaunch)) { - // For a saved file we just execute its path (after escaping it). + // For a saved file we just execute its path (after escaping it), with the configured operator + // (which can't be called that because it's a reserved keyword in C#). + string executeMode = _debugStateService?.ExecuteMode == "Call" ? "&" : "."; command = PSCommandHelpers.BuildDotSourceCommandWithArguments( - PSCommandHelpers.EscapeScriptFilePath(scriptToLaunch), _debugStateService?.Arguments); + PSCommandHelpers.EscapeScriptFilePath(scriptToLaunch), _debugStateService?.Arguments, executeMode); } else // It's a URI to an untitled script, or a raw script. { diff --git a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs index 1ec1557ed..97bd6cca7 100644 --- a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs +++ b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs @@ -65,6 +65,11 @@ internal record PsesLaunchRequestArguments : LaunchRequestArguments /// public string[] RuntimeArgs { get; set; } + /// + /// Gets or sets the script execution mode, either "DotSource" or "Call". + /// + public string ExecuteMode { get; set; } + /// /// Gets or sets optional environment variables to pass to the debuggee. The string valued /// properties of the 'environmentVariables' are used as key/value pairs. @@ -186,6 +191,7 @@ public async Task Handle(PsesLaunchRequestArguments request, Can _debugStateService.ScriptToLaunch = request.Script; _debugStateService.Arguments = request.Args; _debugStateService.IsUsingTempIntegratedConsole = request.CreateTemporaryIntegratedConsole; + _debugStateService.ExecuteMode = request.ExecuteMode; if (request.CreateTemporaryIntegratedConsole && !string.IsNullOrEmpty(request.Script) diff --git a/src/PowerShellEditorServices/Utility/PSCommandExtensions.cs b/src/PowerShellEditorServices/Utility/PSCommandExtensions.cs index b16129af9..4fe298424 100644 --- a/src/PowerShellEditorServices/Utility/PSCommandExtensions.cs +++ b/src/PowerShellEditorServices/Utility/PSCommandExtensions.cs @@ -94,10 +94,12 @@ private static StringBuilder AddCommandText(this StringBuilder sb, Command comma public static string EscapeScriptFilePath(string f) => string.Concat("'", f.Replace("'", "''"), "'"); - public static PSCommand BuildDotSourceCommandWithArguments(string command, IEnumerable arguments) + // Operator defaults to dot-source but could also be call (ampersand). + // It can't be called that because it's a reserved keyword in C#. + public static PSCommand BuildDotSourceCommandWithArguments(string command, IEnumerable arguments, string executeMode = ".") { string args = string.Join(" ", arguments ?? Array.Empty()); - string script = string.Concat(". ", command, string.IsNullOrEmpty(args) ? "" : " ", args); + string script = string.Concat(executeMode, " ", command, string.IsNullOrEmpty(args) ? "" : " ", args); // HACK: We use AddScript instead of AddArgument/AddParameter to reuse Powershell parameter binding logic. return new PSCommand().AddScript(script); } diff --git a/test/PowerShellEditorServices.Test.E2E/DebugAdapterClientExtensions.cs b/test/PowerShellEditorServices.Test.E2E/DebugAdapterClientExtensions.cs index bdf785ede..dfcb0bbc7 100644 --- a/test/PowerShellEditorServices.Test.E2E/DebugAdapterClientExtensions.cs +++ b/test/PowerShellEditorServices.Test.E2E/DebugAdapterClientExtensions.cs @@ -11,21 +11,17 @@ namespace PowerShellEditorServices.Test.E2E { public static class DebugAdapterClientExtensions { - public static async Task LaunchScript(this DebugAdapterClient debugAdapterClient, string script, TaskCompletionSource started) + public static async Task LaunchScript(this DebugAdapterClient debugAdapterClient, string script, TaskCompletionSource started, string executeMode = "DotSource") { - LaunchResponse launchResponse = await debugAdapterClient.Launch( + _ = await debugAdapterClient.Launch( new PsesLaunchRequestArguments { NoDebug = false, Script = script, Cwd = "", - CreateTemporaryIntegratedConsole = false - }); - - if (launchResponse is null) - { - throw new Exception("Launch response was null."); - } + CreateTemporaryIntegratedConsole = false, + ExecuteMode = executeMode, + }) ?? throw new Exception("Launch response was null."); // This will check to see if we received the Initialized event from the server. await started.Task; diff --git a/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs b/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs index bc1ac3435..654001da7 100644 --- a/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs +++ b/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs @@ -4,7 +4,6 @@ using System; using System.IO; using System.Linq; -using System.Reflection; using System.Runtime.InteropServices; using System.Text; using System.Threading; @@ -21,11 +20,8 @@ namespace PowerShellEditorServices.Test.E2E [Trait("Category", "DAP")] public class DebugAdapterProtocolMessageTests : IAsyncLifetime, IDisposable { - private const string TestOutputFileName = "__dapTestOutputFile.txt"; private static readonly bool s_isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); - private static readonly string s_binDir = - Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - private static readonly string s_testOutputPath = Path.Combine(s_binDir, TestOutputFileName); + private static readonly string s_testOutputPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); private readonly ITestOutputHelper _output; private DebugAdapterClient PsesDebugAdapterClient; @@ -116,7 +112,7 @@ public void Dispose() private static string NewTestFile(string script, bool isPester = false) { string fileExt = isPester ? ".Tests.ps1" : ".ps1"; - string filePath = Path.Combine(s_binDir, Path.GetRandomFileName() + fileExt); + string filePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + fileExt); File.WriteAllText(filePath, script); return filePath; @@ -193,6 +189,17 @@ public async Task UsesDotSourceOperatorAndQuotesAsync() (i) => Assert.StartsWith(". '", i)); } + [Fact] + public async Task UsesCallOperatorWithSettingAsync() + { + string filePath = NewTestFile(GenerateScriptFromLoggingStatements("$($MyInvocation.Line)")); + await PsesDebugAdapterClient.LaunchScript(filePath, Started, executeMode: "Call"); + ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments()); + Assert.NotNull(configDoneResponse); + Assert.Collection(await GetLog(), + (i) => Assert.StartsWith("& '", i)); + } + [Fact] public async Task CanLaunchScriptWithNoBreakpointsAsync() { diff --git a/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj b/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj index ec30df02e..3756f071d 100644 --- a/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj +++ b/test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj @@ -7,11 +7,11 @@ - - - - - + + + + + @@ -23,8 +23,8 @@ - - + + diff --git a/test/PowerShellEditorServices.Test.Shared/Completion/CompleteCommandInFile.cs b/test/PowerShellEditorServices.Test.Shared/Completion/CompleteCommandInFile.cs index 80a1cc906..f84a44a11 100644 --- a/test/PowerShellEditorServices.Test.Shared/Completion/CompleteCommandInFile.cs +++ b/test/PowerShellEditorServices.Test.Shared/Completion/CompleteCommandInFile.cs @@ -12,7 +12,7 @@ internal static class CompleteCommandInFile file: TestUtilities.NormalizePath("Completion/CompletionExamples.psm1"), text: string.Empty, startLineNumber: 8, - startColumnNumber: 7, + startColumnNumber: 10, startOffset: 0, endLineNumber: 0, endColumnNumber: 0, @@ -22,17 +22,17 @@ internal static class CompleteCommandInFile { Kind = CompletionItemKind.Function, Detail = "", - FilterText = "Get-Something", - InsertText = "Get-Something", - Label = "Get-Something", - SortText = "0001Get-Something", + FilterText = "Get-XYZSomething", + InsertText = "Get-XYZSomething", + Label = "Get-XYZSomething", + SortText = "0001Get-XYZSomething", TextEdit = new TextEdit { - NewText = "Get-Something", + NewText = "Get-XYZSomething", Range = new Range { Start = new Position { Line = 7, Character = 0 }, - End = new Position { Line = 7, Character = 6 } + End = new Position { Line = 7, Character = 9 } } } }; diff --git a/test/PowerShellEditorServices.Test.Shared/Completion/CompletionExamples.psm1 b/test/PowerShellEditorServices.Test.Shared/Completion/CompletionExamples.psm1 index a4ce41222..b8427615e 100644 --- a/test/PowerShellEditorServices.Test.Shared/Completion/CompletionExamples.psm1 +++ b/test/PowerShellEditorServices.Test.Shared/Completion/CompletionExamples.psm1 @@ -1,11 +1,11 @@ -function Get-Something +function Get-XYZSomething { $testVar2 = "Shouldn't find this variable" } $testVar1 = "Should find this variable" -Get-So +Get-XYZSo $testVar diff --git a/test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs b/test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs index 630c8a018..359a424f8 100644 --- a/test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs +++ b/test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs @@ -832,7 +832,7 @@ public void FindsSymbolsInFile() Assert.True(symbol.IsDeclaration); // There should be no region symbols unless the provider has been registered. - Assert.Empty(symbols.Where(i => i.Type == SymbolType.Region)); + Assert.DoesNotContain(symbols, i => i.Type == SymbolType.Region); } [Fact] diff --git a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj index 548f36c3e..01c23bcee 100644 --- a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj +++ b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj @@ -2,7 +2,7 @@ - net8.0;net7.0;net6.0;net462 + net8.0;net6.0;net462 Microsoft.PowerShell.EditorServices.Test x64 @@ -18,29 +18,24 @@ - - - - - - + - + - + - - - - + + + + diff --git a/tools/installPSResources.ps1 b/tools/installPSResources.ps1 index a7b4b041f..e98910d70 100644 --- a/tools/installPSResources.ps1 +++ b/tools/installPSResources.ps1 @@ -1,13 +1,13 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. +param( + [ValidateSet("PSGallery", "CFS")] + [string]$PSRepository = "PSGallery" +) -$ErrorActionPreference = 'Stop' - -Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null -if ($PSVersionTable.PSVersion.Major -lt 6) { - throw "The build script requires PowerShell 7!" +if ($PSRepository -eq "CFS" -and -not (Get-PSResourceRepository -Name CFS -ErrorAction SilentlyContinue)) { + Register-PSResourceRepository -Name CFS -Uri "https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/nuget/v3/index.json" } -# TODO: Switch to Install-PSResource when CI uses PowerShell 7.4 -Install-Module -Name InvokeBuild -Scope CurrentUser -Install-Module -Name platyPS -Scope CurrentUser +Install-PSResource -Repository $PSRepository -TrustRepository -Name InvokeBuild +Install-PSResource -Repository $PSRepository -TrustRepository -Name platyPS