Compare commits

...

158 commits

Author SHA1 Message Date
Travis Plunk a090b9eb5f
use different containers for different branches (#16434) 2021-11-10 13:34:29 -08:00
Travis Plunk 292c63430b
Add import so we can use common GitHub workflow function. (#16433)
* Update daily.yml

* Update daily.yml

* try changing error action (#16435)

* Add exit 0 (#16436)
2021-11-10 13:09:28 -08:00
Aditya Patwardhan 9cb33d48a8
Remove pre-release .NET 6 build sources (#16418)
* Remove pre-release .NET 6 build sources

* Update nuget.config
2021-11-10 13:00:18 -08:00
Travis Plunk 23f701ca3c
Update release instructions with link to new build (#16419) 2021-11-10 12:29:07 -08:00
MartinGC94 965dc8f40f
Fix tab completion within the script block specified for the ValidateScriptAttribute. (#14550) 2021-11-09 18:26:14 -08:00
James Truher [MSFT] 19b5647c0a
Update README.md to specify gathered telemetry (#16379) 2021-11-09 17:30:56 -08:00
dependabot[bot] f2a42fb964
Bump Microsoft.ApplicationInsights from 2.18.0 to 2.19.0 (#16413)
* Bump Microsoft.ApplicationInsights from 2.18.0 to 2.19.0

Bumps [Microsoft.ApplicationInsights](https://github.com/Microsoft/ApplicationInsights-dotnet) from 2.18.0 to 2.19.0.
- [Release notes](https://github.com/Microsoft/ApplicationInsights-dotnet/releases)
- [Changelog](https://github.com/microsoft/ApplicationInsights-dotnet/blob/develop/CHANGELOG.md)
- [Commits](https://github.com/Microsoft/ApplicationInsights-dotnet/compare/2.18.0...2.19.0)

---
updated-dependencies:
- dependency-name: Microsoft.ApplicationInsights
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update cgmanifest.json

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
2021-11-09 15:48:06 -08:00
Steve Lee cc28dafa8a
Fix typo for "privacy" in MSI installer (#16407) 2021-11-09 14:56:46 -08:00
Travis Plunk eac16e8167
Update metadata.json to make 7.2.0 the latest LTS (#16417) 2021-11-09 10:21:16 -08:00
Travis Plunk d176853672
Make static CI a matrix (#16397)
* move markdown lint tests

* move markdown link tests

* refactor static link analysis into a matrix

* cache yarn packages

* fix paramater name
2021-11-09 09:23:26 -08:00
Aditya Patwardhan f8d6b2f9fe
Update metadata.json in preparation on 7.3.0-preview.1 release (#16406)
* Update `metadata.json` in preparation on `7.3.0-preview.1` release

* Update PSVersion table and tests
2021-11-09 08:31:01 -08:00
Travis Plunk a10da5a041
Update change log for 7.2.0 (#16401)
* Merged PR 17994: Update change log for 7.2.0

Update change log for 7.2.0

# Conflicts:
#	.spelling

* add blank change log for 7.3

Co-authored-by: Aditya Patwardhan <adityap@microsoft.com>
2021-11-08 15:03:23 -08:00
Travis Plunk dca88a8f50
Update cgmanifest (#16405) 2021-11-08 15:02:11 -08:00
Travis Plunk b48614bf92
Add diagnostics used to take corrective action when releasing buildInfoJson (#16404)
Co-authored-by: Aditya Patwardhan <adityap@microsoft.com>
2021-11-08 14:54:48 -08:00
Travis Plunk 6d0d34f8e8
vPack release should use buildInfoJson new to 7.2 (#16402) 2021-11-08 14:50:24 -08:00
Aditya Patwardhan bc4f6b5a04
Update the usage of metadata.json for getting LTS information (#16381) 2021-11-08 14:21:31 -08:00
Aditya Patwardhan d9eb54b4fd
Add checkout to build json stage to get ci.psm1 (#16399) 2021-11-08 12:28:09 -08:00
Aditya Patwardhan 01069f03fc
Update CgManifest.json for 6.0.0 .NET packages (#16398) 2021-11-08 11:45:47 -08:00
Aditya Patwardhan 1902575129
Update metadata.json and README.md for 7.2.0 release (#16395) 2021-11-08 10:39:29 -08:00
Ilya ef69fdafc4
Remove unneeded call to File.ResolveLinkTarget from IsWindowsApplication (#16371) 2021-11-03 22:28:04 -07:00
Travis Plunk 2f7f67d1ea
Add current folder to the beginning of the module import (#16353)
* fix module import

* capture git status for notices wf

* Only create a pr if there is a diff

* Update .github/workflows/daily.yml
2021-11-03 09:52:13 -07:00
Travis Plunk 00d39fa4d5
Increment RC MSI build number by 100 (#16354) 2021-11-02 17:01:34 -07:00
Maksim Ivanyuk 674ef888a2
Add -HttpVersion parameter to web cmdlets (#15853) 2021-11-02 16:53:36 -07:00
Austin Farmer 107fd7ab1f
Add support to web cmdlets for open-ended input tags (#16193) 2021-11-02 09:39:28 -07:00
dependabot[bot] 53f8cba46f
Bump XunitXml.TestLogger from 3.0.66 to 3.0.70 (#16356) 2021-11-02 09:30:41 -07:00
Ryan Polley cf22188e95
Add more tests to Tee-Object -Encoding (#14539) 2021-11-01 23:06:05 -07:00
Travis Plunk 4eb9e8bea5
Move PR Quantifier config to subfolder (#16352) 2021-11-02 08:44:08 +05:00
Travis Plunk 64d11f44c3
Release build info json when it is preview (#16335) 2021-11-01 15:23:07 -07:00
Aditya Patwardhan 3071718053
Add an approval for releasing build-info json (#16351) 2021-11-01 15:16:00 -07:00
Aditya Patwardhan 8fbffe3e4a
Fix global tool and SDK tests in release pipeline (#16342) 2021-11-01 11:03:52 -07:00
Travis Plunk 64392f36d1
Generate manifest with latest public version of the packages (#16337)
* Generate manifest with latest public version of the packages

* update cgmanifest

* update the PR title for the notice update

* Fix code factor issue - use catch block for fall back

* removing noisy logging
2021-11-01 10:25:39 -07:00
github-actions[bot] 154feabadf
Update to the latest notices file (#16339)
Co-authored-by: TravisEz13 <TravisEz13@users.noreply.github.com>
2021-10-30 11:19:59 -07:00
Travis Plunk aa7a31b46e
Use notice task to generate license assuming cgmanifest contains all components (#16340)
* Use notice task to generate license assuming cgmanifest contains all components

* fix capture task

* fix output location

* cgmanifest using latest public

* fix additional attributions path

* split into stages to allow retry without restarting

* manually append additional attributions

* remove dead comment

* Revert "cgmanifest using latest public"

This reverts commit 6bed867300.
2021-10-30 11:00:07 -07:00
Dongbo Wang 723a50832d
Don't throw exception when trying to resolve a possible link path (#16310) 2021-10-30 08:54:23 -07:00
Travis Plunk 727326d78c
Refactor cgmanifest generator to include all components (#16326) 2021-10-29 16:29:40 -07:00
Aditya Patwardhan c44c39c92b
Fix issues in release build (#16332) 2021-10-29 11:18:43 -07:00
Aditya Patwardhan b2dd88ec8b
Update feed and analyzer dependency (#16327) 2021-10-28 20:51:35 -07:00
Dongbo Wang 979f105a99
Fix parser to generate error when array has more than 32 dimensions (#16276)
An array cannot have more than 32 dimensions. See the doc of MarkArrayType(int rank)) https://docs.microsoft.com/en-us/dotnet/api/system.type.makearraytype?view=net-5.0#System_Type_MakeArrayType_System_Int32_ for details.

The fix is to not create the ArrayTypeName instance when the number of dimensions exceeds 32, but instead, generate a parsing error.
2021-10-29 08:16:26 +05:00
dependabot[bot] 4ae539fed4
Bump Microsoft.NET.Test.Sdk from 16.11.0 to 17.0.0 (#16312) 2021-10-28 14:11:20 -07:00
github-actions[bot] 3b26fc8ae9
Update license and cgmanifest (#16325) 2021-10-28 13:48:41 -07:00
Travis Plunk f1602c215a
Fix condition in cgmanifest logic (#16324) 2021-10-28 13:47:53 -07:00
Kev Ritchie 01426b2763
Fix ConvertTo-Json -Depth to allow 100 at maximum (#16197) 2021-10-28 11:56:55 -07:00
Travis Plunk f41b6b415e
Add GitHub Workflow to keep notices up to date (#16284)
Co-authored-by: Robert Holt <rjmholt_msft@outlook.com>
2021-10-28 11:44:06 -07:00
Aditya Patwardhan 52b6d89407
Update to latest .NET 6 GA build 6.0.100-rtm.21527.11 (#16309) 2021-10-28 11:40:52 -07:00
Ilya 51e11aaedf
Remove unnecessary call to ToArray (#16307) 2021-10-28 11:22:09 -07:00
Ilya 48be7b7f45
Avoid validation for built-in file extension and color VT sequences (#16320) 2021-10-28 11:17:15 -07:00
Travis Plunk 5ce5936d78
Create compliance build (#16286)
Co-authored-by: Robert Holt <rjmholt@gmail.com>
2021-10-28 11:07:09 -07:00
Paul Higinbotham bd4e5598ce
Fix for SSH remoting when banner is enabled on SSHD endpoint (#16205) 2021-10-28 10:39:55 -07:00
Travis Plunk ffd06eb8ed
Move mapping file into product repo and add Debian 11 (#16316) 2021-10-27 17:15:28 -07:00
Travis Plunk a3c03392ca
Add a major-minor build info JSON file (#16301) 2021-10-27 17:14:50 -07:00
Dongbo Wang f2d5ae74ad
Clean up crossgen related build scripts also generate native symbols for R2R images (#16297)
* Clean up crossgen related build scripts

* Fix ci.psm1

* Clean up '-CrossGen' use in a few other files
2021-10-27 11:42:37 -07:00
Nikolay Kondratyev d28691f59e
Fix Windows build ZIP packaging (#16299) 2021-10-27 10:29:42 -07:00
Travis Plunk 14ea042cec
Revert "Update to use .NET 6 GA build (#16296)" (#16308)
This reverts commit 6302f4815a.
2021-10-26 15:57:59 -07:00
Nikolay Kondratyev d391168ece
Add wget as a dependency for Bootstrap script (#16303)
* Add wget as a dependency for installation script

* Add wget as a dependency for alpine
2021-10-26 11:50:57 -07:00
Aditya Patwardhan 15ac9485de
Fix issues reported by code signing verification tool (#16291) 2021-10-22 16:45:51 -07:00
Aditya Patwardhan 6302f4815a
Update to use .NET 6 GA build (#16296) 2021-10-22 23:12:00 +00:00
Travis Plunk e5d27d139c
Revert "add GH workflow to keep the cgmanifest up to date." (#16294)
This reverts commit 57f4ccd1fc.
2021-10-22 10:32:08 -07:00
Dongbo Wang 612aade356
Update README.md and metadata.json files for v7.2.0-rc.1 release (#16285) 2021-10-21 17:03:47 -07:00
Dongbo Wang 7ce4e5a766
Update ChangeLog for 7.2.0-rc.1 and also fix RPM packaging (#16290) 2021-10-21 16:15:13 -07:00
dependabot[bot] 247bf620fc
Bump Microsoft.CodeAnalysis.NetAnalyzers (#16271)
Bumps [Microsoft.CodeAnalysis.NetAnalyzers](https://github.com/dotnet/roslyn-analyzers) from 6.0.0-rtm.21516.1 to 6.0.0-rtm.21518.1.
- [Release notes](https://github.com/dotnet/roslyn-analyzers/releases)
- [Changelog](https://github.com/dotnet/roslyn-analyzers/blob/main/PostReleaseActivities.md)
- [Commits](https://github.com/dotnet/roslyn-analyzers/commits)

---
updated-dependencies:
- dependency-name: Microsoft.CodeAnalysis.NetAnalyzers
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-10-21 12:33:26 -07:00
Travis Plunk 57f4ccd1fc
add GH workflow to keep the cgmanifest up to date. 2021-10-20 13:11:22 -07:00
Aditya Patwardhan 3253124f69
Update ThirdPartyNotices.txt (#16283) 2021-10-20 11:52:54 -07:00
Aditya Patwardhan 7ac276ac25
Update testartifacts.yml to use ubuntu-latest image (#16279) 2021-10-20 11:51:58 -07:00
Aditya Patwardhan 66508053f5
Update version of Microsoft.PowerShell.Native and Microsoft.PowerShell.MarkdownRender packages (#16277) 2021-10-19 17:31:57 -07:00
Travis Plunk b08ab5afea
Add script to generate cgmanifest.json (#16278) 2021-10-19 17:27:44 -07:00
Travis Plunk 5d447cb773
Disallow all COM for AppLocker system lock down (#16268)
Co-authored-by: Paul Higinbotham <paulhi@microsoft.com>
2021-10-19 11:18:37 -07:00
Aditya Patwardhan a82630a17a
Add cgmanifest.json for generating correct third party notice file (#16266) 2021-10-19 11:17:46 -07:00
Dongbo Wang 89dd5b8127
Remove the outdated test (#16269) 2021-10-19 13:45:36 +05:00
dependabot[bot] b4c5c29dff
Bump Microsoft.CodeAnalysis.NetAnalyzers from 6.0.0-rtm.21504.2 to 6.0.0-rtm.21516.1 (#16264) 2021-10-18 15:16:49 -07:00
Travis Plunk 0a80da013c
Only upload stable buildinfo for stable releases (#16251) 2021-10-18 13:10:59 -07:00
Travis Plunk b413d63d14
Make RPM license recognized (#16189) 2021-10-18 13:07:41 -07:00
Travis Plunk 240b3261b8
Don't upload dep or tar.gz for RPM because there are none. (#16230) 2021-10-18 13:07:20 -07:00
Aditya Patwardhan 061a644019
Add condition to generate release files in local dev build only (#16259) 2021-10-15 16:42:23 -07:00
Aditya Patwardhan 45b80a555a
Update .NET 6 to version 6.0.100-rc.2.21505.57 (#16249) 2021-10-15 13:51:26 -07:00
Travis Plunk 1be0c92486
change order of try-catch-finally and split out arm runs (#16252) 2021-10-15 11:43:18 -07:00
Aditya Patwardhan 52e82d0d7f
Ensure psoptions.json and manifest.spdx.json files always exist in packages (#16258) 2021-10-15 11:29:19 -07:00
Andrew a5f283537a
Removed old not-used-anymore docker-based tests for PS release packages (#16224) 2021-10-15 10:46:36 -07:00
Travis Plunk 3ecf4b3a1d
Update to vPack task version to 12 (#16250) 2021-10-14 17:24:10 -07:00
Travis Plunk d74c6bfb7b
Configure ApplicationInsights to not send cloud role name (#16246)
Configure ApplicationInsights to not send cloud role name

Co-authored-by: Aditya Patwardhan <adityap@microsoft.com>
2021-10-14 15:12:37 -07:00
Travis Plunk 3893c4d55b
Disallow Add-Type in NoLanguage mode on a locked down machine (#16245) 2021-10-14 14:53:41 -07:00
Dongbo Wang cd6eccb1ac
Update the change logs for v7.0.8 and v7.1.5 releases (#16248) 2021-10-14 14:51:25 -07:00
Keith Hill b94dd91e74
Specify exe path as TargetObect for non-zero exit code ErrorRecord (#16108) 2021-10-14 14:47:54 -07:00
Aditya Patwardhan 9a63f412ef
Update README.md and metadata.json for 7.0.8 and 7.1.5 releases (#16144) 2021-10-14 14:31:49 -07:00
Dongbo Wang c784dde5a2
Remove the unused FollowSymLink function (#16231) 2021-10-14 14:14:05 -07:00
Dongbo Wang 080b754cb9
Remove unneeded NuGetConfigFile resource string (#16232) 2021-10-14 14:13:24 -07:00
Travis Plunk bd5dc97087
Add Software Bill of Materials to the main packages (#16202) 2021-10-12 15:40:43 -07:00
Travis Plunk e4367386b3
Sign third party exes (#16229) 2021-10-12 14:32:10 -07:00
Steve Lee d0e823797f
Don't allow Move-Item with FileSystemProvider to move a directory into itself (#16198) 2021-10-12 14:16:32 -07:00
Travis Plunk 329250c974
Upgrade set-value package for markdown test (#16196) 2021-10-12 14:14:39 -07:00
Dongbo Wang c8984c0517
Make property names for the color VT sequences consistent with documentations (#16212) 2021-10-11 14:58:51 -07:00
Dongbo Wang a32700a1c1
Add clean block to script block as a peer to begin, process, and end to allow easy resource cleanup (#15177) 2021-10-11 14:49:09 -07:00
Dongbo Wang fa4bfb447e
Use Ubuntu 20.04 for SSH remoting test (#16225) 2021-10-11 13:43:42 -07:00
Ikko Ashimine ce951602a4
Fix typo in TypeTable.cs (#16220)
occured -> occurred
2021-10-11 10:15:16 -07:00
Sean Wheeler 41093f6d7a
Fixes #16176 - replace snippet tag with code tag in comments (#16177) 2021-10-08 21:01:28 +05:00
Dongbo Wang e98a8c8601
Fix '-PipelineVariable' to set variable in the right scope (#16199) 2021-10-07 10:26:21 -07:00
dwtaber 53ac646cc0
Invoke-Command: improve handling of variables with $using: expression (#16113) 2021-10-06 10:43:56 -07:00
Dongbo Wang 2f57bf848b
Change Target from a CodeProperty to be an AliasProperty that points to FileSystemInfo.LinkTarget (#16165) 2021-10-05 10:29:16 -07:00
dependabot[bot] 4c84665bc7
Bump Microsoft.CodeAnalysis.NetAnalyzers (#16194)
Bumps [Microsoft.CodeAnalysis.NetAnalyzers](https://github.com/dotnet/roslyn-analyzers) from 6.0.0-rtm.21480.8 to 6.0.0-rtm.21504.2.
- [Release notes](https://github.com/dotnet/roslyn-analyzers/releases)
- [Changelog](https://github.com/dotnet/roslyn-analyzers/blob/main/PostReleaseActivities.md)
- [Commits](https://github.com/dotnet/roslyn-analyzers/commits)

---
updated-dependencies:
- dependency-name: Microsoft.CodeAnalysis.NetAnalyzers
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-10-05 10:28:10 -07:00
dependabot[bot] cfe45defc1
Bump Microsoft.CodeAnalysis.NetAnalyzers from 6.0.0-rc2.21458.5 to 6.0.0-rtm.21480.8 (#16183)
Bumps [Microsoft.CodeAnalysis.NetAnalyzers](https://github.com/dotnet/roslyn-analyzers) from 6.0.0-rc2.21458.5 to 6.0.0-rtm.21480.8.
- [Release notes](https://github.com/dotnet/roslyn-analyzers/releases)
- [Changelog](https://github.com/dotnet/roslyn-analyzers/blob/main/PostReleaseActivities.md)
- [Commits](https://github.com/dotnet/roslyn-analyzers/commits)

---
updated-dependencies:
- dependency-name: Microsoft.CodeAnalysis.NetAnalyzers
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-10-03 13:48:25 -07:00
Travis Plunk 6b42f445ed
Move vPack build to 1ES Pool (#16169) 2021-10-03 13:36:55 -07:00
Travis Plunk 4336ebaf29
Fix Microsoft update spelling issue. (#16178) 2021-10-03 13:35:19 -07:00
Travis Plunk 7cf1ef8c85 merge v7.2.0-preview.10 into master 2021-09-29 12:33:07 -07:00
Aditya Patwardhan f4ee1d7f12
Update README.md and metadata.json for next preview release (#16107) 2021-09-28 17:13:11 -07:00
Travis Plunk 7f36609cf4
fix issue with hash file getting created before we have finished get-childitem (#16170) 2021-09-28 16:58:26 -07:00
Andy Schwartzmeyer 3ed7571f94
Update Windows PowerShell issues link (#16105) 2021-09-23 22:28:57 -07:00
Travis Plunk 9eb63debcd
Add sha256 hashes to release (#16147)
* Add sha256 hashes to release

* Update tools/releaseBuild/azureDevOps/templates/release-CreateGitHubDraft.yml
2021-09-23 17:31:57 -07:00
Travis Plunk 6589eeb610
Change path for Component Governance for build to the path we actually use to build (#16137) 2021-09-23 07:06:06 -07:00
Aditya Patwardhan c4c312cc31
Update Microsoft.CodeAnalysis.CSharp version (#16138) 2021-09-23 07:04:14 -07:00
Steve Lee e81048b6ab
Remove Joey from Committee and WG membership (#16119) 2021-09-17 17:37:18 +00:00
xtqqczze 49e21be29d
Update more docs for net6.0 TFM (#16102) 2021-09-16 08:51:48 +05:00
Sean Wheeler 6d2feeee38
Change 'snippet' tag to 'code' tag in XML comments (#16106) 2021-09-15 15:42:13 -07:00
Dongbo Wang fd3579badb
Use PlainText when writing to a host that doesn't support VT (#16092) 2021-09-15 10:38:26 -07:00
Kellen Stuart 4c958d8631
Update build documentation to reflect .NET 6 (#15751) 2021-09-15 08:32:42 -07:00
dependabot[bot] f1b122588b
Bump Microsoft.CodeAnalysis.NetAnalyzers (#16070)
Bumps [Microsoft.CodeAnalysis.NetAnalyzers](https://github.com/dotnet/roslyn-analyzers) from 6.0.0-rc2.21452.5 to 6.0.0-rc2.21458.5.
- [Release notes](https://github.com/dotnet/roslyn-analyzers/releases)
- [Changelog](https://github.com/dotnet/roslyn-analyzers/blob/main/PostReleaseActivities.md)
- [Commits](https://github.com/dotnet/roslyn-analyzers/commits)

---
updated-dependencies:
- dependency-name: Microsoft.CodeAnalysis.NetAnalyzers
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-15 08:58:57 +05:00
Steve Lee ed249d0fe6
Remove support for AppExeCLinks to retrieve target (#16044) 2021-09-14 14:08:00 -07:00
Dongbo Wang 1704ca6885
Add benchmark to test compiler performance (#16083) 2021-09-14 13:51:18 -07:00
Aditya Patwardhan 55ccbb6803
Update .NET to 6.0.100-rc.1.21458.32 (#16066) 2021-09-13 16:45:10 -07:00
Travis Plunk 8b962ca1db
Update minimum required OS version for macOS (#16088) 2021-09-13 15:56:12 -07:00
Steve Lee dad7a34ee7
Move GetOuputString() and GetFormatStyleString() to PSHostUserInterface as public API (#16075) 2021-09-10 09:05:07 -07:00
Dongbo Wang 74e283c4f9
Set locale correctly on Linux CI (#16073) 2021-09-09 13:59:31 -07:00
Steve Lee 024f409763
Add isOutputRedirected parameter to GetFormatStyleString() method (#14397) 2021-09-09 11:50:36 -07:00
Paul Higinbotham 0d7ba2fe5a
Fix ConvertTo-SecureString with key regression due to .NET breaking change (#16068) 2021-09-09 10:36:05 -07:00
Robert Holt 12dbdd9f05
Ensure locale is set correctly on Ubuntu 20.04 in CI (#16067) 2021-09-08 14:30:44 -07:00
dependabot[bot] 4c5f987e6c
Bump Microsoft.CodeAnalysis.NetAnalyzers (#16045) 2021-09-08 14:19:07 -07:00
Steve Lee 5872e47254
Fix regression in Move-Item to only fallback to CopyAndDelete in specific cases (#16029)
If Move fails, check if known case before attempting CopyAndDelete:

- if an item is attempted to be renamed across filesystem mount boundaries.
- if the source and destination do not have the same root path.
2021-09-08 11:20:30 +05:00
github-actions[bot] 1e823e6677
Update .NET SDK version from 6.0.100-rc.1.21430.44 to 6.0.100-rc.1.21455.2 (#16041) 2021-09-07 14:11:13 -07:00
Robert Holt 17986d88c1
Improve CommandInvocationIntrinsics API documentation and style (#14369) 2021-09-03 16:05:30 -07:00
Dongbo Wang 66b5d50170
Set $? correctly for command expression with redirections (#16046) 2021-09-03 15:36:31 -07:00
Aditya Patwardhan 14ced821c9
Fix the GitHub Action for updating .NET daily builds (#16042) 2021-09-03 15:18:50 -07:00
dependabot[bot] d3d8897619
Bump Microsoft.CodeAnalysis.CSharp from 4.0.0-3.final to 4.0.0-4.21430.4 (#16036) 2021-09-02 09:59:58 -07:00
Ikko Ashimine 3f571d8a8f
Fix typo in build.psm1 (#16038)
targetting -> targeting
2021-09-02 17:42:06 +05:00
Travis Plunk 6cde546203
Add .stylecop to filetypexml and format it (#16025) 2021-09-01 10:36:58 -07:00
Aditya Patwardhan 7fc60d1d5f
Bump .NET to 6.0.100-rc.1.21430.44 (#16028) 2021-09-01 10:35:27 -07:00
Paul Higinbotham 946341b2eb
Remove duplicate remote server mediator code (#16027) 2021-09-01 09:31:19 -07:00
Aditya Patwardhan 15f2730c4c
Move from PkgES hosted agents to 1ES hosted agents (#16023) 2021-08-31 15:16:10 -07:00
dependabot[bot] 6de53f89cf
Bump Microsoft.CodeAnalysis.NetAnalyzers (#16021)
Bumps [Microsoft.CodeAnalysis.NetAnalyzers](https://github.com/dotnet/roslyn-analyzers) from 6.0.0-rc2.21423.3 to 6.0.0-rc2.21430.2.
- [Release notes](https://github.com/dotnet/roslyn-analyzers/releases)
- [Changelog](https://github.com/dotnet/roslyn-analyzers/blob/main/PostReleaseActivities.md)
- [Commits](https://github.com/dotnet/roslyn-analyzers/commits)

---
updated-dependencies:
- dependency-name: Microsoft.CodeAnalysis.NetAnalyzers
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-31 12:44:55 +05:00
Aditya Patwardhan 3bb6b2736a
Update Ubuntu images to use Ubuntu 20.04 (#15906) 2021-08-30 13:56:52 -07:00
xtqqczze fa50e4dcae
Use bool?.GetValueOrDefault() in FormatWideCommand (#15988) 2021-08-30 08:51:07 -07:00
Dongbo Wang e3d8353e3c
Fix the mac build by updating the pool image name (#16010) 2021-08-28 12:51:37 -07:00
Aditya Patwardhan 008f4b057f
Use Alpine 3.12 for building PowerShell for alpine (#16008) 2021-08-27 14:05:39 -07:00
Ilya 102ccffd14
Enable two previously disabled Get-Process tests (#15845) 2021-08-26 21:53:27 -07:00
Joel Sallow (/u/ta11ow) fde119e28b
Use CurrentCulture when handling conversions to DateTime in Add-History (#16005) 2021-08-26 21:41:01 -07:00
Steven Liekens 02b532fb1d
Fix link header parsing to handle unquoted rel types (#15973) 2021-08-26 15:11:15 -07:00
github-actions[bot] d33b223674
Update .NET SDK version from 6.0.100-preview.6.21355.2 to 6.0.100-rc.1.21426.1 (#15648) 2021-08-26 13:07:43 -07:00
Dongbo Wang 403767d7f7
Fix a casting error when using $PSNativeCommandUsesErrorActionPreference (#15993) 2021-08-25 17:05:54 -07:00
Aditya Patwardhan 15836f289c
Ignore error from Find-Package (#15999) 2021-08-25 15:59:58 -07:00
Aditya Patwardhan b09f6973fd
Find packages separately for each source in UpdateDotnetRuntime.ps1 script (#15998) 2021-08-25 14:19:55 -07:00
Daryl Graves 321b726306
Format-Wide: Fix NullReferenceException (#15990) 2021-08-25 09:45:00 -07:00
Robert Holt a4d14576b3
Make the native command error handling optionally honor ErrorActionPreference (#15897) 2021-08-24 15:27:22 -07:00
Aditya Patwardhan 56d22bc386
Enable sending Teams notification when workflow fails (#15982) 2021-08-24 10:20:49 -07:00
Aditya Patwardhan bd84f4265b
Update metadata to start using .NET 6 RC1 builds (#15981) 2021-08-24 09:55:42 -07:00
dependabot[bot] 07e466871a
Bump Microsoft.CodeAnalysis.NetAnalyzers (#15985) 2021-08-24 08:09:55 -07:00
Aditya Patwardhan ab5e1779a3
Revert "Use GetValueOrDefault() for nullable PSLanguageMode (#13849)" (#15980) 2021-08-23 17:20:29 -07:00
Dongbo Wang 8f8bc02c8d
Merge the v7.2.0-preview.9 release branch back to GitHub master (#15983) 2021-08-23 15:32:42 -07:00
Dongbo Wang b283188573
Update readme and metadata.json for 7.2.0-preview.9 release (#15957) 2021-08-23 15:08:41 -07:00
James Truher [MSFT] c39d672560
Remove 4 assertions which cause debug build test runs to fail (#15963) 2021-08-22 10:49:07 -07:00
Dongbo Wang e70ad6ce25
Publish global tool package for stable releases (#15961) 2021-08-20 11:23:30 -07:00
dependabot[bot] 40928f7a97
Bump Microsoft.CodeAnalysis.NetAnalyzers to newer version (#15962) 2021-08-20 09:24:35 -07:00
197 changed files with 14906 additions and 5303 deletions

View file

@ -1,7 +1,7 @@
blank_issues_enabled: false
contact_links:
- name: Windows PowerShell
url: https://windowsserver.uservoice.com/forums/301869-powershell
url: https://support.microsoft.com/windows/send-feedback-to-microsoft-with-the-feedback-hub-app-f59187f8-8739-22d6-ba93-f66612949332
about: Windows PowerShell issues or suggestions.
- name: Support
url: https://github.com/PowerShell/PowerShell/blob/master/.github/SUPPORT.md

11
.github/prquantifier.yaml vendored Normal file
View file

@ -0,0 +1,11 @@
# https://github.com/microsoft/PullRequestQuantifier/blob/main/docs/prquantifier-yaml.md
Excluded:
# defaults
- '*.csproj'
- prquantifier.yaml
- package-lock.json
- '*.md'
- '*.sln'
# autogenerated files
- cgmanifest.json
- assets/wix/files.wxs

View file

@ -0,0 +1,27 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
function Set-GWVariable {
param(
[Parameter(Mandatory = $true)]
[string]$Name,
[Parameter(Mandatory = $true)]
[string]$Value
)
Write-Verbose "Setting CI variable $Name to $Value" -Verbose
if ($env:GITHUB_ENV) {
"$Name=$Value" | Out-File $env:GITHUB_ENV -Append
}
}
function Get-GWTempPath {
$temp = [System.IO.Path]::GetTempPath()
if ($env:RUNNER_TEMP) {
$temp = $env:RUNNER_TEMP
}
Write-Verbose "Get CI Temp path: $temp" -Verbose
return $temp
}

View file

@ -30,18 +30,16 @@ jobs:
git fetch --prune --unshallow --tags
- name: Execute Update .NET script
run: |
Import-Module ./.github/workflows/GHWorkflowHelper
$currentVersion = (Get-Content .\global.json | ConvertFrom-Json).sdk.version
Write-Verbose "OLD_VERSION=$currentVersion" -Verbose
"OLD_VERSION=$currentVersion" | Out-File $env:GITHUB_ENV -Append
Set-GWVariable -Name OLD_VERSION -Value $currentVersion
./tools/UpdateDotnetRuntime.ps1 -UpdateMSIPackaging -UseInternalFeed
$newVersion = (Get-Content .\global.json | ConvertFrom-Json).sdk.version
Write-Verbose "NEW_VERSION=$newVersion" -Verbose
"NEW_VERSION=$newVersion" | Out-File $env:GITHUB_ENV -Append
Set-GWVariable -Name NEW_VERSION -Value $newVersion
if ($currentVersion -ne $newVersion) {
Write-Verbose "CREATE_PR=true" -Verbose
"CREATE_PR=true" | Out-File $env:GITHUB_ENV -Append
Set-GWVariable -Name CREATE_PR -Value 'true'
}
- name: Microsoft Teams Notifier
uses: skitionek/notify-microsoft-teams@master
@ -58,5 +56,43 @@ jobs:
title: "Update .NET SDK version from `${{ env.OLD_VERSION }}` to `${{ env.NEW_VERSION }}`"
base: master
branch: dotnet_update
update-tpn:
name: Update Notices File
timeout-minutes: 15
runs-on: windows-latest
if: github.repository == 'PowerShell/PowerShell'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Update Notices file
run: |
Invoke-WebRequest -Uri https://aka.ms/pwsh-daily-tpn -OutFile ./ThirdPartyNotices.txt
- name: Capture Git Status
run: |
git status --short
- name: Check if we need to create a PR
run: |
$ErrorActionPreference = 'continue'
git diff --quiet ThirdPartyNotices.txt
$exitCode = $LASTEXITCODE
Write-Verbose -Message "Exit code: $exitCode" -Verbose
if ($LASTEXITCODE -ne 0) {
Import-Module ./.github/workflows/GHWorkflowHelper
Set-GWVariable -Name CREATE_PR -Value 'true'
} else {
Write-Verbose "No difference found. Not creating a PR." -Verbose
}
exit 0
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
id: cprtpn
if: env.CREATE_PR == 'true'
with:
commit-message: "Update to the latest notice file"
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
title: "Update to the latest notice file"
reviewers: travisez13
base: master
draft: false
branch: update-cgmanifest

57
.github/workflows/update-cgmanifest.yml vendored Normal file
View file

@ -0,0 +1,57 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
name: Update cgmanifest
on:
workflow_dispatch:
pull_request:
branches:
- master
defaults:
run:
shell: pwsh
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
POWERSHELL_TELEMETRY_OPTOUT: 1
CGMANIFEST_PATH: ''
NUGET_PACKAGES: ${{ github.workspace }}\.nuget\packages
jobs:
update-cgmanifest:
name: Update cgmanifest
timeout-minutes: 15
runs-on: windows-latest
if: github.repository == 'PowerShell/PowerShell'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache DotNet
uses: actions/cache@v2
with:
path: |
~\AppData\Local\Microsoft\dotnet
${{ github.workspace }}\.nuget\packages
key: ${{ runner.os }}-${{ hashFiles('**\DotnetRuntimeMetadata.json') }}-${{ hashFiles('**\nuget.config') }}
- name: Sync tags
run: |
git fetch --prune --unshallow --tags
- name: Install Ships provider to deal with project.assets.json
run: |
Install-Module -Name dotnet.project.assets -force
- name: Bootstrap
run: |
Import-Module ./build.psm1
Start-PSBootStrap
- name: Verify cgmanifest is up to date
run: |
Import-Module ./build.psm1
Find-Dotnet
./tools/findMissingNotices.ps1
- name: Upload cgmanifest
uses: actions/upload-artifact@v2
if: always() && env.CGMANIFEST_PATH != ''
with:
name: cgmanifest
path: ${{ env.CGMANIFEST_PATH }}

View file

@ -15,6 +15,7 @@
about_
about_debuggers
about_jobs
about_Telemetry
acl
adamdriscoll
add-localgroupmember
@ -1269,7 +1270,7 @@ package.json
jcotton42
RPMs
PSDesiredStateConfiguration
- CHANGELOG/preview.md
- CHANGELOG/7.2.md
Gimly
jborean93
mkswd
@ -1383,12 +1384,32 @@ lselden
SethFalco
CodeQL
slowy07
rc.2.21505.57
ThirdPartyNotices.txt
cgmanifest.json
buildinfo
tar.gz
psoptions.json
manifest.spdx.json
vPack
kondratyev-nv
v7.2.0
cgmanifest.json
pwsh.exe
6.0.100-rtm.21527.11
6.0.100-rc.2.21505.57
ThirdPartyNotices.txt
rtm.21527.11
- CHANGELOG/7.0.md
codesign
release-BuildJson
yml
centos-7
PSDesiredStateConfiguration
NoLanguage
createdump
vPack
PkgES
- test/perf/benchmarks/README.md
benchmarked
BenchmarkDotNet

View file

@ -11,9 +11,9 @@ trigger:
include:
- '*'
exclude:
- /.vsts-ci/misc-analysis.yml
- /.github/ISSUE_TEMPLATE/*
- /.dependabot/config.yml
- .vsts-ci/misc-analysis.yml
- .github/ISSUE_TEMPLATE/*
- .dependabot/config.yml
- test/perf/*
pr:
branches:
@ -30,10 +30,14 @@ pr:
- .vsts-ci/misc-analysis.yml
- .vsts-ci/windows.yml
- .vsts-ci/windows/*
- cgmanifest.json
- LICENSE.txt
- test/common/markdown/*
- test/perf/*
- tools/releaseBuild/*
- tools/releaseBuild/azureDevOps/templates/*
- README.md
- .spelling
variables:
DOTNET_CLI_TELEMETRY_OPTOUT: 1

View file

@ -11,10 +11,10 @@ trigger:
include:
- '*'
exclude:
- /tools/releaseBuild/**/*
- /.vsts-ci/misc-analysis.yml
- /.github/ISSUE_TEMPLATE/*
- /.dependabot/config.yml
- tools/releaseBuild/**/*
- .vsts-ci/misc-analysis.yml
- .github/ISSUE_TEMPLATE/*
- .dependabot/config.yml
- test/perf/*
pr:
branches:
@ -29,13 +29,17 @@ pr:
- .dependabot/config.yml
- .github/ISSUE_TEMPLATE/*
- .vsts-ci/misc-analysis.yml
- /.vsts-ci/windows.yml
- /.vsts-ci/windows/*
- .vsts-ci/windows.yml
- .vsts-ci/windows/*
- cgmanifest.json
- LICENSE.txt
- test/common/markdown/*
- test/perf/*
- tools/packaging/*
- tools/releaseBuild/*
- tools/releaseBuild/azureDevOps/templates/*
- README.md
- .spelling
variables:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
@ -97,10 +101,6 @@ stages:
vmImage: macOS-latest
steps:
- pwsh: |
# Remove old .NET SDKs
if (Test-Path -Path $HOME/.dotnet) {
Remove-Item $HOME/.dotnet -Recurse -Force
}
Import-Module .\tools\ci.psm1
New-CodeCoverageAndTestPackage
displayName: CodeCoverage and Test Package

View file

@ -27,83 +27,41 @@ variables:
- name: repoFolder
value: PowerShell
jobs:
- job: CI_Compliance
displayName: CI Compliance
stages:
- stage: Compliance
jobs:
- job: CI_Compliance
displayName: CI Compliance
pool:
vmImage: windows-latest
pool:
vmImage: windows-latest
variables:
- name: repoPath
value: $(Agent.BuildDirectory)\$(repoFolder)
variables:
- name: repoPath
value: $(Agent.BuildDirectory)\$(repoFolder)
steps:
- checkout: self
clean: true
path: $(repoFolder)
steps:
- checkout: self
clean: true
path: $(repoFolder)
- checkout: ComplianceRepo
- checkout: ComplianceRepo
- template: ci-compliance.yml@ComplianceRepo
- job: Linux_CI
displayName: Markdown and Common Tests
pool:
vmImage: ubuntu-20.04
variables:
- name: repoPath
value: $(Agent.BuildDirectory)/$(repoFolder)
steps:
- checkout: self
clean: true
path: $(repoFolder)
- checkout: ComplianceRepo
- powershell: |
Get-ChildItem -Path env:
displayName: Capture Environment
condition: succeededOrFailed()
- powershell: |
Install-module Pester -Scope CurrentUser -Force -MaximumVersion 4.99
displayName: Install Pester
condition: succeededOrFailed()
- bash: |
curl -o- --progress-bar -L https://yarnpkg.com/install.sh | bash
displayName: Bootstrap Yarn
condition: succeededOrFailed()
- bash: |
sudo yarn global add markdown-spellcheck@0.11.0
displayName: Install mdspell
condition: succeededOrFailed()
- bash: |
mdspell '**/*.md' '!**/Pester/**/*.md' '!**/dotnet-tools/**/*.md' --ignore-numbers --ignore-acronyms --report --en-us;
displayName: Test Spelling in Markdown
condition: succeededOrFailed()
workingDirectory: '$(repoPath)'
- ${{ if not(contains(variables['SYSTEM.COLLECTIONURI'],'mscodehub')) }}:
- pwsh: |
Import-module ./build.psm1
$path = Join-Path -Path $pwd -ChildPath './commonTestResults.xml'
$results = invoke-pester -Script ./test/common -OutputFile $path -OutputFormat NUnitXml -PassThru
Write-Host "##vso[results.publish type=NUnit;mergeResults=true;runTitle=Common Tests;publishRunAttachments=true;resultFiles=$path;]"
if($results.TotalCount -eq 0 -or $results.FailedCount -gt 0)
{
throw "Markdown tests failed"
}
displayName: Run Common Tests
condition: succeededOrFailed()
workingDirectory: '$(repoPath)'
- template: dailyBuildCompliance.yml@ComplianceRepo
- template: ci-compliance.yml@ComplianceRepo
- stage: markdown_spelling_lint
displayName: Markdown Spelling and Lint
dependsOn: []
jobs:
- template: ./misc-analysis/mdSpell.yml
- stage: markdown_link
displayName: Markdown Link
dependsOn: []
jobs:
- template: ./misc-analysis/generateMarkdownMatrix.yml
parameters:
sourceScanPath: '$(repoPath)'
jobName: generateMatrix
taskName: matrixTask
- template: ./misc-analysis/markdown.yml
parameters:
matrix: $[ dependencies.generateMatrix.outputs['matrixTask.matrix'] ]
dependsOn: generateMatrix

View file

@ -0,0 +1,46 @@
parameters:
- name: jobName
- name: taskName
jobs:
- job: ${{ parameters.jobName }}
displayName: Generate Markdown Matrix
pool:
vmImage: ubuntu-20.04
variables:
- name: repoPath
value: $(Agent.BuildDirectory)/$(repoFolder)
steps:
- checkout: self
clean: true
path: $(repoFolder)
- powershell: |
$matrix = @{}
$matrix += @{
'root' = @{
markdown_folder = "$(repoPath)"
markdown_recurse = $false
}
}
Get-ChildItem -path '$(repoPath)' -Directory | Foreach-Object {
$folder = $_
$matrix += @{
$_.Name = @{
markdown_folder = $_.fullName
markdown_recurse = $true
}
}
}
$matrixJson = $matrix | ConvertTo-Json -Compress
$variableName = "matrix"
$command = "vso[task.setvariable variable=$variableName;isoutput=true]$($matrixJson)"
Write-Verbose "sending command: '$command'"
Write-Host "##$command"
displayName: Create Matrix
condition: succeededOrFailed()
name: ${{ parameters.taskName }}

View file

@ -0,0 +1,63 @@
parameters:
- name: matrix
- name: dependsOn
jobs:
- job: markdown
strategy:
matrix: ${{ parameters.matrix }}
maxParallel: 5
displayName: Markdown Link Verification
dependsOn: ${{ parameters.dependsOn }}
pool:
vmImage: ubuntu-20.04
variables:
- name: repoPath
value: $(Agent.BuildDirectory)/$(repoFolder)
- name: YARN_CACHE_FOLDER
value: $(Pipeline.Workspace)/.yarn
- name: YARN_GLOBAL_CACHE_FOLDER
value: $(Pipeline.Workspace)/.yarn-global
steps:
- checkout: self
clean: true
path: $(repoFolder)
- checkout: ComplianceRepo
- task: Cache@2
inputs:
key: '"markdown-link-check" | "$(Agent.OS)" | $(repoPath)/test/common/markdown-link/markdown-link.tests.ps1'
path: $(YARN_GLOBAL_CACHE_FOLDER)
displayName: Cache Yarn packages
- powershell: |
Install-module Pester -Scope CurrentUser -Force -MaximumVersion 4.99
displayName: Install Pester
- bash: |
curl -o- --progress-bar -L https://yarnpkg.com/install.sh | bash
displayName: Bootstrap Yarn
- bash: |
yarn config set global-folder "$(YARN_GLOBAL_CACHE_FOLDER)"
displayName: Set Yarn global cache folder
- ${{ if not(contains(variables['SYSTEM.COLLECTIONURI'],'mscodehub')) }}:
- pwsh: |
Import-module ./build.psm1
$path = Join-Path -Path $pwd -ChildPath './commonTestResults.xml'
$results = invoke-pester -Script ./test/common/markdown-link -OutputFile $path -OutputFormat NUnitXml -PassThru
Write-Host "##vso[results.publish type=NUnit;mergeResults=true;runTitle=Markdown Link;publishRunAttachments=true;resultFiles=$path;]"
if($results.TotalCount -eq 0 -or $results.FailedCount -gt 0)
{
throw "Markdown tests failed"
}
displayName: Run Markdown Link Tests
condition: succeededOrFailed()
workingDirectory: '$(repoPath)'

View file

@ -0,0 +1,56 @@
jobs:
- job: markdown
displayName: Markdown Spelling
pool:
vmImage: ubuntu-20.04
variables:
- name: repoPath
value: $(Agent.BuildDirectory)/$(repoFolder)
steps:
- checkout: self
clean: true
path: $(repoFolder)
- checkout: ComplianceRepo
- powershell: |
Get-ChildItem -Path env:
displayName: Capture Environment
condition: succeededOrFailed()
- bash: |
curl -o- --progress-bar -L https://yarnpkg.com/install.sh | bash
displayName: Bootstrap Yarn
condition: succeededOrFailed()
- bash: |
sudo yarn global add markdown-spellcheck@0.11.0
displayName: Install mdspell
condition: succeededOrFailed()
- bash: |
mdspell '**/*.md' '!**/Pester/**/*.md' '!**/dotnet-tools/**/*.md' --ignore-numbers --ignore-acronyms --report --en-us;
displayName: Test Spelling in Markdown
condition: succeededOrFailed()
workingDirectory: '$(repoPath)'
- ${{ if not(contains(variables['SYSTEM.COLLECTIONURI'],'mscodehub')) }}:
- pwsh: |
Import-module ./build.psm1
$path = Join-Path -Path $pwd -ChildPath './commonTestResults.xml'
$results = invoke-pester -Script ./test/common/markdown-lint -OutputFile $path -OutputFormat NUnitXml -PassThru
Write-Host "##vso[results.publish type=NUnit;mergeResults=true;runTitle=Markdown Lint;publishRunAttachments=true;resultFiles=$path;]"
if($results.TotalCount -eq 0 -or $results.FailedCount -gt 0)
{
throw "Markdown tests failed"
}
displayName: Run Markdown Lint Tests
condition: succeededOrFailed()
workingDirectory: '$(repoPath)'
- template: dailyBuildCompliance.yml@ComplianceRepo
parameters:
sourceScanPath: '$(repoPath)'

View file

@ -34,6 +34,8 @@ resources:
clean: true
jobs:
- job: SSHRemotingTests
pool:
vmImage: ubuntu-20.04
container: mcr.microsoft.com/powershell/test-deps:ubuntu-18.04
displayName: SSH Remoting Tests

View file

@ -11,38 +11,31 @@ jobs:
displayName: ${{ parameters.displayName }}
steps:
- powershell: |
- pwsh: |
Get-ChildItem -Path env:
displayName: Capture Environment
condition: succeededOrFailed()
- powershell: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))"
- pwsh: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))"
displayName: Set Build Name for Non-PR
condition: ne(variables['Build.Reason'], 'PullRequest')
- ${{ if ne(variables['AzDevOpsFeed'], '') }}:
- template: /tools/releaseBuild/azureDevOps/templates/insert-nuget-config-azfeed.yml
- pwsh: |
if (Test-Path -Path $HOME/.dotnet) {
Remove-Item $HOME/.dotnet -Recurse -Force
}
displayName: Remove Old .NET SDKs
condition: succeededOrFailed()
- pwsh: |
Import-Module .\tools\ci.psm1
Invoke-CIInstall -SkipUser
displayName: Bootstrap
condition: succeeded()
- powershell: |
- pwsh: |
Import-Module .\tools\ci.psm1
Invoke-CIBuild
displayName: Build
condition: succeeded()
- powershell: |
- pwsh: |
Import-Module .\tools\ci.psm1
Restore-PSOptions
Invoke-CIxUnit -SkipFailing

View file

@ -33,13 +33,6 @@ jobs:
displayName: 'Capture Artifacts Directory'
continueOnError: true
- pwsh: |
if (Test-Path -Path $HOME/.dotnet) {
Remove-Item $HOME/.dotnet -Recurse -Force
}
displayName: Remove Old .NET SDKs
condition: succeededOrFailed()
- pwsh: |
Import-Module .\tools\ci.psm1
Invoke-CIInstall -SkipUser

View file

@ -11,9 +11,9 @@ trigger:
include:
- '*'
exclude:
- /.vsts-ci/misc-analysis.yml
- /.github/ISSUE_TEMPLATE/*
- /.dependabot/config.yml
- .vsts-ci/misc-analysis.yml
- .github/ISSUE_TEMPLATE/*
- .dependabot/config.yml
- test/perf/*
pr:
branches:
@ -28,11 +28,15 @@ pr:
- .dependabot/config.yml
- .github/ISSUE_TEMPLATE/*
- .vsts-ci/misc-analysis.yml
- cgmanifest.json
- LICENSE.txt
- test/common/markdown/*
- test/perf/*
- tools/packaging/*
- tools/releaseBuild/*
- tools/releaseBuild/azureDevOps/templates/*
- README.md
- .spelling
variables:
GIT_CONFIG_PARAMETERS: "'core.autocrlf=false'"

View file

@ -1,25 +1,53 @@
parameters:
pool: 'Hosted VS2017'
jobName: 'win_packaging'
architecture: 'x64'
channel: 'preview'
parentJobs: []
- name: pool
default: 'Hosted VS2017'
- name: jobName
default: 'win_packaging'
- name: runtimePrefix
default: 'win7'
- name: architecture
default: 'x64'
- name: channel
default: 'preview'
jobs:
- job: ${{ parameters.jobName }}_${{ parameters.channel }}_${{ parameters.architecture }}
dependsOn:
${{ parameters.parentJobs }}
variables:
- name: repoFolder
value: PowerShell
- name: repoPath
value: $(Agent.BuildDirectory)\$(repoFolder)
- name: complianceRepoFolder
value: compliance
- name: complianceRepoPath
value: $(Agent.BuildDirectory)\$(complianceRepoFolder)
pool:
name: ${{ parameters.pool }}
displayName: Windows Packaging - ${{ parameters.architecture }} - ${{ parameters.channel }}
steps:
- checkout: self
clean: true
path: $(repoFolder)
- checkout: ComplianceRepo
clean: true
path: $(complianceRepoFolder)
- powershell: |
Get-ChildItem -Path env:
displayName: Capture environment
condition: succeededOrFailed()
- pwsh: |
$PSVersionTable
displayName: Capture PowerShell Version Table
condition: succeededOrFailed()
- template: /tools/releaseBuild/azureDevOps/templates/insert-nuget-config-azfeed.yml
- pwsh: |
@ -27,9 +55,24 @@ jobs:
Invoke-CIInstall -SkipUser
displayName: Bootstrap
condition: succeeded()
workingDirectory: $(repoPath)
- pwsh: |
Import-Module .\tools\ci.psm1
New-CodeCoverageAndTestPackage
Invoke-CIFinish -Runtime win7-${{ parameters.architecture }} -channel ${{ parameters.channel }}
displayName: Build and Test Package
Invoke-CIFinish -Runtime ${{ parameters.runtimePrefix }}-${{ parameters.architecture }} -channel ${{ parameters.channel }} -Stage Build
displayName: Build
workingDirectory: $(repoPath)
- template: Sbom.yml@ComplianceRepo
parameters:
BuildDropPath: '$(System.ArtifactsDirectory)/mainBuild'
Build_Repository_Uri: $(build.repository.uri)
displayName: SBOM
- pwsh: |
Import-Module .\tools\ci.psm1
New-CodeCoverageAndTestPackage
Invoke-CIFinish -Runtime ${{ parameters.runtimePrefix }}-${{ parameters.architecture }} -channel ${{ parameters.channel }} -Stage Package
displayName: Package and Test
workingDirectory: $(repoPath)

View file

@ -67,10 +67,17 @@ variables:
- name: __SuppressAnsiEscapeSequences
value: 1
- group: fakeNugetKey
- name: SBOMGenerator_Formats
value: spdx:2.2
resources:
- repo: self
clean: true
repositories:
- repository: ComplianceRepo
type: github
endpoint: PowerShell
name: PowerShell/compliance
ref: master
stages:
- stage: PackagingWin
displayName: Packaging for Windows
@ -86,3 +93,13 @@ stages:
parameters:
channel: preview
architecture: x86
- template: templates/windows-packaging.yml
parameters:
channel: preview
architecture: arm
runtimePrefix: win
- template: templates/windows-packaging.yml
parameters:
channel: preview
architecture: arm64
runtimePrefix: win

View file

@ -1,7 +1,7 @@
<Project>
<ItemGroup>
<PackageReference Include="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.59" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0-rc2.21458.5" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.354" PrivateAssets="all" />
</ItemGroup>
</Project>

View file

@ -1,5 +1,45 @@
# 7.0 Changelog
## [7.0.8] - 2021-10-14
### Engine Updates and Fixes
- Handle error from unauthorized access when removing `AppLocker` test files (#15881)
- Handle error when the telemetry mutex cannot be created (#15574) (Thanks @gukoff!)
- Configure `ApplicationInsights` to not send cloud role name (Internal 17099)
- Disallow `Add-Type` in NoLanguage mode on a locked down machine (Internal 17521)
### Tools
- Add `.stylecop` to `filetypexml` and format it (#16025)
### Build and Packaging Improvements
<details>
<summary>
<p>Bump .NET SDK to 3.1.414</p>
</summary>
<ul>
<li>Update the nuget.config file used for building NuGet packages (Internal 17547)</li>
<li>Sign the .NET <code>createdump</code> executable (#16229)</li>
<li>Upgrade <code>set-value</code> package for markdown test (#16196)</li>
<li>Move vPack build to 1ES Pool (#16169)</li>
<li>Update to .NET SDK 3.1.414 (Internal 17532)</li>
<li>Fix the macOS build by updating the pool image name (#16010)</li>
<li>Move from PkgES hosted agents to 1ES hosted agents (#16023)</li>
<li>Use Alpine 3.12 for building PowerShell for Alpine Linux (#16008)</li>
</ul>
</details>
### Documentation and Help Content
- Fix example nuget.config (#14349)
[7.0.8]: https://github.com/PowerShell/PowerShell/compare/v7.0.7...v7.0.8
## [7.0.7] - 2021-08-12
### Build and Packaging Improvements

View file

@ -1,5 +1,45 @@
# 7.1 Changelog
## [7.1.5] - 2021-10-14
### Engine Updates and Fixes
- Handle error from unauthorized access when removing `AppLocker` test files (#15881)
- Test more thoroughly whether a command is `Out-Default` for transcription scenarios (#15653)
- Handle error when the telemetry mutex cannot be created (#15574) (Thanks @gukoff!)
- Configure `ApplicationInsights` to not send cloud role name (Internal 17100)
- Disallow `Add-Type` in NoLanguage mode on a locked down machine (Internal 17522)
### Tools
- Add `.stylecop` to `filetypexml` and format it (#16025)
### Build and Packaging Improvements
<details>
<summary>
<p>Bump .NET SDK to 5.0.402</p>
</summary>
<ul>
<li>Upgrade <code>set-value</code> package for markdown test (#16196)</li>
<li>Sign the .NET <code>createdump</code> executable (#16229)</li>
<li>Move vPack build to 1ES Pool (#16169)</li>
<li>Update to .NET SDK 5.0.402 (Internal 17537)</li>
<li>Move from PkgES hosted agents to 1ES hosted agents (#16023)</li>
<li>Fix the macOS build by updating the pool image name (#16010)</li>
<li>Use Alpine 3.12 for building PowerShell for Alpine Linux (#16008)</li>
</ul>
</details>
### Documentation and Help Content
- Fix example nuget.config (#14349)
[7.1.5]: https://github.com/PowerShell/PowerShell/compare/v7.1.4...v7.1.5
## [7.1.4] - 2021-08-12
### Build and Packaging Improvements

1122
CHANGELOG/7.2.md Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,13 +1,15 @@
{
"sdk": {
"channel": "6.0.1xx-rc1",
"channel": "6.0.1xx",
"quality": "signed",
"qualityFallback": "daily",
"packageVersionPattern": "6.0.0-rc.1",
"packageVersionPattern": "6.0.0",
"sdkImageVersion": "6.0.100",
"nextChannel": "6.0.1xx-rc1"
"nextChannel": "6.0.1xx",
"azureFeed": "",
"sdkImageOverride": ""
},
"internalfeed" : {
"url": "https://pkgs.dev.azure.com/dnceng/public/_packaging/6.0.100-rc.1.21458.32-shipping/nuget/v2"
"url": ""
}
}

View file

@ -138,6 +138,7 @@
<TargetFramework>net6.0</TargetFramework>
<LangVersion>10.0</LangVersion>
<PublishReadyToRun Condition=" '$(Configuration)' != 'Debug' ">true</PublishReadyToRun>
<PublishReadyToRunEmitSymbols>true</PublishReadyToRunEmitSymbols>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

114
README.md
View file

@ -30,19 +30,19 @@ You can download and install a PowerShell package for any of the following platf
| -------------------------------------------| ------------------------| ------------------------| ----------------------| ------------------------------|
| [Windows (x64)][corefx-win] | [.msi][lts-windows-64] | [.msi][rl-windows-64] | [.msi][pv-windows-64] | [Instructions][in-windows] |
| [Windows (x86)][corefx-win] | [.msi][lts-windows-86] | [.msi][rl-windows-86] | [.msi][pv-windows-86] | [Instructions][in-windows] |
| [Ubuntu 20.04][corefx-linux] | | [.deb][rl-ubuntu20] | [.deb][pv-deb] | [Instructions][in-ubuntu20] |
| [Ubuntu 18.04][corefx-linux] | [.deb][lts-ubuntu18] | [.deb][rl-ubuntu18] | [.deb][pv-deb] | [Instructions][in-ubuntu18] |
| [Ubuntu 16.04][corefx-linux] | [.deb][lts-ubuntu16] | [.deb][rl-ubuntu16] | [.deb][pv-deb] | [Instructions][in-ubuntu16] |
| [Debian 9][corefx-linux] | [.deb][lts-debian9] | [.deb][rl-debian9] | [.deb][pv-deb] | [Instructions][in-deb9] |
| [Debian 10][corefx-linux] | [.deb][lts-debian10] | [.deb][rl-debian10] | [.deb][pv-deb] | [Instructions][in-deb9] |
| [Debian 11][corefx-linux] | | [.deb][rl-debian11] | [.deb][pv-deb] | |
| [CentOS 7][corefx-linux] | [.rpm][lts-centos] | [.rpm][rl-centos] | [.rpm][pv-rpm] | [Instructions][in-centos] |
| [CentOS 8][corefx-linux] | [.rpm][lts-centos8] | [.rpm][rl-centos8] | [.rpm][pv-rpm] | |
| [Red Hat Enterprise Linux 7][corefx-linux] | [.rpm][lts-centos] | [.rpm][rl-centos] | [.rpm][pv-rpm] | [Instructions][in-rhel7] |
| [openSUSE 42.3][corefx-linux] | [.rpm][lts-centos] | [.rpm][rl-centos] | [.rpm][pv-rpm] | [Instructions][in-opensuse] |
| [Fedora 30][corefx-linux] | [.rpm][lts-centos] | [.rpm][rl-centos] | [.rpm][pv-rpm] | [Instructions][in-fedora] |
| [Ubuntu 20.04][corefx-linux] | [.deb][lts-deb] | [.deb][rl-ubuntu20] | [.deb][pv-deb] | [Instructions][in-ubuntu20] |
| [Ubuntu 18.04][corefx-linux] | [.deb][lts-deb] | [.deb][rl-ubuntu18] | [.deb][pv-deb] | [Instructions][in-ubuntu18] |
| [Ubuntu 16.04][corefx-linux] | [.deb][lts-deb] | [.deb][rl-ubuntu16] | [.deb][pv-deb] | [Instructions][in-ubuntu16] |
| [Debian 9][corefx-linux] | [.deb][lts-deb] | [.deb][rl-debian9] | [.deb][pv-deb] | [Instructions][in-deb9] |
| [Debian 10][corefx-linux] | [.deb][lts-deb] | [.deb][rl-debian10] | [.deb][pv-deb] | [Instructions][in-deb9] |
| [Debian 11][corefx-linux] | [.deb][lts-deb] | [.deb][rl-debian11] | [.deb][pv-deb] | |
| [CentOS 7][corefx-linux] | [.rpm][lts-rh] | [.rpm][rl-centos] | [.rpm][pv-rpm] | [Instructions][in-centos] |
| [CentOS 8][corefx-linux] | [.rpm][lts-rh] | [.rpm][rl-centos8] | [.rpm][pv-rpm] | |
| [Red Hat Enterprise Linux 7][corefx-linux] | [.rpm][lts-rh] | [.rpm][rl-centos] | [.rpm][pv-rpm] | [Instructions][in-rhel7] |
| [openSUSE 42.3][corefx-linux] | [.rpm][lts-rh] | [.rpm][rl-centos] | [.rpm][pv-rpm] | [Instructions][in-opensuse] |
| [Fedora 30][corefx-linux] | [.rpm][lts-rh] | [.rpm][rl-centos] | [.rpm][pv-rpm] | [Instructions][in-fedora] |
| [macOS 10.13+ (x64)][corefx-macos] | [.pkg][lts-macos] | [.pkg][rl-macos] | [.pkg][pv-macos] | [Instructions][in-macos] |
| [macOS 10.13+ (arm64)][corefx-macos] | | | [.pkg][pv-macos-arm64]| [Instructions][in-macos] |
| [macOS 10.13+ (arm64)][corefx-macos] | [.pkg][lts-macos-arm64] | [.pkg][rl-macos-arm64] | [.pkg][pv-macos-arm64]| [Instructions][in-macos] |
| Docker | | | | [Instructions][in-docker] |
You can download and install a PowerShell package for any of the following platforms, **which are supported by the community.**
@ -58,56 +58,55 @@ You can also download the PowerShell binary archives for Windows, macOS and Linu
| Platform | Downloads (stable) | Downloads (preview) | How to Install |
| ---------------| --------------------------------------------------- | ------------------------------------------------| -----------------------------------------------|
| Windows | [32-bit][rl-winx86-zip]/[64-bit][rl-winx64-zip] | [32-bit][pv-winx86-zip]/[64-bit][pv-winx64-zip] | [Instructions][in-windows-zip] |
| macOS | [64-bit][rl-macos-tar] | [64-bit][pv-macos-tar] | [Instructions][in-tar-macos] |
| macOS | | [64-bit][pv-macos-tar-arm64] | [Instructions][in-tar-macos] |
| macOS (x64) | [64-bit][rl-macos-tar] | [64-bit][pv-macos-tar] | [Instructions][in-tar-macos] |
| macOS (arm64) | [64-bit][rl-macos-tar-arm64] | [64-bit][pv-macos-tar-arm64] | [Instructions][in-tar-macos] |
| Linux | [64-bit][rl-linux-tar] | [64-bit][pv-linux-tar] | [Instructions][in-tar-linux] |
| Windows (Arm) | [64-bit][rl-winarm64] (preview) | [64-bit][pv-winarm64] | [Instructions][in-arm] |
| Raspbian (Arm) | [32-bit][rl-arm32]/[64-bit][rl-arm64] | [32-bit][pv-arm32]/[64-bit][pv-arm64] | [Instructions][in-raspbian] |
[lts-windows-86]: https://github.com/PowerShell/PowerShell/releases/download/v7.0.7/PowerShell-7.0.7-win-x86.msi
[lts-windows-64]: https://github.com/PowerShell/PowerShell/releases/download/v7.0.7/PowerShell-7.0.7-win-x64.msi
[lts-ubuntu18]: https://github.com/PowerShell/PowerShell/releases/download/v7.0.7/powershell-lts_7.0.7-1.ubuntu.18.04_amd64.deb
[lts-ubuntu16]: https://github.com/PowerShell/PowerShell/releases/download/v7.0.7/powershell-lts_7.0.7-1.ubuntu.16.04_amd64.deb
[lts-debian9]: https://github.com/PowerShell/PowerShell/releases/download/v7.0.7/powershell-lts_7.0.7-1.debian.9_amd64.deb
[lts-debian10]: https://github.com/PowerShell/PowerShell/releases/download/v7.0.7/powershell-lts_7.0.7-1.debian.10_amd64.deb
[lts-centos]: https://github.com/PowerShell/PowerShell/releases/download/v7.0.7/powershell-lts-7.0.7-1.rhel.7.x86_64.rpm
[lts-centos8]: https://github.com/PowerShell/PowerShell/releases/download/v7.0.7/powershell-lts-7.0.7-1.centos.8.x86_64.rpm
[lts-macos]: https://github.com/PowerShell/PowerShell/releases/download/v7.0.7/powershell-lts-7.0.7-osx-x64.pkg
[lts-windows-86]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/PowerShell-7.2.0-win-x86.msi
[lts-windows-64]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/PowerShell-7.2.0-win-x64.msi
[lts-deb]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell-lts_7.2.0-1.deb_amd64.deb
[lts-rh]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell-lts-7.2.0-1.rh.x86_64.rpm
[lts-macos]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell-lts-7.2.0-osx-x64.pkg
[lts-macos-arm64]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell-lts-7.2.0-osx-arm64.pkg
[rl-windows-64]: https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/PowerShell-7.1.4-win-x64.msi
[rl-windows-86]: https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/PowerShell-7.1.4-win-x86.msi
[rl-ubuntu20]: https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/powershell_7.1.4-1.ubuntu.20.04_amd64.deb
[rl-ubuntu18]: https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/powershell_7.1.4-1.ubuntu.18.04_amd64.deb
[rl-ubuntu16]: https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/powershell_7.1.4-1.ubuntu.16.04_amd64.deb
[rl-debian9]: https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/powershell_7.1.4-1.debian.9_amd64.deb
[rl-debian10]: https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/powershell_7.1.4-1.debian.10_amd64.deb
[rl-debian11]: https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/powershell_7.1.4-1.debian.11_amd64.deb
[rl-centos]: https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/powershell-7.1.4-1.rhel.7.x86_64.rpm
[rl-centos8]: https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/powershell-7.1.4-1.centos.8.x86_64.rpm
[rl-macos]: https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/powershell-7.1.4-osx-x64.pkg
[rl-winarm64]: https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/PowerShell-7.1.4-win-arm64.zip
[rl-winx86-zip]: https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/PowerShell-7.1.4-win-x86.zip
[rl-winx64-zip]: https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/PowerShell-7.1.4-win-x64.zip
[rl-macos-tar]: https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/powershell-7.1.4-osx-x64.tar.gz
[rl-linux-tar]: https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/powershell-7.1.4-linux-x64.tar.gz
[rl-arm32]: https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/powershell-7.1.4-linux-arm32.tar.gz
[rl-arm64]: https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/powershell-7.1.4-linux-arm64.tar.gz
[rl-windows-64]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/PowerShell-7.2.0-win-x64.msi
[rl-windows-86]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/PowerShell-7.2.0-win-x86.msi
[rl-ubuntu20]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell_7.2.0-1.deb_amd64.deb
[rl-ubuntu18]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell_7.2.0-1.deb_amd64.deb
[rl-ubuntu16]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell_7.2.0-1.deb_amd64.deb
[rl-debian9]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell_7.2.0-1.deb_amd64.deb
[rl-debian10]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell_7.2.0-1.deb_amd64.deb
[rl-debian11]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell_7.2.0-1.deb_amd64.deb
[rl-centos]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell-7.2.0-1.rh.x86_64.rpm
[rl-centos8]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell-7.2.0-1.rh.x86_64.rpm
[rl-macos]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell-7.2.0-osx-x64.pkg
[rl-macos-arm64]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell-7.2.0-osx-arm64.pkg
[rl-winarm64]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/PowerShell-7.2.0-win-arm64.zip
[rl-winx86-zip]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/PowerShell-7.2.0-win-x86.zip
[rl-winx64-zip]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/PowerShell-7.2.0-win-x64.zip
[rl-macos-tar]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell-7.2.0-osx-x64.tar.gz
[rl-macos-tar-arm64]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell-7.2.0-osx-arm64.tar.gz
[rl-linux-tar]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell-7.2.0-linux-x64.tar.gz
[rl-arm32]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell-7.2.0-linux-arm32.tar.gz
[rl-arm64]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell-7.2.0-linux-arm64.tar.gz
[rl-snap]: https://snapcraft.io/powershell
[pv-windows-64]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-preview.8/PowerShell-7.2.0-preview.8-win-x64.msi
[pv-windows-86]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-preview.8/PowerShell-7.2.0-preview.8-win-x86.msi
[pv-deb]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-preview.8/powershell-preview_7.2.0-preview.8-1.deb_amd64.deb
[pv-rpm]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-preview.8/powershell-preview-7.2.0_preview.8-1.rh.x86_64.rpm
[pv-macos]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-preview.8/powershell-7.2.0-preview.8-osx-x64.pkg
[pv-macos-arm64]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-preview.8/powershell-7.2.0-preview.8-osx-arm64.pkg
[pv-winarm64]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-preview.8/PowerShell-7.2.0-preview.8-win-arm64.zip
[pv-winx86-zip]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-preview.8/PowerShell-7.2.0-preview.8-win-x86.zip
[pv-winx64-zip]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-preview.8/PowerShell-7.2.0-preview.8-win-x64.zip
[pv-macos-tar]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-preview.8/powershell-7.2.0-preview.8-osx-x64.tar.gz
[pv-macos-tar-arm64]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-preview.8/powershell-7.2.0-preview.8-osx-arm64.tar.gz
[pv-linux-tar]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-preview.8/powershell-7.2.0-preview.8-linux-x64.tar.gz
[pv-arm32]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-preview.8/powershell-7.2.0-preview.8-linux-arm32.tar.gz
[pv-arm64]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-preview.8/powershell-7.2.0-preview.8-linux-arm64.tar.gz
[pv-windows-64]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-rc.1/PowerShell-7.2.0-rc.1-win-x64.msi
[pv-windows-86]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-rc.1/PowerShell-7.2.0-rc.1-win-x86.msi
[pv-deb]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-rc.1/powershell-preview_7.2.0-rc.1-1.deb_amd64.deb
[pv-rpm]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-rc.1/powershell-preview-7.2.0_rc.1-1.rh.x86_64.rpm
[pv-macos]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-rc.1/powershell-7.2.0-rc.1-osx-x64.pkg
[pv-macos-arm64]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-rc.1/powershell-7.2.0-rc.1-osx-arm64.pkg
[pv-winarm64]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-rc.1/PowerShell-7.2.0-rc.1-win-arm64.zip
[pv-winx86-zip]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-rc.1/PowerShell-7.2.0-rc.1-win-x86.zip
[pv-winx64-zip]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-rc.1/PowerShell-7.2.0-rc.1-win-x64.zip
[pv-macos-tar]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-rc.1/powershell-7.2.0-rc.1-osx-x64.tar.gz
[pv-macos-tar-arm64]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-rc.1/powershell-7.2.0-rc.1-osx-arm64.tar.gz
[pv-linux-tar]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-rc.1/powershell-7.2.0-rc.1-linux-x64.tar.gz
[pv-arm32]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-rc.1/powershell-7.2.0-rc.1-linux-arm32.tar.gz
[pv-arm64]: https://github.com/PowerShell/PowerShell/releases/download/v7.2.0-rc.1/powershell-7.2.0-rc.1-linux-arm64.tar.gz
[pv-snap]: https://snapcraft.io/powershell-preview
[in-windows]: https://docs.microsoft.com/powershell/scripting/install/installing-powershell-core-on-windows
@ -240,9 +239,8 @@ License: By requesting and using the Container OS Image for Windows containers,
### Telemetry
By default, PowerShell collects the OS description and the version of PowerShell (equivalent to `$PSVersionTable.OS` and `$PSVersionTable.GitCommitId`) using [Application Insights](https://azure.microsoft.com/services/application-insights/).
To opt-out of sending telemetry, create an environment variable called `POWERSHELL_TELEMETRY_OPTOUT` set to a value of `1` before starting PowerShell from the installed location.
The telemetry we collect falls under the [Microsoft Privacy Statement](https://privacy.microsoft.com/privacystatement/).
Please visit our [about_Telemetry](https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_telemetry)
topic to read details about telemetry gathered by PowerShell.
## Governance

File diff suppressed because it is too large Load diff

View file

@ -1,46 +1,42 @@
## Used to generate a new TPN
## Copy this into the additional attributions fields
## Copy everything below here, but do not include this line
---------------------------------------------
File: PSReadLine
---------------------------------------------
-------------------------------------------------------------------
https://github.com/lzybkr/PSReadLine
-------------------------------------------------------------------
Copyright (c) 2013, Jason Shirk
Additional -
All rights reserved.
-------------------------------------------------
Microsoft.PowerShell.Archive
-------------------------------------------------
BSD License
Copyright (c) 2016 Microsoft Corporation.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
The MIT License (MIT)
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
----------------------------------------------
File: Hashtables from ConvertFrom-json
----------------------------------------------
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
https://stackoverflow.com/questions/22002748/hashtables-from-convertfrom-json-have-different-type-from-powershells-built-in-h
-------------------------------------------------
Microsoft.Management.Infrastructure.Runtime.Unix
Microsoft.Management.Infrastructure
-------------------------------------------------
Copyright (c) 2015 Dave Wyatt. All rights reserved.
Copyright (c) Microsoft Corporation
All rights reserved.
@ -52,33 +48,6 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------
PackageManagement
-------------------------------------------------
Copyright (c) Microsoft Corporation
All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the Software), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
--------------------------------------------------------
• NuGet.Common
• NuGet.Configuration
@ -108,3 +77,116 @@ Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-------------------------------------------------
PackageManagement
-------------------------------------------------
Copyright (c) Microsoft Corporation
All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the Software), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-------------------------------------------------
PowerShellGet
-------------------------------------------------
Copyright (c) Microsoft Corporation
All rights reserved.
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---------------------------------------------
File: PSReadLine
---------------------------------------------
https://github.com/PowerShell/PSReadLine
Copyright (c) 2013, Jason Shirk
All rights reserved.
BSD License
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------
ThreadJob
-------------------------------------------------
Copyright (c) 2018 Paul Higinbotham
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -350,7 +350,7 @@
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" TabSkip="yes" />
<Control Id="Description" Type="Text" X="25" Y="54" Width="280" Height="100" Transparent="yes" NoPrefix="yes" Text="Microsoft Update helps keep your computer secure and up to date for Windows and other Microsoft products, including PowerShell 7. Updates will be delivered based on your current update settings. You can review or change these settings from the Windows Update control panel." TabSkip="yes" />
<!-- If the checkboxes are defined first, then they are first in the tab order and can be ticked and unticked using the spacebar -->
<Control Id="UseMuCheckBox" Type="CheckBox" X="20" Y="100" Width="290" Height="27" Property="USE_MU" CheckBoxValue="1" Text="Enable updating PowerShell through Microsft Update or WSUS (recommended)"/>
<Control Id="UseMuCheckBox" Type="CheckBox" X="20" Y="100" Width="290" Height="27" Property="USE_MU" CheckBoxValue="1" Text="Enable updating PowerShell through Microsoft Update or WSUS (recommended)"/>
<Control Id="EnableMuCheckBox" Type="CheckBox" X="20" Y="130" Width="290" Height="17" Property="ENABLE_MU" CheckBoxValue="1" Text="Use Microsoft Update when I check for updates (recommended)">
</Control>
<Control Id="MuWarningText" Type="Text" X="20" Y="160" Width="290" Height="27" Text="Without Microsoft Update enabled, you will need to use another update solution like WSUS or SCCM in order to receive automatic updates.">
@ -361,7 +361,7 @@
<Text><![CDATA[<a href="https://aka.ms/PowerShell-Microsoft-Update-FAQ">See the Microsoft Update FAQ</a>]]></Text>
</Control>
<Control Id="PrivacyLink" Type="Hyperlink" X="20" Y="210" Width="290" Height="17">
<Text><![CDATA[<a href="https://aka.ms/PowerShell-Microsoft-Update-Privacy-Statement">Read the Microsoft Update Priacy Statement</a>]]></Text>
<Text><![CDATA[<a href="https://aka.ms/PowerShell-Microsoft-Update-Privacy-Statement">Read the Microsoft Update Privacy Statement</a>]]></Text>
</Control>
<!-- divider and bottom buttons -->
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" TabSkip="yes"/>

View file

@ -1987,6 +1987,12 @@
<Component Id="cmp57D197B18F1F4A6AAB704B28CF61B535">
<File Id="fil71B3802CB88348AC888B9902212CADA2" KeyPath="yes" Source="$(var.ProductSourcePath)\cs\Microsoft.VisualBasic.Forms.resources.dll" />
</Component>
<Component Id="cmp690BAC3241424F59B5D30DE0E846D03E">
<File Id="filDBDCB9BFFF9F425B8CF7F7A5F05D42B1" KeyPath="yes" Source="$(var.ProductSourcePath)\cs\System.Private.ServiceModel.resources.dll" />
</Component>
<Component Id="cmp5B67AE2852E04C26970FD2016CA76E07">
<File Id="fil42D10EBCB41B426BAFBF26BB053A9E84" KeyPath="yes" Source="$(var.ProductSourcePath)\cs\System.Web.Services.Description.resources.dll" />
</Component>
</Directory>
<Directory Id="dirEA0127D6607E68B508B9DB9CE315A2CE" Name="de">
<Component Id="cmpF2941A91B17EEA22CD6DAB34693D9AC0">
@ -2046,6 +2052,12 @@
<Component Id="cmpB40EE0CC916B4928987F62F5909AE709">
<File Id="filA21E2DDEAEAE4E0D94346C5671D9D29F" KeyPath="yes" Source="$(var.ProductSourcePath)\de\System.Windows.Forms.Primitives.resources.dll" />
</Component>
<Component Id="cmpB43ED7BA30C844E2B5C38F7B747EEFDC">
<File Id="filE106C77258F047E8A384E1E75B7EF6B8" KeyPath="yes" Source="$(var.ProductSourcePath)\de\System.Private.ServiceModel.resources.dll" />
</Component>
<Component Id="cmp777DF202EF2542F2ACFCCF0481E8D6EE">
<File Id="filFCCE95BFDDD540E1AA243049872EF5D0" KeyPath="yes" Source="$(var.ProductSourcePath)\de\System.Web.Services.Description.resources.dll" />
</Component>
</Directory>
<Directory Id="dir5B65D7353FBDCD17AB60A674B3FDF93B" Name="es">
<Component Id="cmpBEB5F3CF75675537751F0D0B32125BF1">
@ -2105,6 +2117,12 @@
<Component Id="cmpB944176DE7924A268269903DC0B5D510">
<File Id="filBA47C41DFB3849228624C99949FB61FC" KeyPath="yes" Source="$(var.ProductSourcePath)\es\System.Windows.Forms.Primitives.resources.dll" />
</Component>
<Component Id="cmpCC4A42AA70EE4418926986F5A4B8D3FA">
<File Id="fil186134FCB6984F1484A8308DF4F2B917" KeyPath="yes" Source="$(var.ProductSourcePath)\es\System.Private.ServiceModel.resources.dll" />
</Component>
<Component Id="cmpF96C036EAE3B436DB096888697193FAF">
<File Id="fil761ECB84FAFA4674AB5712669532C569" KeyPath="yes" Source="$(var.ProductSourcePath)\es\System.Web.Services.Description.resources.dll" />
</Component>
</Directory>
<Directory Id="dir23063512FA8C884E1B4F08FDF0A44516" Name="fr">
<Component Id="cmp1DEB513A065956086898BCDACC5887B6">
@ -2164,6 +2182,12 @@
<Component Id="cmp7B5948A1A366409F99B871F0E772B945">
<File Id="filCCA6A5EE7ED9459C93A8C05B0A93880F" KeyPath="yes" Source="$(var.ProductSourcePath)\fr\System.Windows.Forms.Primitives.resources.dll" />
</Component>
<Component Id="cmpE7BE9D8F63E04798870E57BA1EABB9A5">
<File Id="fil93C038D9EED945F5A984CF3C98EDB72B" KeyPath="yes" Source="$(var.ProductSourcePath)\fr\System.Private.ServiceModel.resources.dll" />
</Component>
<Component Id="cmp789F545EA2CB4AC5A2688CF730A5F6B4">
<File Id="fil70A83BE26FCF4905B220521A6B75198D" KeyPath="yes" Source="$(var.ProductSourcePath)\fr\System.Web.Services.Description.resources.dll" />
</Component>
</Directory>
<Directory Id="dir42B03840AE19D1498CC524F2B6C0389D" Name="it">
<Component Id="cmp3EC91B8BF4282E77113321E5D1ED27B2">
@ -2223,6 +2247,12 @@
<Component Id="cmp28349C4ACD6D42D3967853E0A1D7DC4E">
<File Id="filDF0828378FCA4CAC8F7DA90DC4F802CC" KeyPath="yes" Source="$(var.ProductSourcePath)\it\Microsoft.VisualBasic.Forms.resources.dll" />
</Component>
<Component Id="cmp166B17F72C954B0087DF991E560B399A">
<File Id="fil528F0FBF10C246568FCE1F5B10E541D1" KeyPath="yes" Source="$(var.ProductSourcePath)\it\System.Private.ServiceModel.resources.dll" />
</Component>
<Component Id="cmp0173AE0CBFA44C269D93361F6C98F99B">
<File Id="fil3767F5D3C1264EC596A9F335355521C6" KeyPath="yes" Source="$(var.ProductSourcePath)\it\System.Web.Services.Description.resources.dll" />
</Component>
</Directory>
<Directory Id="dir086D21BE309BE4C7081FC60E3524890F" Name="ja">
<Component Id="cmp867E4E51FE7BC09AAD5D59FD76716FBC">
@ -2282,6 +2312,12 @@
<Component Id="cmp26335B5D1FE94E87A6B6EBD56A22C2B9">
<File Id="filD585A7E89ACF4E4CB9DB8EAD4ACB7092" KeyPath="yes" Source="$(var.ProductSourcePath)\ja\System.Windows.Forms.Primitives.resources.dll" />
</Component>
<Component Id="cmp529A2B5343FD466884FAF627E37C648D">
<File Id="fil265B2A6A67EF4C6E8C17BDC3AAD8F729" KeyPath="yes" Source="$(var.ProductSourcePath)\ja\System.Private.ServiceModel.resources.dll" />
</Component>
<Component Id="cmp5492F78ACB1A4391BBED371FDFC06B9E">
<File Id="fil54F7909E28E54B0687222DFD1D95009D" KeyPath="yes" Source="$(var.ProductSourcePath)\ja\System.Web.Services.Description.resources.dll" />
</Component>
</Directory>
<Directory Id="dir43D6CAD5F3ED1060009918D06D84FB18" Name="ko">
<Component Id="cmpAA026CCA623F0E8FB5BAE9F201C5B89D">
@ -2341,6 +2377,12 @@
<Component Id="cmpF4093A1E8AB94B43AB0F852EB647CE7F">
<File Id="filCE28F42A54C24F5DA508904E60E23BBD" KeyPath="yes" Source="$(var.ProductSourcePath)\ko\System.Windows.Forms.Primitives.resources.dll" />
</Component>
<Component Id="cmp4EE1633EE4864CE5B9015BF76BD31D14">
<File Id="fil688FE14A80204086A48DE1BDC6591EB0" KeyPath="yes" Source="$(var.ProductSourcePath)\ko\System.Private.ServiceModel.resources.dll" />
</Component>
<Component Id="cmp3B07F4E4B6034F3284288C18F4638CA7">
<File Id="filA52AFEA335CA41D98DB28358CE344EB5" KeyPath="yes" Source="$(var.ProductSourcePath)\ko\System.Web.Services.Description.resources.dll" />
</Component>
</Directory>
<Directory Id="dirE8201C74A7184D11233BAD63C6DB37BD" Name="pl">
<Component Id="cmpA656A18FE14D3C8EB02C31AE474054E3">
@ -2400,6 +2442,12 @@
<Component Id="cmp705598FEC8EA43D7A9B239787BA5DB09">
<File Id="filD8ECB20D015F4477ABD58505B48D02D1" KeyPath="yes" Source="$(var.ProductSourcePath)\pl\System.Windows.Forms.Primitives.resources.dll" />
</Component>
<Component Id="cmpC8C68DB0DEE44CF49D98532D2C26395E">
<File Id="fil1959B05E9F214DCFA6670F1892EE2E7D" KeyPath="yes" Source="$(var.ProductSourcePath)\pl\System.Private.ServiceModel.resources.dll" />
</Component>
<Component Id="cmpA8A66545C44F428BB552B55EEE353BB0">
<File Id="filC0107BEFC31E4F9AB5037537B82D92EF" KeyPath="yes" Source="$(var.ProductSourcePath)\pl\System.Web.Services.Description.resources.dll" />
</Component>
</Directory>
<Directory Id="dir47ED939BFA870848E0764E862CD6B4D7" Name="pt-BR">
<Component Id="cmp3D20E940BDBF41630242C63011A80CE5">
@ -2459,6 +2507,12 @@
<Component Id="cmpFAA0CCBA17FE4E8FAE5FE4B5F679DF52">
<File Id="fil6A42B845F64A4B2490AFFA079E0FB086" KeyPath="yes" Source="$(var.ProductSourcePath)\pt-BR\System.Windows.Forms.Primitives.resources.dll" />
</Component>
<Component Id="cmpF3C18F07C6A148638CBC858EB02E3A6D">
<File Id="filE6672552F1EE45D3AC3021E02DB093CB" KeyPath="yes" Source="$(var.ProductSourcePath)\pt-BR\System.Private.ServiceModel.resources.dll" />
</Component>
<Component Id="cmp0C4751F9D5C14419A45F234152D21DA9">
<File Id="filF6E3EF23DEEF4D3BB3CA9C9D084FB607" KeyPath="yes" Source="$(var.ProductSourcePath)\pt-BR\System.Web.Services.Description.resources.dll" />
</Component>
</Directory>
<Directory Id="dir37B8DFAE26D5F8E9948851F7D19F9E20" Name="ru">
<Component Id="cmpFDCD51BD80926ABECCE27D0D66A47C8F">
@ -2518,6 +2572,12 @@
<Component Id="cmpA6FA5B27C61E482D8BBC5F1806D3B223">
<File Id="filD4732A3ABFD342B890F75CCB5DE1CAE8" KeyPath="yes" Source="$(var.ProductSourcePath)\ru\System.Windows.Forms.Primitives.resources.dll" />
</Component>
<Component Id="cmpBD958F4B8F9146499DE2CA6321C65F96">
<File Id="fil6A1EB9311FE546F69F28948794DC43BF" KeyPath="yes" Source="$(var.ProductSourcePath)\ru\System.Private.ServiceModel.resources.dll" />
</Component>
<Component Id="cmp6ADB50DF9F2D4BCA9E682AA6D1C7C03B">
<File Id="fil7FECA5AED84D4C84968358F2C065BBEC" KeyPath="yes" Source="$(var.ProductSourcePath)\ru\System.Web.Services.Description.resources.dll" />
</Component>
</Directory>
<Directory Id="dirA7E9CC01273A7FED89FC8D3A368E00CC" Name="tr">
<Component Id="cmp286FCD0B19BF06446A7274672A2491CA">
@ -2577,6 +2637,12 @@
<Component Id="cmp10773057C33543FA93222022DEC0847D">
<File Id="filD2D3E621E5C54C5EBF044078C9073C2B" KeyPath="yes" Source="$(var.ProductSourcePath)\tr\Microsoft.VisualBasic.Forms.resources.dll" />
</Component>
<Component Id="cmp2B8239B905B146A69CD5D55A353AC131">
<File Id="fil618AA430D1794A45A1D2BAA2451BECB2" KeyPath="yes" Source="$(var.ProductSourcePath)\tr\System.Private.ServiceModel.resources.dll" />
</Component>
<Component Id="cmp9FCFAEB797D9475C873E21B4B5A89E28">
<File Id="filC4BDA69F669843EAAD7B6D8714CB1420" KeyPath="yes" Source="$(var.ProductSourcePath)\tr\System.Web.Services.Description.resources.dll" />
</Component>
</Directory>
<Directory Id="dir47E993970F74AA9F393D23500827D12C" Name="zh-Hans">
<Component Id="cmp34C4A21743AC68583599BF2B139F39F2">
@ -2636,6 +2702,12 @@
<Component Id="cmp33364765C98D4BE09BD26DC1E6B95B86">
<File Id="filB57C4C58936D4A7587CEA358B1AF57C2" KeyPath="yes" Source="$(var.ProductSourcePath)\zh-Hans\Microsoft.VisualBasic.Forms.resources.dll" />
</Component>
<Component Id="cmp582595AE8291444E837793472E0A259C">
<File Id="fil7044506B31FA4130B2E375147032298D" KeyPath="yes" Source="$(var.ProductSourcePath)\zh-Hans\System.Private.ServiceModel.resources.dll" />
</Component>
<Component Id="cmpF24D3B9F29F84B4D9C47577B7926FC2E">
<File Id="fil0AF0C0F933404EABBC94B10ED8740042" KeyPath="yes" Source="$(var.ProductSourcePath)\zh-Hans\System.Web.Services.Description.resources.dll" />
</Component>
</Directory>
<Directory Id="dirB1FFB91EED6FD71EA866548CEA3A5298" Name="zh-Hant">
<Component Id="cmpBC28FE8B65954B00AECA9C534639596D">
@ -2695,6 +2767,12 @@
<Component Id="cmpB9B22A80E70F414B8778B852E29D6492">
<File Id="fil46C0F341CAB64BD390BEA73E1FE0F552" KeyPath="yes" Source="$(var.ProductSourcePath)\zh-Hant\Microsoft.VisualBasic.Forms.resources.dll" />
</Component>
<Component Id="cmp91C27D1766E84B8BB0F0C70888F03C2E">
<File Id="filC888727CE05A4A9FA0DB66EE0F15097C" KeyPath="yes" Source="$(var.ProductSourcePath)\zh-Hant\System.Private.ServiceModel.resources.dll" />
</Component>
<Component Id="cmpD55F08F6CF51498E9E8551067BA57040">
<File Id="fil46C47F01171F45A898A7AD6A14ACE432" KeyPath="yes" Source="$(var.ProductSourcePath)\zh-Hant\System.Web.Services.Description.resources.dll" />
</Component>
</Directory>
<Directory Name="Schemas" Id="dir1DB5B24CC3494785974A51F28F128069">
<Directory Name="PSMaml" Id="dirAC38B2C7629B42DC836E01F976A10EC9">
@ -3054,8 +3132,27 @@
<Component Id="cmp957498053E01454DA1E21E6D7317DCD6">
<File Id="fil2AA6F0D8A51D4BB89F33F2B73AB12391" KeyPath="yes" Source="$(var.ProductSourcePath)\msquic.dll" />
</Component>
<Component Id="cmp2EB55EB6B44F4CF186F0BAFD6B33BCD6">
<File Id="filC629C6EFCF314F9BB78C56E0876C08EB" KeyPath="yes" Source="$(var.ProductSourcePath)\mscordaccore_$(var.FileArchitecture)_$(var.FileArchitecture)_6.0.21.45113.dll" />
<Directory Name="_manifest" Id="dir81094D6B916B4BC8B1BA0E1DADB93A02">
<Directory Name="spdx_2.2" Id="dirA36413FB3A534FDF8657D62728080E9F">
<Component Id="cmp408A3AF905EB47ADA35FBC5A6B1465A0">
<File Id="fil2146848B6ACB45FCA8E9C8FEE3BECDD8" KeyPath="yes" Source="$(var.ProductSourcePath)\_manifest\spdx_2.2\manifest.spdx.json" />
</Component>
</Directory>
</Directory>
<Component Id="cmpA6276F9EAB41411AAAEC496E67A3DBAE">
<File Id="filC840646CDE814D33B16DA3A5BBDDC88D" KeyPath="yes" Source="$(var.ProductSourcePath)\psoptions.json" />
</Component>
<Component Id="cmp3CF3F69A352F4438B8F2F73EBBD12996">
<File Id="filB8F63979F96B4007BA9C0CE6BD3531D0" KeyPath="yes" Source="$(var.ProductSourcePath)\Microsoft.Extensions.ObjectPool.dll" />
</Component>
<Component Id="cmp09155DA101E1424B98832A789E93E835">
<File Id="fil7D748565EBF5423A84CFC6D25D21F43C" KeyPath="yes" Source="$(var.ProductSourcePath)\Microsoft.Bcl.AsyncInterfaces.dll" />
</Component>
<Component Id="cmp22840874A8C84AA796496634FBEBF09C">
<File Id="fil2067B616D1FA4B30932A0240ABE06089" KeyPath="yes" Source="$(var.ProductSourcePath)\System.Web.Services.Description.dll" />
</Component>
<Component Id="cmpFB17CABA17334B2BBA1ED6CBF757B310">
<File Id="fil1621E0132D2C49B89068166196075157" KeyPath="yes" Source="$(var.ProductSourcePath)\mscordaccore_$(var.FileArchitecture)_$(var.FileArchitecture)_6.0.21.52210.dll" />
</Component>
</DirectoryRef>
</Fragment>
@ -4041,7 +4138,38 @@
<ComponentRef Id="cmp708913639F7A46E784CC0FA862A1A2CE" />
<ComponentRef Id="cmpA75DEF5617C54DA1937CB37D5824BF79" />
<ComponentRef Id="cmp957498053E01454DA1E21E6D7317DCD6" />
<ComponentRef Id="cmp2EB55EB6B44F4CF186F0BAFD6B33BCD6" />
<ComponentRef Id="cmp408A3AF905EB47ADA35FBC5A6B1465A0" />
<ComponentRef Id="cmpA6276F9EAB41411AAAEC496E67A3DBAE" />
<ComponentRef Id="cmp91C27D1766E84B8BB0F0C70888F03C2E" />
<ComponentRef Id="cmpCC4A42AA70EE4418926986F5A4B8D3FA" />
<ComponentRef Id="cmp690BAC3241424F59B5D30DE0E846D03E" />
<ComponentRef Id="cmp3CF3F69A352F4438B8F2F73EBBD12996" />
<ComponentRef Id="cmp09155DA101E1424B98832A789E93E835" />
<ComponentRef Id="cmpC8C68DB0DEE44CF49D98532D2C26395E" />
<ComponentRef Id="cmpB43ED7BA30C844E2B5C38F7B747EEFDC" />
<ComponentRef Id="cmpF3C18F07C6A148638CBC858EB02E3A6D" />
<ComponentRef Id="cmp582595AE8291444E837793472E0A259C" />
<ComponentRef Id="cmp2B8239B905B146A69CD5D55A353AC131" />
<ComponentRef Id="cmpBD958F4B8F9146499DE2CA6321C65F96" />
<ComponentRef Id="cmp166B17F72C954B0087DF991E560B399A" />
<ComponentRef Id="cmp529A2B5343FD466884FAF627E37C648D" />
<ComponentRef Id="cmp4EE1633EE4864CE5B9015BF76BD31D14" />
<ComponentRef Id="cmpE7BE9D8F63E04798870E57BA1EABB9A5" />
<ComponentRef Id="cmp5B67AE2852E04C26970FD2016CA76E07" />
<ComponentRef Id="cmp6ADB50DF9F2D4BCA9E682AA6D1C7C03B" />
<ComponentRef Id="cmpA8A66545C44F428BB552B55EEE353BB0" />
<ComponentRef Id="cmp5492F78ACB1A4391BBED371FDFC06B9E" />
<ComponentRef Id="cmp22840874A8C84AA796496634FBEBF09C" />
<ComponentRef Id="cmp0173AE0CBFA44C269D93361F6C98F99B" />
<ComponentRef Id="cmpFB17CABA17334B2BBA1ED6CBF757B310" />
<ComponentRef Id="cmpD55F08F6CF51498E9E8551067BA57040" />
<ComponentRef Id="cmp777DF202EF2542F2ACFCCF0481E8D6EE" />
<ComponentRef Id="cmpF24D3B9F29F84B4D9C47577B7926FC2E" />
<ComponentRef Id="cmp3B07F4E4B6034F3284288C18F4638CA7" />
<ComponentRef Id="cmp9FCFAEB797D9475C873E21B4B5A89E28" />
<ComponentRef Id="cmp0C4751F9D5C14419A45F234152D21DA9" />
<ComponentRef Id="cmpF96C036EAE3B436DB096888697193FAF" />
<ComponentRef Id="cmp789F545EA2CB4AC5A2688CF730A5F6B4" />
</ComponentGroup>
</Fragment>
</Wix>

View file

@ -6,6 +6,8 @@ param(
[parameter(Mandatory = $false)][switch]$SkipLinuxDistroCheck = $false
)
. "$PSScriptRoot\tools\buildCommon\startNativeExecution.ps1"
Set-StrictMode -Version 3.0
# On Unix paths is separated by colon
@ -16,6 +18,8 @@ $script:Options = $null
$dotnetMetadata = Get-Content $PSScriptRoot/DotnetRuntimeMetadata.json | ConvertFrom-Json
$dotnetCLIChannel = $dotnetMetadata.Sdk.Channel
$dotnetCLIQuality = $dotnetMetadata.Sdk.Quality
$dotnetAzureFeed = $dotnetMetadata.Sdk.azureFeed
$dotnetSDKVersionOveride = $dotnetMetadata.Sdk.sdkImageOverride
$dotnetCLIRequiredVersion = $(Get-Content $PSScriptRoot/global.json | ConvertFrom-Json).Sdk.Version
# Track if tags have been sync'ed
@ -314,14 +318,13 @@ function Start-PSBuild {
[ValidateSet('Debug', 'Release', 'CodeCoverage', '')] # We might need "Checked" as well
[string]$Configuration,
[switch]$CrossGen,
[ValidatePattern("^v\d+\.\d+\.\d+(-\w+(\.\d{1,2})?)?$")]
[ValidateNotNullOrEmpty()]
[string]$ReleaseTag,
[switch]$Detailed,
[switch]$InteractiveAuth,
[switch]$SkipRoslynAnalyzers
[switch]$SkipRoslynAnalyzers,
[string]$PSOptionsPath
)
if ($ReleaseTag -and $ReleaseTag -notmatch "^v\d+\.\d+\.\d+(-(preview|rc)(\.\d{1,2})?)?$") {
@ -342,10 +345,6 @@ function Start-PSBuild {
}
if ($ForMinimalSize) {
if ($CrossGen) {
throw "Build for the minimal size requires the minimal disk footprint, so `CrossGen` is not allowed"
}
if ($Runtime -and "linux-x64", "win7-x64", "osx-x64" -notcontains $Runtime) {
throw "Build for the minimal size is enabled only for following runtimes: 'linux-x64', 'win7-x64', 'osx-x64'"
}
@ -391,7 +390,8 @@ function Start-PSBuild {
}
# Verify if the dotnet in-use is the required version
$dotnetCLIInstalledVersion = Start-NativeExecution -sb { dotnet --version } -IgnoreExitcode
$dotnetCLIInstalledVersion = Get-LatestInstalledSDK
If ($dotnetCLIInstalledVersion -ne $dotnetCLIRequiredVersion) {
Write-Warning @"
The currently installed .NET Command Line Tools is not the required version.
@ -413,7 +413,6 @@ Fix steps:
# set output options
$OptionsArguments = @{
CrossGen=$CrossGen
Output=$Output
Runtime=$Runtime
Configuration=$Configuration
@ -440,6 +439,10 @@ Fix steps:
# Add --self-contained due to "warning NETSDK1179: One of '--self-contained' or '--no-self-contained' options are required when '--runtime' is used."
if ($Options.Runtime -like 'fxdependent*') {
$Arguments += "--no-self-contained"
# The UseAppHost = false property avoids creating ".exe" for the fxdependent packages.
# The ".exe" is not a cross-platform executable, but specific to the platform that it was built on.
# We do not need to ship that.
$Arguments += "/property:UseAppHost=false"
}
else {
$Arguments += "--self-contained"
@ -524,12 +527,6 @@ Fix steps:
Write-Log -message "Run dotnet $Arguments from $PWD"
Start-NativeExecution { dotnet $Arguments }
Write-Log -message "PowerShell output: $($Options.Output)"
if ($CrossGen) {
# fxdependent package cannot be CrossGen'ed
Start-CrossGen -PublishPath $publishPath -Runtime $script:Options.Runtime
Write-Log -message "pwsh.exe with ngen binaries is available at: $($Options.Output)"
}
} else {
$globalToolSrcFolder = Resolve-Path (Join-Path $Options.Top "../Microsoft.PowerShell.GlobalTool.Shim") | Select-Object -ExpandProperty Path
@ -668,6 +665,15 @@ Fix steps:
if ($CI) {
Restore-PSPester -Destination (Join-Path $publishPath "Modules")
}
if ($PSOptionsPath) {
$resolvedPSOptionsPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($PSOptionsPath)
$parent = Split-Path -Path $resolvedPSOptionsPath
if (!(Test-Path $parent)) {
$null = New-Item -ItemType Directory -Path $parent
}
Save-PSOptions -PSOptionsPath $PSOptionsPath -Options $Options
}
}
function Restore-PSPackage
@ -823,8 +829,6 @@ function New-PSOptions {
"win7-x86")]
[string]$Runtime,
[switch]$CrossGen,
# Accept a path to the output directory
# If not null or empty, name of the executable will be appended to
# this path, otherwise, to the default path, and then the full path
@ -930,7 +934,6 @@ function New-PSOptions {
-RootInfo ([PSCustomObject]$RootInfo) `
-Top $Top `
-Runtime $Runtime `
-Crossgen $Crossgen.IsPresent `
-Configuration $Configuration `
-PSModuleRestore $PSModuleRestore.IsPresent `
-Framework $Framework `
@ -1748,6 +1751,13 @@ function Install-Dotnet {
[string]$FeedCredential
)
Write-Verbose -Verbose "In install-dotnet"
# This is needed workaround for RTM pre-release build as the SDK version is always 6.0.100 after installation for every pre-release
if ($dotnetCLIRequiredVersion -like '6.0.100-rtm.*') {
$dotnetCLIRequiredVersion = '6.0.100'
}
# This allows sudo install to be optional; needed when running in containers / as root
# Note that when it is null, Invoke-Expression (but not &) must be used to interpolate properly
$sudo = if (!$NoSudo) { "sudo" }
@ -1775,10 +1785,12 @@ function Install-Dotnet {
Write-Warning "This script only removes prior versions of dotnet for Ubuntu and OS X"
}
Write-Verbose -Verbose "Invoking install script"
# Install new dotnet 1.1.0 preview packages
$installScript = "dotnet-install.sh"
Start-NativeExecution {
Write-Verbose -Message "downloading install script from $installObtainUrl/$installScript ..." -Verbose
Write-Verbose -Message "downloading install script from $installObtainUrl/$installScript ..." -Verbose
& $wget $installObtainUrl/$installScript
if ((Get-ChildItem "./$installScript").Length -eq 0) {
@ -1797,9 +1809,16 @@ function Install-Dotnet {
}
if ($AzureFeed) {
$bashArgs += @('-AzureFeed', $AzureFeed, '-FeedCredential', $FeedCredential)
$bashArgs += @('-AzureFeed', $AzureFeed)
}
if ($FeedCredential) {
$bashArgs += @('-FeedCredential', $FeedCredential)
}
$bashArgs | Out-String | Write-Verbose -Verbose
Start-NativeExecution {
bash @bashArgs
}
} elseif ($environment.IsWindows) {
@ -1822,35 +1841,44 @@ function Install-Dotnet {
}
if ($AzureFeed) {
$installArgs += @{
AzureFeed = $AzureFeed
$FeedCredential = $FeedCredential
}
$installArgs += @{AzureFeed = $AzureFeed}
}
if ($FeedCredential) {
$installArgs += @{FeedCredential = $FeedCredential}
}
$installArgs | Out-String | Write-Verbose -Verbose
& ./$installScript @installArgs
}
else {
# dotnet-install.ps1 uses APIs that are not supported in .NET Core, so we run it with Windows PowerShell
$fullPSPath = Join-Path -Path $env:windir -ChildPath "System32\WindowsPowerShell\v1.0\powershell.exe"
$fullDotnetInstallPath = Join-Path -Path $PWD.Path -ChildPath $installScript
if ($Version) {
$psArgs = @('-NoLogo', '-NoProfile', '-File', $fullDotnetInstallPath, '-Version', $Version, '-Quality', $Quality)
}
elseif ($Channel) {
$psArgs = @('-NoLogo', '-NoProfile', '-File', $fullDotnetInstallPath, '-Channel', $Channel, '-Quality', $Quality)
}
if ($InstallDir) {
$psArgs += @('-InstallDir', $InstallDir)
}
if ($AzureFeed) {
$psArgs += @('-AzureFeed', $AzureFeed)
}
if ($FeedCredential) {
$psArgs += @('-FeedCredential', $FeedCredential)
}
$psArgs | Out-String | Write-Verbose -Verbose
Start-NativeExecution {
if ($Version) {
$psArgs = @('-NoLogo', '-NoProfile', '-File', $fullDotnetInstallPath, '-Version', $Version, '-Quality', $Quality)
}
elseif ($Channel) {
$psArgs = @('-NoLogo', '-NoProfile', '-File', $fullDotnetInstallPath, '-Channel', $Channel, '-Quality', $Quality)
}
if ($InstallDir) {
$psArgs += @('-InstallDir', $InstallDir)
}
if ($AzureFeed) {
$psArgs += @('-AzureFeed', $AzureFeed, '-FeedCredential', $FeedCredential)
}
& $fullPSPath @psArgs
}
}
@ -1884,6 +1912,10 @@ function Start-PSBootstrap {
Push-Location $PSScriptRoot/tools
if ($dotnetSDKVersionOveride) {
$Version = $dotnetSDKVersionOveride
}
try {
if ($environment.IsLinux -or $environment.IsMacOS) {
# This allows sudo install to be optional; needed when running in containers / as root
@ -1981,6 +2013,9 @@ function Start-PSBootstrap {
# Build tools
$Deps += "cmake"
# wget for downloading dotnet
$Deps += "wget"
# .NET Core required runtime libraries
$Deps += "openssl"
@ -1988,7 +2023,7 @@ function Start-PSBootstrap {
# ignore exitcode, because they may be already installed
Start-NativeExecution ([ScriptBlock]::Create("$PackageManager install $Deps")) -IgnoreExitcode
} elseif ($environment.IsLinux -and $environment.IsAlpine) {
$Deps += 'libunwind', 'libcurl', 'bash', 'cmake', 'clang', 'build-base', 'git', 'curl'
$Deps += 'libunwind', 'libcurl', 'bash', 'cmake', 'clang', 'build-base', 'git', 'curl', 'wget'
Start-NativeExecution {
Invoke-Expression "apk add $Deps"
@ -2013,14 +2048,18 @@ function Start-PSBootstrap {
}
}
Write-Verbose -Verbose "Calling Find-Dotnet from Start-PSBootstrap"
# Try to locate dotnet-SDK before installing it
Find-Dotnet
Write-Verbose -Verbose "Back from calling Find-Dotnet from Start-PSBootstrap"
# Install dotnet-SDK
$dotNetExists = precheck 'dotnet' $null
$dotNetVersion = [string]::Empty
if($dotNetExists) {
$dotNetVersion = Start-NativeExecution -sb { dotnet --version } -IgnoreExitcode
$dotNetVersion = Get-LatestInstalledSDK
}
if(!$dotNetExists -or $dotNetVersion -ne $dotnetCLIRequiredVersion -or $Force.IsPresent) {
@ -2035,6 +2074,12 @@ function Start-PSBootstrap {
}
$DotnetArguments = @{ Channel=$Channel; Version=$Version; NoSudo=$NoSudo }
if ($dotnetAzureFeed) {
$null = $DotnetArguments.Add("AzureFeed", $dotnetAzureFeed)
$null = $DotnetArguments.Add("FeedCredential", $null)
}
Install-Dotnet @DotnetArguments
}
else {
@ -2056,6 +2101,12 @@ function Start-PSBootstrap {
}
}
function Get-LatestInstalledSDK {
Start-NativeExecution -sb {
dotnet --list-sdks | Select-String -Pattern '\d*.\d*.\d*(-\w*\.\d*)?' | ForEach-Object { [System.Management.Automation.SemanticVersion]::new($_.matches.value) } | Sort-Object -Descending | Select-Object -First 1
} -IgnoreExitcode 2> $null
}
function Start-DevPowerShell {
[CmdletBinding(DefaultParameterSetName='ConfigurationParamSet')]
param(
@ -2188,17 +2239,29 @@ function Start-ResGen
}
function Find-Dotnet() {
Write-Verbose -Verbose "In Find-DotNet"
$originalPath = $env:PATH
$dotnetPath = if ($environment.IsWindows) { "$env:LocalAppData\Microsoft\dotnet" } else { "$env:HOME/.dotnet" }
$chosenDotNetVersion = if($dotnetSDKVersionOveride) {
$dotnetSDKVersionOveride
}
else {
$dotnetCLIRequiredVersion
}
# If there dotnet is already in the PATH, check to see if that version of dotnet can find the required SDK
# This is "typically" the globally installed dotnet
if (precheck dotnet) {
# Must run from within repo to ensure global.json can specify the required SDK version
Push-Location $PSScriptRoot
$dotnetCLIInstalledVersion = Start-NativeExecution -sb { dotnet --version } -IgnoreExitcode 2> $null
$dotnetCLIInstalledVersion = Get-LatestInstalledSDK
Pop-Location
if ($dotnetCLIInstalledVersion -ne $dotnetCLIRequiredVersion) {
Write-Verbose -Verbose "dotnetCLIInstalledVersion = $dotnetCLIInstalledVersion`nchosenDotNetVersion = $chosenDotNetVersion"
if ($dotnetCLIInstalledVersion -ne $chosenDotNetVersion) {
Write-Warning "The 'dotnet' in the current path can't find SDK version ${dotnetCLIRequiredVersion}, prepending $dotnetPath to PATH."
# Globally installed dotnet doesn't have the required SDK version, prepend the user local dotnet location
$env:PATH = $dotnetPath + [IO.Path]::PathSeparator + $env:PATH
@ -2296,258 +2359,6 @@ function script:precheck([string]$command, [string]$missedMessage) {
}
}
# this function wraps native command Execution
# for more information, read https://mnaoumov.wordpress.com/2015/01/11/execution-of-external-commands-in-powershell-done-right/
function script:Start-NativeExecution
{
param(
[scriptblock]$sb,
[switch]$IgnoreExitcode,
[switch]$VerboseOutputOnError
)
$backupEAP = $ErrorActionPreference
$ErrorActionPreference = "Continue"
try {
if($VerboseOutputOnError.IsPresent)
{
$output = & $sb 2>&1
}
else
{
& $sb
}
# note, if $sb doesn't have a native invocation, $LASTEXITCODE will
# point to the obsolete value
if ($LASTEXITCODE -ne 0 -and -not $IgnoreExitcode) {
if($VerboseOutputOnError.IsPresent -and $output)
{
$output | Out-String | Write-Verbose -Verbose
}
# Get caller location for easier debugging
$caller = Get-PSCallStack -ErrorAction SilentlyContinue
if($caller)
{
$callerLocationParts = $caller[1].Location -split ":\s*line\s*"
$callerFile = $callerLocationParts[0]
$callerLine = $callerLocationParts[1]
$errorMessage = "Execution of {$sb} by ${callerFile}: line $callerLine failed with exit code $LASTEXITCODE"
throw $errorMessage
}
throw "Execution of {$sb} failed with exit code $LASTEXITCODE"
}
} finally {
$ErrorActionPreference = $backupEAP
}
}
function Start-CrossGen {
[CmdletBinding()]
param(
[Parameter(Mandatory= $true)]
[ValidateNotNullOrEmpty()]
[String]
$PublishPath,
[Parameter(Mandatory=$true)]
[ValidateSet("alpine-x64",
"linux-arm",
"linux-arm64",
"linux-x64",
"osx-arm64",
"osx-x64",
"win-arm",
"win-arm64",
"win7-x64",
"win7-x86")]
[string]
$Runtime
)
function New-CrossGenAssembly {
param (
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String[]]
$AssemblyPath,
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]
$CrossgenPath,
[Parameter(Mandatory = $true)]
[ValidateSet("alpine-x64",
"linux-arm",
"linux-arm64",
"linux-x64",
"osx-arm64",
"osx-x64",
"win-arm",
"win-arm64",
"win7-x64",
"win7-x86")]
[string]
$Runtime
)
$platformAssembliesPath = Split-Path $AssemblyPath[0] -Parent
$targetOS, $targetArch = $Runtime -split '-'
# Special cases where OS / Arch does not conform with runtime names
switch ($Runtime) {
'alpine-x64' {
$targetOS = 'linux'
$targetArch = 'x64'
}
'win-arm' {
$targetOS = 'windows'
$targetArch = 'arm'
}
'win-arm64' {
$targetOS = 'windows'
$targetArch = 'arm64'
}
'win7-x64' {
$targetOS = 'windows'
$targetArch = 'x64'
}
'win7-x86' {
$targetOS = 'windows'
$targetArch = 'x86'
}
}
$generatePdb = $targetos -eq 'windows'
# The path to folder must end with directory separator
$dirSep = [System.IO.Path]::DirectorySeparatorChar
$platformAssembliesPath = if (-not $platformAssembliesPath.EndsWith($dirSep)) { $platformAssembliesPath + $dirSep }
Start-NativeExecution {
$crossgen2Params = @(
"-r"
$platformAssembliesPath
"--out-near-input"
"--single-file-compilation"
"-O"
"--targetos"
$targetOS
"--targetarch"
$targetArch
)
if ($generatePdb) {
$crossgen2Params += "--pdb"
}
$crossgen2Params += $AssemblyPath
& $CrossgenPath $crossgen2Params
}
}
if (-not (Test-Path $PublishPath)) {
throw "Path '$PublishPath' does not exist."
}
# Get the path to crossgen
$crossGenExe = if ($environment.IsWindows) { "crossgen2.exe" } else { "crossgen2" }
# The crossgen tool is only published for these particular runtimes
$crossGenRuntime = if ($environment.IsWindows) {
# for windows the tool architecture is the host machine architecture, so it is always x64.
# we can cross compile for x86, arm and arm64
"win-x64"
} else {
$Runtime
}
if (-not $crossGenRuntime) {
throw "crossgen is not available for this platform"
}
$dotnetRuntimeVersion = $script:Options.Framework -replace 'net'
# Get the CrossGen.exe for the correct runtime with the latest version
$crossGenPath = Get-ChildItem $script:Environment.nugetPackagesRoot $crossGenExe -Recurse | `
Where-Object { $_.FullName -match $crossGenRuntime } | `
Where-Object { $_.FullName -match $dotnetRuntimeVersion } | `
Where-Object { (Split-Path $_.FullName -Parent).EndsWith('tools') } | `
Sort-Object -Property FullName -Descending | `
Select-Object -First 1 | `
ForEach-Object { $_.FullName }
if (-not $crossGenPath) {
throw "Unable to find latest version of crossgen2.exe. 'Please run Start-PSBuild -Clean' first, and then try again."
}
Write-Verbose "Matched CrossGen2.exe: $crossGenPath" -Verbose
# Common assemblies used by Add-Type or assemblies with high JIT and no pdbs to crossgen
$commonAssembliesForAddType = @(
"Microsoft.CodeAnalysis.CSharp.dll"
"Microsoft.CodeAnalysis.dll"
"System.Linq.Expressions.dll"
"Microsoft.CSharp.dll"
"System.Runtime.Extensions.dll"
"System.Linq.dll"
"System.Collections.Concurrent.dll"
"System.Collections.dll"
"Newtonsoft.Json.dll"
"System.IO.FileSystem.dll"
"System.Diagnostics.Process.dll"
"System.Threading.Tasks.Parallel.dll"
"System.Security.AccessControl.dll"
"System.Text.Encoding.CodePages.dll"
"System.Private.Uri.dll"
"System.Threading.dll"
"System.Security.Principal.Windows.dll"
"System.Console.dll"
"Microsoft.Win32.Registry.dll"
"System.IO.Pipes.dll"
"System.Diagnostics.FileVersionInfo.dll"
"System.Collections.Specialized.dll"
"Microsoft.ApplicationInsights.dll"
)
$fullAssemblyList = $commonAssembliesForAddType
$assemblyFullPaths = @()
$assemblyFullPaths += foreach ($assemblyName in $fullAssemblyList) {
Join-Path $PublishPath $assemblyName
}
New-CrossGenAssembly -CrossgenPath $crossGenPath -AssemblyPath $assemblyFullPaths -Runtime $Runtime
#
# With the latest dotnet.exe, the default load context is only able to load TPAs, and TPA
# only contains IL assembly names. In order to make the default load context able to load
# the NI PS assemblies, we need to replace the IL PS assemblies with the corresponding NI
# PS assemblies, but with the same IL assembly names.
#
Write-Verbose "PowerShell Ngen assemblies have been generated. Deploying ..." -Verbose
foreach ($assemblyName in $fullAssemblyList) {
# Remove the IL assembly and its symbols.
$assemblyPath = Join-Path $PublishPath $assemblyName
$symbolsPath = [System.IO.Path]::ChangeExtension($assemblyPath, ".pdb")
Remove-Item $assemblyPath -Force -ErrorAction Stop
# Rename the corresponding ni.dll assembly to be the same as the IL assembly
$niAssemblyPath = [System.IO.Path]::ChangeExtension($assemblyPath, "ni.dll")
Rename-Item $niAssemblyPath $assemblyPath -Force -ErrorAction Stop
# No symbols are available for Microsoft.CodeAnalysis.CSharp.dll, Microsoft.CodeAnalysis.dll,
# Microsoft.CodeAnalysis.VisualBasic.dll, and Microsoft.CSharp.dll.
if ($commonAssembliesForAddType -notcontains $assemblyName) {
Remove-Item $symbolsPath -Force -ErrorAction Stop
}
}
}
# Cleans the PowerShell repo - everything but the root folder
function Clear-PSRepo
{
@ -3070,7 +2881,6 @@ function Restore-PSOptions {
-RootInfo $options.RootInfo `
-Top $options.Top `
-Runtime $options.Runtime `
-Crossgen $options.Crossgen `
-Configuration $options.Configuration `
-PSModuleRestore $options.PSModuleRestore `
-Framework $options.Framework `
@ -3094,10 +2904,6 @@ function New-PSOptionsObject
[String]
$Runtime,
[Parameter(Mandatory)]
[Bool]
$CrossGen,
[Parameter(Mandatory)]
[String]
$Configuration,
@ -3126,7 +2932,6 @@ function New-PSOptionsObject
Framework = $Framework
Runtime = $Runtime
Output = $Output
CrossGen = $CrossGen
PSModuleRestore = $PSModuleRestore
ForMinimalSize = $ForMinimalSize
}

1424
cgmanifest.json Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,25 +0,0 @@
# Docker tests
## Windows and Linux containers
The tests must be run separately on the Windows and Linux docker daemons. You can use the Linux docker daemon on Windows, but that will only test Linux containers not Windows Containers.
## To building and basic behavior of the containers
```PowerShell
Invoke-Pester
```
Note: be sure to do this using both the Windows and Linux docker daemon.
## To test the productions containers
```PowerShell
Invoke-Pester -Tag Behavior
```
## To test only building the containers
```PowerShell
Invoke-Pester -Tag Build
```

View file

@ -1,23 +0,0 @@
FROM centos:7
ARG PACKAGENAME
ARG PACKAGELOCATION
ARG PREVIEWSUFFIX=
ARG TESTLIST=/PowerShell/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1,/PowerShell/test/powershell/engine/Module
ARG TESTDOWNLOADCOMMAND="git clone --recursive https://github.com/PowerShell/PowerShell.git"
# Install dependencies
RUN yum install -y \
curl \
glibc-locale-source \
git
# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG
RUN curl -L -o $PACKAGENAME $PACKAGELOCATION/$PACKAGENAME \
&& yum install -y $PACKAGENAME
RUN $TESTDOWNLOADCOMMAND
RUN pwsh$PREVIEWSUFFIX -c "Import-Module /PowerShell/build.psm1;\$dir='/usr/local/share/powershell/Modules';\$null=New-Item -Type Directory -Path \$dir -ErrorAction SilentlyContinue;Restore-PSPester -Destination \$dir;exit (Invoke-Pester $TESTLIST -PassThru).FailedCount"

View file

@ -1,29 +0,0 @@
FROM debian:stretch
ARG PACKAGENAME
ARG PACKAGELOCATION
ARG PREVIEWSUFFIX=
ARG TESTLIST=/PowerShell/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1,/PowerShell/test/powershell/engine/Module
ARG TESTDOWNLOADCOMMAND="git clone --recursive https://github.com/PowerShell/PowerShell.git"
# Install dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
ca-certificates \
curl \
apt-transport-https \
locales \
git \
&& apt-get clean
# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN locale-gen $LANG && update-locale
RUN curl -L -o $PACKAGENAME $PACKAGELOCATION/$PACKAGENAME
RUN dpkg -i $PACKAGENAME || :
RUN apt-get install -y -f --no-install-recommends
RUN $TESTDOWNLOADCOMMAND
RUN pwsh$PREVIEWSUFFIX -c "Import-Module /PowerShell/build.psm1;\$dir='/usr/local/share/powershell/Modules';\$null=New-Item -Type Directory -Path \$dir -ErrorAction SilentlyContinue;Restore-PSPester -Destination \$dir;exit (Invoke-Pester $TESTLIST -PassThru).FailedCount"

View file

@ -1,26 +0,0 @@
FROM fedora:28
ARG PACKAGENAME
ARG PACKAGELOCATION
ARG PREVIEWSUFFIX=
ARG TESTLIST=/PowerShell/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1,/PowerShell/test/powershell/engine/Module
ARG TESTDOWNLOADCOMMAND="git clone --recursive https://github.com/PowerShell/PowerShell.git"
# Install dependencies
RUN dnf install -y \
curl \
glibc-locale-source \
git \
compat-openssl10 \
&& dnf upgrade-minimal -y --security \
&& dnf clean all
# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG
RUN curl -L -o $PACKAGENAME $PACKAGELOCATION/$PACKAGENAME
RUN dnf install -y $PACKAGENAME
RUN $TESTDOWNLOADCOMMAND
RUN pwsh$PREVIEWSUFFIX -c "Import-Module /PowerShell/build.psm1;\$dir='/usr/local/share/powershell/Modules';\$null=New-Item -Type Directory -Path \$dir -ErrorAction SilentlyContinue;Restore-PSPester -Destination \$dir;exit (Invoke-Pester $TESTLIST -PassThru).FailedCount"

View file

@ -1,31 +0,0 @@
FROM centos:7
ARG PACKAGENAME
ARG PACKAGELOCATION
ARG PREVIEWSUFFIX=
ARG TESTLIST=/PowerShell/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1,/PowerShell/test/powershell/engine/Module
ARG TESTDOWNLOADCOMMAND="git clone --recursive https://github.com/PowerShell/PowerShell.git"
# Install dependencies
RUN yum install -y \
glibc-locale-source \
git
# Install dotnet-runtime
RUN rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm
RUN yum install -y \
dotnet-runtime-2.1
# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG
# Install PowerShell package
ADD $PACKAGELOCATION/$PACKAGENAME .
RUN mkdir -p /opt/microsoft/powershell
RUN tar zxf $PACKAGENAME -C /opt/microsoft/powershell
# Download and run tests
RUN $TESTDOWNLOADCOMMAND
RUN dotnet /opt/microsoft/powershell/pwsh.dll -c "Import-Module /PowerShell/build.psm1;\$dir='/usr/local/share/powershell/Modules';\$null=New-Item -Type Directory -Path \$dir -ErrorAction SilentlyContinue;Restore-PSPester -Destination \$dir;exit (Invoke-Pester $TESTLIST -PassThru).FailedCount"

View file

@ -1,31 +0,0 @@
FROM microsoft/dotnet:2.1.7-runtime-stretch-slim
ARG PACKAGENAME
ARG PACKAGELOCATION
ARG PREVIEWSUFFIX=
ARG TESTLIST=/PowerShell/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1,/PowerShell/test/powershell/engine/Module
ARG TESTDOWNLOADCOMMAND="git clone --recursive https://github.com/PowerShell/PowerShell.git"
# Install dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
ca-certificates \
apt-transport-https \
locales \
git \
&& apt-get clean
# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN locale-gen $LANG && update-locale
# Install PowerShell package
ADD $PACKAGELOCATION/$PACKAGENAME .
RUN mkdir -p /opt/microsoft/powershell
RUN tar zxf $PACKAGENAME -C /opt/microsoft/powershell
# Download and run tests
RUN $TESTDOWNLOADCOMMAND
RUN dotnet /opt/microsoft/powershell/pwsh.dll -c "Import-Module /PowerShell/build.psm1;\$dir='/usr/local/share/powershell/Modules';\$null=New-Item -Type Directory -Path \$dir -ErrorAction SilentlyContinue;Restore-PSPester -Destination \$dir;exit (Invoke-Pester $TESTLIST -PassThru).FailedCount"

View file

@ -1,31 +0,0 @@
FROM microsoft/dotnet:3.0.100-preview-sdk
ARG PACKAGENAME
ARG PACKAGELOCATION
ARG PREVIEWSUFFIX=
ARG TESTLIST=/PowerShell/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1,/PowerShell/test/powershell/engine/Module
ARG TESTDOWNLOADCOMMAND="git clone --recursive https://github.com/PowerShell/PowerShell.git"
# Install dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
ca-certificates \
apt-transport-https \
locales \
git \
&& apt-get clean
# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN locale-gen $LANG && update-locale
# Install PowerShell package
ADD $PACKAGELOCATION/$PACKAGENAME .
RUN mkdir -p /opt/microsoft/powershell \
&& tar zxf $PACKAGENAME -C /opt/microsoft/powershell
# Download and run tests
RUN $TESTDOWNLOADCOMMAND
RUN dotnet /opt/microsoft/powershell/pwsh.dll -c "Import-Module /PowerShell/build.psm1;\$dir='/usr/local/share/powershell/Modules';\$null=New-Item -Type Directory -Path \$dir -ErrorAction SilentlyContinue;Restore-PSPester -Destination \$dir;exit (Invoke-Pester $TESTLIST -PassThru).FailedCount"

View file

@ -1,38 +0,0 @@
FROM fedora:28
ARG PACKAGENAME
ARG PACKAGELOCATION
ARG PREVIEWSUFFIX=
ARG TESTLIST=/PowerShell/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1,/PowerShell/test/powershell/engine/Module
ARG TESTDOWNLOADCOMMAND="git clone --recursive https://github.com/PowerShell/PowerShell.git"
# Install dependencies
RUN dnf install -y \
glibc-locale-source \
git \
compat-openssl10 \
&& dnf upgrade-minimal -y --security \
&& dnf clean all
# Install dotnet-runtime
RUN rpm --import https://packages.microsoft.com/keys/microsoft.asc
ADD https://packages.microsoft.com/config/fedora/27/prod.repo .
RUN mv prod.repo /etc/yum.repos.d/microsoft-prod.repo
RUN dnf install -y \
dotnet-runtime-2.1 \
&& dnf upgrade-minimal -y --security \
&& dnf clean all
# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG
# Install PowerShell package
ADD $PACKAGELOCATION/$PACKAGENAME .
RUN mkdir -p /opt/microsoft/powershell \
&& tar zxf $PACKAGENAME -C /opt/microsoft/powershell
# Download and run tests
RUN $TESTDOWNLOADCOMMAND
RUN dotnet /opt/microsoft/powershell/pwsh.dll -c "Import-Module /PowerShell/build.psm1;\$dir='/usr/local/share/powershell/Modules';\$null=New-Item -Type Directory -Path \$dir -ErrorAction SilentlyContinue;Restore-PSPester -Destination \$dir;exit (Invoke-Pester $TESTLIST -PassThru).FailedCount"

View file

@ -1,41 +0,0 @@
FROM opensuse:42.3
ARG PACKAGENAME
ARG PACKAGELOCATION
ARG PREVIEWSUFFIX=
ARG TESTLIST=/PowerShell/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1,/PowerShell/test/powershell/engine/Module
ARG TESTDOWNLOADCOMMAND="git clone --recursive https://github.com/PowerShell/PowerShell.git"
# Install dependencies
RUN zypper --non-interactive update --skip-interactive \
&& zypper --non-interactive install \
glibc-locale \
glibc-i18ndata \
tar \
libunwind \
libicu \
openssl \
git
# Install dotnet-runtime
ADD https://packages.microsoft.com/keys/microsoft.asc .
RUN rpmkeys --import microsoft.asc
ADD https://packages.microsoft.com/config/opensuse/42.2/prod.repo .
RUN mv prod.repo /etc/zypp/repos.d/microsoft-prod.repo
RUN zypper --non-interactive update --skip-interactive \
&& zypper --non-interactive install \
dotnet-runtime-2.1
# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG
# Install PowerShell package
ADD $PACKAGELOCATION/$PACKAGENAME .
RUN mkdir -p /opt/microsoft/powershell
RUN tar zxf $PACKAGENAME -C /opt/microsoft/powershell
# Download and run tests
RUN $TESTDOWNLOADCOMMAND
RUN dotnet /opt/microsoft/powershell/pwsh.dll -c "Import-Module /PowerShell/build.psm1;\$dir='/usr/local/share/powershell/Modules';\$null=New-Item -Type Directory -Path \$dir -ErrorAction SilentlyContinue;Restore-PSPester -Destination \$dir;exit (Invoke-Pester $TESTLIST -PassThru).FailedCount"

View file

@ -1,39 +0,0 @@
FROM ubuntu:xenial
ARG PACKAGENAME
ARG PACKAGELOCATION
ARG PREVIEWSUFFIX=
ARG TESTLIST=/PowerShell/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1,/PowerShell/test/powershell/engine/Module
ARG TESTDOWNLOADCOMMAND="git clone --recursive https://github.com/PowerShell/PowerShell.git"
# Install dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
ca-certificates \
apt-transport-https \
locales \
git \
&& apt-get clean
# Install dotnet-runtime
ADD https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb .
RUN dpkg -i packages-microsoft-prod.deb
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
dotnet-runtime-2.1 \
&& apt-get clean
# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN locale-gen $LANG && update-locale
# Install PowerShell package
ADD $PACKAGELOCATION/$PACKAGENAME .
RUN mkdir -p /opt/microsoft/powershell \
&& tar zxf $PACKAGENAME -C /opt/microsoft/powershell
# Download and run tests
RUN $TESTDOWNLOADCOMMAND
RUN dotnet /opt/microsoft/powershell/pwsh.dll -c "Import-Module /PowerShell/build.psm1;\$dir='/usr/local/share/powershell/Modules';\$null=New-Item -Type Directory -Path \$dir -ErrorAction SilentlyContinue;Restore-PSPester -Destination \$dir;exit (Invoke-Pester $TESTLIST -PassThru).FailedCount"

View file

@ -1,31 +0,0 @@
FROM microsoft/dotnet:2.1.7-runtime-bionic
ARG PACKAGENAME
ARG PACKAGELOCATION
ARG PREVIEWSUFFIX=
ARG TESTLIST=/PowerShell/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1,/PowerShell/test/powershell/engine/Module
ARG TESTDOWNLOADCOMMAND="git clone --recursive https://github.com/PowerShell/PowerShell.git"
# Install dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
ca-certificates \
apt-transport-https \
locales \
git \
&& apt-get clean
# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN locale-gen $LANG && update-locale
# Install PowerShell package
ADD $PACKAGELOCATION/$PACKAGENAME .
RUN mkdir -p /opt/microsoft/powershell \
&& tar zxf $PACKAGENAME -C /opt/microsoft/powershell
# Download and run tests
RUN $TESTDOWNLOADCOMMAND
RUN dotnet /opt/microsoft/powershell/pwsh.dll -c "Import-Module /PowerShell/build.psm1;\$dir='/usr/local/share/powershell/Modules';\$null=New-Item -Type Directory -Path \$dir -ErrorAction SilentlyContinue;Restore-PSPester -Destination \$dir;exit (Invoke-Pester $TESTLIST -PassThru).FailedCount"

View file

@ -1,39 +0,0 @@
FROM opensuse:42.3
ARG PACKAGENAME
ARG PACKAGELOCATION
ARG PREVIEWSUFFIX=
ARG TESTLIST=/PowerShell/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1,/PowerShell/test/powershell/engine/Module
ARG TESTDOWNLOADCOMMAND="git clone --recursive https://github.com/PowerShell/PowerShell.git"
ARG POWERSHELL_LINKFILE=/usr/bin/pwsh
# Install dependencies
RUN zypper --non-interactive update --skip-interactive \
&& zypper --non-interactive install \
glibc-locale \
glibc-i18ndata \
tar \
curl \
libunwind \
libicu \
openssl \
git
# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG
RUN curl -L -o $PACKAGENAME $PACKAGELOCATION/$PACKAGENAME
# Create the target folder where powershell will be placed
RUN mkdir -p /opt/microsoft/powershell
# Expand powershell to the target folder
RUN tar zxf $PACKAGENAME -C /opt/microsoft/powershell
# Create the symbolic link that points to powershell
RUN ln -s /opt/microsoft/powershell/pwsh $POWERSHELL_LINKFILE
RUN $TESTDOWNLOADCOMMAND
RUN pwsh -c "Import-Module /PowerShell/build.psm1;\$dir='/usr/local/share/powershell/Modules';\$null=New-Item -Type Directory -Path \$dir -ErrorAction SilentlyContinue;Restore-PSPester -Destination \$dir;exit (Invoke-Pester $TESTLIST -PassThru).FailedCount"

View file

@ -1,29 +0,0 @@
FROM ubuntu:xenial
ARG PACKAGENAME
ARG PACKAGELOCATION
ARG PREVIEWSUFFIX=
ARG TESTLIST=/PowerShell/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1,/PowerShell/test/powershell/engine/Module
ARG TESTDOWNLOADCOMMAND="git clone --recursive https://github.com/PowerShell/PowerShell.git"
# Install dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
ca-certificates \
curl \
apt-transport-https \
locales \
git \
&& apt-get clean
# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN locale-gen $LANG && update-locale
RUN curl -L -o $PACKAGENAME $PACKAGELOCATION/$PACKAGENAME
RUN dpkg -i $PACKAGENAME || :
RUN apt-get install -y -f --no-install-recommends
RUN $TESTDOWNLOADCOMMAND
RUN pwsh$PREVIEWSUFFIX -c "Import-Module /PowerShell/build.psm1;\$dir='/usr/local/share/powershell/Modules';\$null=New-Item -Type Directory -Path \$dir -ErrorAction SilentlyContinue;Restore-PSPester -Destination \$dir;exit (Invoke-Pester $TESTLIST -PassThru).FailedCount"

View file

@ -1,29 +0,0 @@
FROM ubuntu:bionic
ARG PACKAGENAME
ARG PACKAGELOCATION
ARG PREVIEWSUFFIX=
ARG TESTLIST=/PowerShell/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1,/PowerShell/test/powershell/engine/Module
ARG TESTDOWNLOADCOMMAND="git clone --recursive https://github.com/PowerShell/PowerShell.git"
# Install dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
ca-certificates \
curl \
apt-transport-https \
locales \
git \
&& apt-get clean
# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN locale-gen $LANG && update-locale
RUN curl -L -o $PACKAGENAME $PACKAGELOCATION/$PACKAGENAME
RUN dpkg -i $PACKAGENAME || :
RUN apt-get install -y -f --no-install-recommends
RUN $TESTDOWNLOADCOMMAND
RUN pwsh$PREVIEWSUFFIX -c "Import-Module /PowerShell/build.psm1;\$dir='/usr/local/share/powershell/Modules';\$null=New-Item -Type Directory -Path \$dir -ErrorAction SilentlyContinue;Restore-PSPester -Destination \$dir;exit (Invoke-Pester $TESTLIST -PassThru).FailedCount"

View file

@ -1,370 +0,0 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
$script:forcePull = $true
# Get docker Engine OS
function Get-DockerEngineOs
{
docker info --format '{{ .OperatingSystem }}'
}
# Call Docker with appropriate result checksfunction Invoke-Docker
function Invoke-Docker
{
param(
[Parameter(Mandatory=$true)]
[string[]]
$Command,
[ValidateSet("error","warning",'ignore')]
$FailureAction = 'error',
[Parameter(Mandatory=$true)]
[string[]]
$Params,
[switch]
$PassThru,
[switch]
$SuppressHostOutput
)
$ErrorActionPreference = 'Continue'
# Log how we are running docker for troubleshooting issues
Write-Verbose "Running docker $command $params" -Verbose
if($SuppressHostOutput.IsPresent)
{
$result = docker $command $params 2>&1
}
else
{
&'docker' $command $params 2>&1 | Tee-Object -Variable result -ErrorAction SilentlyContinue | Out-String -Stream -ErrorAction SilentlyContinue | Write-Host -ErrorAction SilentlyContinue
}
$dockerExitCode = $LASTEXITCODE
if($PassThru.IsPresent)
{
Write-Verbose "passing through docker result$($result.length)..." -Verbose
return $result
}
elseif($dockerExitCode -ne 0 -and $FailureAction -eq 'error')
{
Write-Error "docker $command failed with: $result" -ErrorAction Stop
return $false
}
elseif($dockerExitCode -ne 0 -and $FailureAction -eq 'warning')
{
Write-Warning "docker $command failed with: $result"
return $false
}
elseif($dockerExitCode -ne 0)
{
return $false
}
return $true
}
# Return a list of Linux Container Test Cases
function Get-LinuxContainer
{
foreach($os in 'centos7','ubuntu16.04')
{
Write-Output @{
Name = $os
Path = "$PSScriptRoot/../release/$os"
}
}
}
# Return a list of Windows Container Test Cases
function Get-WindowsContainer
{
foreach($os in 'windowsservercore','nanoserver')
{
Write-Output @{
Name = $os
Path = "$PSScriptRoot/../release/$os"
}
}
}
$script:repoName = 'microsoft/powershell'
function Get-RepoName
{
return $script:repoName
}
function Set-RepoName
{
param([string]$RepoName)
$script:repoName = $RepoName
$script:forcePull = $false
}
function Test-SkipWindows
{
[bool] $canRunWindows = (Get-DockerEngineOs) -like 'Windows*'
return ($IsLinux -or $IsMacOS -or !$canRunWindows)
}
function Test-SkipLinux
{
$os = Get-DockerEngineOs
switch -wildcard ($os)
{
'*Linux*' {
return $false
}
'*Mac' {
return $false
}
# Docker for Windows means we are running the linux kernel
'Docker for Windows' {
return $false
}
'Windows*' {
return $true
}
default {
throw "Unknown docker os '$os'"
}
}
}
function Get-TestContext
{
param(
[ValidateSet('Linux','Windows','macOS')]
[string]$Type
)
$resultFileName = 'results.xml'
$logFileName = 'results.log'
$containerTestDrive = '/test'
# Return a windows context if the Context in Windows *AND*
# the current system is windows, otherwise Join-path will fail.
if($Type -eq 'Windows' -and $IsWindows)
{
$ContainerTestDrive = 'C:\test'
}
$resolvedTestDrive = (Resolve-Path "Testdrive:\").providerPath
return @{
ResolvedTestDrive = $resolvedTestDrive
ResolvedXmlPath = Join-Path $resolvedTestDrive -ChildPath $resultFileName
ResolvedLogPath = Join-Path $resolvedTestDrive -ChildPath $logFileName
ContainerTestDrive = $ContainerTestDrive
ContainerXmlPath = Join-Path $containerTestDrive -ChildPath $resultFileName
ContainerLogPath = Join-Path $containerTestDrive -ChildPath $logFileName
Type = $Type
ForcePull = $script:forcePull
}
}
function Get-ContainerPowerShellVersion
{
param(
[HashTable] $TestContext,
[string] $RepoName,
[string] $Name
)
$imageTag = "${script:repoName}:${Name}"
if($TestContext.ForcePull)
{
$null=Invoke-Docker -Command 'image', 'pull' -Params $imageTag -SuppressHostOutput
}
$runParams = @()
$localVolumeName = $testContext.resolvedTestDrive
$runParams += '--rm'
if($TestContext.Type -ne 'Windows' -and $IsWindows)
{
# use a container volume on windows because host volumes are not automatic
$volumeName = "test-volume-" + (Get-Random -Minimum 100 -Maximum 999)
# using alpine because it's tiny
$null=Invoke-Docker -Command create -Params '-v', '/test', '--name', $volumeName, 'alpine' -SuppressHostOutput
$runParams += '--volumes-from'
$runParams += $volumeName
}
else {
$runParams += '-v'
$runParams += "${localVolumeName}:$($testContext.containerTestDrive)"
}
$runParams += $imageTag
$runParams += 'pwsh'
$runParams += '-c'
$runParams += ('$PSVersionTable.PSVersion.ToString() | out-string | out-file -encoding ascii -FilePath '+$testContext.containerLogPath)
$null = Invoke-Docker -Command run -Params $runParams -SuppressHostOutput
if($TestContext.Type -ne 'Windows' -and $IsWindows)
{
$null = Invoke-Docker -Command cp -Params "${volumeName}:$($testContext.containerLogPath)", $TestContext.ResolvedLogPath
$null = Invoke-Docker -Command container, rm -Params $volumeName, '--force' -SuppressHostOutput
}
return (Get-Content -Encoding Ascii $testContext.resolvedLogPath)[0]
}
# Function defines a config mapping for testing Preview packages.
# The list of supported OS for each release can be found here:
# https://github.com/PowerShell/PowerShell-Docs/blob/staging/reference/docs-conceptual/PowerShell-Core-Support.md#supported-platforms
function Get-DefaultPreviewConfigForPackageValidation
{
# format: <DockerfileFolderName>=<PartOfPackageFilename>
@{ 'centos7'='rhel.7';
'debian.9'='debian.9';
'fedora28'='rhel.7';
'opensuse42.3'='linux-x64.tar.gz';
'ubuntu16.04'='ubuntu.16.04';
'ubuntu18.04'='ubuntu.18.04';
'fxdependent-centos7'='linux-x64-fxdependent.tar.gz';
'fxdependent-debian.9'='linux-x64-fxdependent.tar.gz';
'fxdependent-fedora28'='linux-x64-fxdependent.tar.gz';
'fxdependent-opensuse42.3'='linux-x64-fxdependent.tar.gz';
'fxdependent-ubuntu16.04'='linux-x64-fxdependent.tar.gz';
'fxdependent-ubuntu18.04'='linux-x64-fxdependent.tar.gz';
'fxdependent-dotnetsdk-latest'='linux-x64-fxd-dotnetsdk.tar.gz'
}
}
# Function defines a config mapping for testing Stable packages.
# The list of supported OS for each release can be found here:
# https://github.com/PowerShell/PowerShell-Docs/blob/staging/reference/docs-conceptual/PowerShell-Core-Support.md#supported-platforms
function Get-DefaultStableConfigForPackageValidation
{
# format: <DockerfileFolderName>=<PartOfPackageFilename>
@{ 'centos7'='rhel.7';
'debian.9'='debian.9';
'opensuse42.3'='linux-x64.tar.gz';
'ubuntu16.04'='ubuntu.16.04';
'fxdependent-centos7'='linux-x64-fxdependent.tar.gz';
'fxdependent-debian.9'='linux-x64-fxdependent.tar.gz';
'fxdependent-opensuse42.3'='linux-x64-fxdependent.tar.gz';
'fxdependent-ubuntu16.04'='linux-x64-fxdependent.tar.gz'
}
}
# Returns a list of files in a specified Azure container.
function Get-PackageNamesOnAzureBlob
{
param(
[string]
$ContainerUrl,
# $SAS (shared access signature) param should include beginning '?' and trailing '&'
[string]
$SAS
)
$response = Invoke-RestMethod -Method Get -Uri $($ContainerUrl + $SAS + 'restype=container&comp=list')
$xmlResponce = [xml]$response.Substring($response.IndexOf('<EnumerationResults')) # remove some bad chars in the beginning that break XML parsing
($xmlResponce.EnumerationResults.Blobs.Blob).Name
}
# This function is used for basic validation of PS packages during a release;
# During the process Docker files are filled out and executed with Docker build;
# During the build PS packages are downloaded onto Docker containers, installed and selected Pester tests from PowerShell Github repo are executed.
# This function must be run on a Docker host machine in 'Linux containers' mode, such as Windows 10 server with Hyper-V role installed.
function Test-PSPackage
{
param(
[string]
[Parameter(Mandatory=$true)]
$PSPackageLocation, # e.g. Azure container storage url
[string]
$SAS,# $SAS (shared access signature) param should include beginning '?' and trailing '&'
[Hashtable]
$Config, # hashtable that maps packages to dockerfiles; for example see Get-DefaultConfigForPackageValidation
[string]
$TestList = "/PowerShell/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1,/PowerShell/test/powershell/engine/Module",
[string]
$TestDownloadCommand = "git clone --recursive https://github.com/PowerShell/PowerShell.git",
[switch]
$Preview = $false
)
$PSPackageLocation = $PSPackageLocation.TrimEnd('/','\') # code below assumes there is no trailing separator in PSPackageLocation url
$RootFolder = Join-Path $PSScriptRoot 'Templates'
$packageList = Get-PackageNamesOnAzureBlob -ContainerUrl $PSPackageLocation -SAS $SAS
if (!$Config)
{
if ($Preview)
{
$Config = Get-DefaultPreviewConfigForPackageValidation
}
else
{
$Config = Get-DefaultStableConfigForPackageValidation
}
}
# pre-process $Config: verify build directories and packages exist
$map = @{}
foreach($kp in $Config.GetEnumerator())
{
$buildDir = Join-Path $RootFolder $kp.Key
$packageName = $packageList | Where-Object {$_ -like $('*'+$kp.Value+'*')}
if (-not (Test-Path $buildDir))
{
Write-Error "Directory does Not exist - $buildDir; Check `$Config parameter and '$RootFolder' folder"
}
elseif (-not ($packageName))
{
Write-Error "Can not find package that matches filter *$($kp.Value)*; Check `$Config parameter and '$PSPackageLocation'"
}
else
{
$map.Add($buildDir, $packageName)
}
}
Write-Verbose "Using configuration:" -Verbose
Write-Verbose ($map | Format-List | Out-String) -Verbose
$results = @{}
$returnValue = $true
# run builds sequentially, but don't block for errors so that configs after failed one can run
foreach($kp in $map.GetEnumerator())
{
$dockerDirPath = $kp.Key
$packageFileName = $kp.Value
$buildArgs = @()
$buildArgs += "--build-arg","PACKAGENAME=$packageFileName"
$buildArgs += "--build-arg","PACKAGELOCATION=$PSPackageLocation"
if ($Preview)
{
$buildArgs += "--build-arg","PREVIEWSUFFIX=-preview"
}
$buildArgs += "--build-arg","TESTLIST=$TestList"
$buildArgs += "--build-arg","TESTDOWNLOADCOMMAND=$TestDownloadCommand"
$buildArgs += "--no-cache"
$buildArgs += $dockerDirPath
$dockerResult = Invoke-Docker -Command 'build' -Params $buildArgs -FailureAction warning
$confName = Split-Path -Leaf $dockerDirPath
$results.Add($confName, $dockerResult)
if (-not $dockerResult) {$returnValue = $false}
}
# in the end print results for all configurations
Write-Verbose "Package validation results:" -Verbose
$results
return $returnValue
}

View file

@ -71,7 +71,7 @@ Start-PSBuild
Congratulations! If everything went right, PowerShell is now built.
The `Start-PSBuild` script will output the location of the executable:
`./src/powershell-unix/bin/Debug/net5.0/linux-x64/publish/pwsh`.
`./src/powershell-unix/bin/Debug/net6.0/linux-x64/publish/pwsh`.
You should now be running the PowerShell Core that you just built, if you run the above executable.
You can run our cross-platform Pester tests with `Start-PSPester`, and our xUnit tests with `Start-PSxUnit`.

View file

@ -36,4 +36,4 @@ We cannot do this for you in the build module due to #[847][].
Start a PowerShell session by running `pwsh`, and then use `Start-PSBuild` from the module.
After building, PowerShell will be at `./src/powershell-unix/bin/Debug/net5.0/osx-x64/publish/pwsh`.
After building, PowerShell will be at `./src/powershell-unix/bin/Debug/net6.0/osx-x64/publish/pwsh`.

View file

@ -59,11 +59,11 @@ Import-Module ./build.psm1
Start-PSBuild
```
Congratulations! If everything went right, PowerShell is now built and executable as `./src/powershell-win-core/bin/Debug/net5.0/win7-x64/publish/pwsh.exe`.
Congratulations! If everything went right, PowerShell is now built and executable as `./src/powershell-win-core/bin/Debug/net6.0/win7-x64/publish/pwsh.exe`.
This location is of the form `./[project]/bin/[configuration]/[framework]/[rid]/publish/[binary name]`,
and our project is `powershell`, configuration is `Debug` by default,
framework is `net5.0`, runtime identifier is `win7-x64` by default,
framework is `net6.0`, runtime identifier is `win7-x64` by default,
and binary name is `pwsh`.
The function `Get-PSOutput` will return the path to the executable;
thus you can execute the development copy via `& (Get-PSOutput)`.

View file

@ -27,7 +27,6 @@ The PowerShell Committee and its members (aka Committee Members) are the primary
* Bruce Payette ([BrucePay](https://github.com/BrucePay))
* Jim Truher ([JamesWTruher](https://github.com/JamesWTruher))
* Joey Aiello ([joeyaiello](https://github.com/joeyaiello))
* Paul Higinbotham ([paulhigin](https://github.com/paulhigin))
* Rob Holt ([rjmholt](https://github.com/rjmholt))
* Steve Lee ([SteveL-MSFT](https://github.com/SteveL-MSFT))

View file

@ -19,7 +19,6 @@ Today, DSC is integrated into the PowerShell language, and we need to manage it
* @TravisEz13
* @theJasonHelmick
* @joeyaiello
* @anmenaga
## Developer Experience

View file

@ -1,5 +1,5 @@
{
"sdk": {
"version": "6.0.100-rc.1.21458.32"
"version": "6.0.100"
}
}

View file

@ -2,12 +2,11 @@
<configuration>
<packageSources>
<clear />
<add key="dotnet" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v2" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="dotnet-internal" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/6.0.100-rc.1.21430.44-shipping/nuget/v2" />
</packageSources>
<disabledPackageSources>
<clear />
</disabledPackageSources>
</configuration>

View file

@ -47,7 +47,7 @@
<ItemGroup>
<!-- the following package(s) are from https://github.com/dotnet/corefx -->
<PackageReference Include="System.ServiceProcess.ServiceController" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="6.0.0" />
</ItemGroup>
</Project>

View file

@ -8,7 +8,7 @@
<ItemGroup>
<ProjectReference Include="..\System.Management.Automation\System.Management.Automation.csproj" />
<PackageReference Include="Microsoft.PowerShell.MarkdownRender" Version="7.2.0-preview.2" />
<PackageReference Include="Microsoft.PowerShell.MarkdownRender" Version="7.2.0" />
</ItemGroup>
<PropertyGroup>
@ -31,9 +31,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.0-4.final" />
<PackageReference Include="System.Threading.AccessControl" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.0-6.final" />
<PackageReference Include="System.Threading.AccessControl" Version="6.0.0" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
<PackageReference Include="NJsonSchema" Version="10.5.2" />
</ItemGroup>

View file

@ -11,6 +11,7 @@ using System.IO;
using System.Linq;
using System.Management.Automation;
using System.Management.Automation.Internal;
using System.Management.Automation.Security;
using System.Reflection;
using System.Runtime.Loader;
using System.Security;
@ -549,8 +550,10 @@ namespace Microsoft.PowerShell.Commands
/// </summary>
protected override void BeginProcessing()
{
// Prevent code compilation in ConstrainedLanguage mode
if (SessionState.LanguageMode == PSLanguageMode.ConstrainedLanguage)
// Prevent code compilation in ConstrainedLanguage mode, or NoLanguage mode under system lock down.
if (SessionState.LanguageMode == PSLanguageMode.ConstrainedLanguage ||
(SessionState.LanguageMode == PSLanguageMode.NoLanguage &&
SystemPolicy.GetSystemLockdownPolicy() == SystemEnforcementMode.Enforce))
{
ThrowTerminatingError(
new ErrorRecord(

View file

@ -2823,13 +2823,14 @@ function Get-PSImplicitRemotingClientSideParameters
$clientSideParameters = Get-PSImplicitRemotingClientSideParameters $PSBoundParameters ${8}
$scriptCmd = {{ & $script:InvokeCommand `
@clientSideParameters `
-HideComputerName `
-Session (Get-PSImplicitRemotingSession -CommandName '{0}') `
-Arg ('{0}', $PSBoundParameters, $positionalArguments) `
-Script {{ param($name, $boundParams, $unboundParams) & $name @boundParams @unboundParams }} `
}}
$scriptCmd = {{
& $script:InvokeCommand `
@clientSideParameters `
-HideComputerName `
-Session (Get-PSImplicitRemotingSession -CommandName '{0}') `
-Arg ('{0}', $PSBoundParameters, $positionalArguments) `
-Script {{ param($name, $boundParams, $unboundParams) & $name @boundParams @unboundParams }} `
}}
$steppablePipeline = $scriptCmd.GetSteppablePipeline($myInvocation.CommandOrigin)
$steppablePipeline.Begin($myInvocation.ExpectingInput, $ExecutionContext)

View file

@ -219,7 +219,7 @@ namespace Microsoft.PowerShell.Commands
if (s_inputFieldRegex == null)
{
s_inputFieldRegex = new Regex(@"<input\s+[^>]*(/>|>.*?</input>)",
s_inputFieldRegex = new Regex(@"<input\s+[^>]*(/?>|>.*?</input>)",
RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.Compiled);
}

View file

@ -0,0 +1,51 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#nullable enable
using System;
using System.Collections.Generic;
using System.Management.Automation;
using System.Net;
using System.Reflection;
namespace Microsoft.PowerShell.Commands
{
/// <summary>
/// A completer for HTTP version names.
/// </summary>
internal sealed class HttpVersionCompletionsAttribute : ArgumentCompletionsAttribute
{
public static readonly string[] AllowedVersions;
static HttpVersionCompletionsAttribute()
{
FieldInfo[] fields = typeof(HttpVersion).GetFields(BindingFlags.Static | BindingFlags.Public);
var versions = new List<string>(fields.Length - 1);
for (int i = 0; i < fields.Length; i++)
{
// skip field Unknown and not Version type
if (fields[i].Name == nameof(HttpVersion.Unknown) || fields[i].FieldType != typeof(Version))
{
continue;
}
var version = (Version?)fields[i].GetValue(null);
if (version is not null)
{
versions.Add(version.ToString());
}
}
AllowedVersions = versions.ToArray();
}
/// <inheritdoc/>
public HttpVersionCompletionsAttribute() : base(AllowedVersions)
{
}
}
}

View file

@ -107,6 +107,18 @@ namespace Microsoft.PowerShell.Commands
#endregion
#region HTTP Version
/// <summary>
/// Gets or sets the HTTP Version property.
/// </summary>
[Parameter]
[ArgumentToVersionTransformation]
[HttpVersionCompletions]
public virtual Version HttpVersion { get; set; }
#endregion
#region Session
/// <summary>
/// Gets or sets the Session property.
@ -1081,6 +1093,11 @@ namespace Microsoft.PowerShell.Commands
// create the base WebRequest object
var request = new HttpRequestMessage(httpMethod, requestUri);
if (HttpVersion is not null)
{
request.Version = HttpVersion;
}
// pull in session data
if (WebSession.Headers.Count > 0)
{
@ -1413,6 +1430,7 @@ namespace Microsoft.PowerShell.Commands
string reqVerboseMsg = string.Format(
CultureInfo.CurrentCulture,
WebCmdletStrings.WebMethodInvocationVerboseMsg,
requestWithoutRange.Version,
requestWithoutRange.Method,
requestWithoutRange.RequestUri,
requestContentLength);
@ -1505,10 +1523,14 @@ namespace Microsoft.PowerShell.Commands
if (request.Content != null)
requestContentLength = request.Content.Headers.ContentLength.Value;
string reqVerboseMsg = string.Format(CultureInfo.CurrentCulture,
string reqVerboseMsg = string.Format(
CultureInfo.CurrentCulture,
WebCmdletStrings.WebMethodInvocationVerboseMsg,
request.Version,
request.Method,
request.RequestUri,
requestContentLength);
WriteVerbose(reqVerboseMsg);
HttpResponseMessage response = GetResponse(client, request, keepAuthorization);
@ -1830,7 +1852,7 @@ namespace Microsoft.PowerShell.Commands
// we only support the URL in angle brackets and `rel`, other attributes are ignored
// user can still parse it themselves via the Headers property
const string pattern = "<(?<url>.*?)>;\\s*rel=(\"?)(?<rel>.*?)\\1[^\\w -.]?";
const string pattern = "<(?<url>.*?)>;\\s*rel=(?<quoted>\")?(?<rel>(?(quoted).*?|[^,;]*))(?(quoted)\")";
IEnumerable<string> links;
if (response.Headers.TryGetValues("Link", out links))
{

View file

@ -27,15 +27,13 @@ namespace Microsoft.PowerShell.Commands
private int _depth = 2;
private const int maxDepthAllowed = 100;
private readonly CancellationTokenSource _cancellationSource = new();
/// <summary>
/// Gets or sets the Depth property.
/// </summary>
[Parameter]
[ValidateRange(0, int.MaxValue)]
[ValidateRange(0, 100)]
public int Depth
{
get { return _depth; }
@ -99,23 +97,7 @@ namespace Microsoft.PowerShell.Commands
_cancellationSource.Dispose();
}
}
/// <summary>
/// Prerequisite checks.
/// </summary>
protected override void BeginProcessing()
{
if (_depth > maxDepthAllowed)
{
string errorMessage = StringUtil.Format(WebCmdletStrings.ReachedMaximumDepthAllowed, maxDepthAllowed);
ThrowTerminatingError(new ErrorRecord(
new InvalidOperationException(errorMessage),
"ReachedMaximumDepthAllowed",
ErrorCategory.InvalidOperation,
null));
}
}
private readonly List<object> _inputObjects = new();
/// <summary>

View file

@ -129,7 +129,7 @@
<data name="AuthenticationCredentialNotSupplied" xml:space="preserve">
<value>The cmdlet cannot run because the following parameter is not specified: Credential. The supplied Authentication type requires a Credential. Specify Credential, then retry.</value>
</data>
<data name="AuthenticationTokenNotSupplied" xml:space="preserve">
<data name="AuthenticationTokenNotSupplied" xml:space="preserve">
<value>The cmdlet cannot run because the following parameter is not specified: Token. The supplied Authentication type requires a Token. Specify Token, then retry.</value>
</data>
<data name="AuthenticationTokenConflict" xml:space="preserve">
@ -237,9 +237,6 @@
<data name="JsonNetModuleFilesRequired" xml:space="preserve">
<value>Ensure 'Json.Net.psd1' and 'Newtonsoft.Json.dll' are available in a versioned subdirectory of '{0}'.</value>
</data>
<data name="ReachedMaximumDepthAllowed" xml:space="preserve">
<value>The maximum depth allowed for serialization is {0}.</value>
</data>
<data name="JsonDeserializationFailed" xml:space="preserve">
<value>Conversion from JSON failed with error: {0}</value>
</data>
@ -250,7 +247,7 @@
<value>Following rel link {0}</value>
</data>
<data name="WebMethodInvocationVerboseMsg" xml:space="preserve">
<value>{0} with {1}-byte payload</value>
<value>HTTP/{0} {1} {2} with {3}-byte payload</value>
</data>
<data name="WebMethodResumeFailedVerboseMsg" xml:space="preserve">
<value>The remote server indicated it could not resume downloading. The local file will be overwritten.</value>

View file

@ -432,7 +432,7 @@ namespace Microsoft.PowerShell
host.ShouldEndSession = shouldEndSession;
}
// Creation of the tread and starting it should be an atomic operation.
// Creation of the thread and starting it should be an atomic operation.
// otherwise the code in Run method can get instance of the breakhandlerThread
// after it is created and before started and call join on it. This will result
// in ThreadStateException.

View file

@ -851,18 +851,6 @@ namespace Microsoft.PowerShell
}
// If we get all the way to here, then we've compressed all the nodes and we still don't fit.
#if DEBUG || ASSERTIONS_TRACE
Dbg.Assert(
nodesCompressed == CountNodes(),
"We should have compressed every node in the tree.");
Dbg.Assert(
AllNodesHaveGivenStyle(_topLevelNodes, newStyle),
"We should have compressed every node in the tree.");
#endif
return false;
}

View file

@ -8,7 +8,7 @@
<ItemGroup>
<!-- the following package(s) are from https://github.com/dotnet/corefx -->
<PackageReference Include="System.Diagnostics.EventLog" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="System.Diagnostics.EventLog" Version="6.0.0" />
</ItemGroup>
</Project>

View file

@ -6,6 +6,7 @@
<AssemblyName>Microsoft.PowerShell.GlobalTool.Shim</AssemblyName>
<OutputType>EXE</OutputType>
<RootNamespace>Microsoft.PowerShell.GlobalTool.Shim</RootNamespace>
<UseAppHost>False</UseAppHost>
</PropertyGroup>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" Condition="'$(SDKToUse)' == 'Microsoft.NET.Sdk' " />

View file

@ -16,21 +16,21 @@
<ItemGroup>
<!-- the following package(s) are from https://github.com/dotnet/fxdac -->
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
<!-- the following package(s) are from https://github.com/dotnet/corefx -->
<PackageReference Include="System.IO.Packaging" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="System.Net.Http.WinHttpHandler" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="System.Text.Encodings.Web" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="System.IO.Packaging" Version="6.0.0" />
<PackageReference Include="System.Net.Http.WinHttpHandler" Version="6.0.0" />
<PackageReference Include="System.Text.Encodings.Web" Version="6.0.0" />
<!-- the following package(s) are from https://github.com/dotnet/wcf -->
<PackageReference Include="System.ServiceModel.Duplex" Version="4.9.0-preview1.21220.1" />
<PackageReference Include="System.ServiceModel.Http" Version="4.9.0-preview1.21220.1" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="4.9.0-preview1.21220.1" />
<PackageReference Include="System.ServiceModel.Primitives" Version="4.9.0-preview1.21220.1" />
<PackageReference Include="System.ServiceModel.Security" Version="4.9.0-preview1.21220.1" />
<PackageReference Include="System.Private.ServiceModel" Version="4.9.0-preview1.21220.1" />
<PackageReference Include="System.ServiceModel.Duplex" Version="4.9.0" />
<PackageReference Include="System.ServiceModel.Http" Version="4.9.0" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="4.9.0" />
<PackageReference Include="System.ServiceModel.Primitives" Version="4.9.0" />
<PackageReference Include="System.ServiceModel.Security" Version="4.9.0" />
<PackageReference Include="System.Private.ServiceModel" Version="4.9.0" />
<!-- the source could not be found for the following package(s) -->
<PackageReference Include="Microsoft.NETCore.Windows.ApiSets" Version="1.0.1" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
</ItemGroup>
</Project>

View file

@ -10,7 +10,7 @@
<ProjectReference Include="..\System.Management.Automation\System.Management.Automation.csproj" />
<ProjectReference Include="..\Microsoft.WSMan.Runtime\Microsoft.WSMan.Runtime.csproj" />
<!-- the following package(s) are from https://github.com/dotnet/corefx -->
<PackageReference Include="System.ServiceProcess.ServiceController" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="6.0.0" />
</ItemGroup>
<PropertyGroup>

View file

@ -184,7 +184,7 @@ namespace System.Management.Automation
#endif
// format files
internal static readonly List<string> FormatFileNames = new()
internal static readonly string[] FormatFileNames = new string[]
{
"Certificate.format.ps1xml",
"Diagnostics.format.ps1xml",
@ -516,11 +516,6 @@ namespace System.Management.Automation
return Unix.IsHardLink(fileInfo);
}
internal static string NonWindowsInternalGetTarget(string path)
{
return Unix.NativeMethods.FollowSymLink(path);
}
internal static string NonWindowsGetUserFromPid(int path)
{
return Unix.NativeMethods.GetUserFromPid(path);
@ -1139,10 +1134,6 @@ namespace System.Management.Automation
internal static extern int CreateHardLink([MarshalAs(UnmanagedType.LPStr)] string filePath,
[MarshalAs(UnmanagedType.LPStr)] string target);
[DllImport(psLib, CharSet = CharSet.Ansi, SetLastError = true)]
[return: MarshalAs(UnmanagedType.LPStr)]
internal static extern string FollowSymLink([MarshalAs(UnmanagedType.LPStr)] string filePath);
[DllImport(psLib, CharSet = CharSet.Ansi, SetLastError = true)]
[return: MarshalAs(UnmanagedType.LPStr)]
internal static extern string GetUserFromPid(int pid);

View file

@ -2082,37 +2082,37 @@ namespace System.Management.Automation.Runspaces
.AddItemScriptBlock(@"""$($_.FileInfo.Executable)$($_.FileInfo.Executable.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "FileInfo.Executable")
.AddItemScriptBlock(@"""$([string]::Join(',',$_.FileInfo.Extension.Keys))""", label: "FileInfo.Extension")
.AddItemScriptBlock(@"""$($_.Foreground.Black)$($_.Foreground.Black.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.Black")
.AddItemScriptBlock(@"""$($_.Foreground.BrightBlack)$($_.Foreground.BrightBlack.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.BrightBlack")
.AddItemScriptBlock(@"""$($_.Foreground.White)$($_.Foreground.White.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.White")
.AddItemScriptBlock(@"""$($_.Foreground.DarkGray)$($_.Foreground.DarkGray.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.DarkGray")
.AddItemScriptBlock(@"""$($_.Foreground.LightGray)$($_.Foreground.LightGray.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.LightGray")
.AddItemScriptBlock(@"""$($_.Foreground.BrightWhite)$($_.Foreground.BrightWhite.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.BrightWhite")
.AddItemScriptBlock(@"""$($_.Foreground.Red)$($_.Foreground.Red.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.Red")
.AddItemScriptBlock(@"""$($_.Foreground.LightRed)$($_.Foreground.LightRed.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.LightRed")
.AddItemScriptBlock(@"""$($_.Foreground.BrightRed)$($_.Foreground.BrightRed.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.BrightRed")
.AddItemScriptBlock(@"""$($_.Foreground.Magenta)$($_.Foreground.Magenta.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.Magenta")
.AddItemScriptBlock(@"""$($_.Foreground.LightMagenta)$($_.Foreground.LightMagenta.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.LightMagenta")
.AddItemScriptBlock(@"""$($_.Foreground.BrightMagenta)$($_.Foreground.BrightMagenta.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.BrightMagenta")
.AddItemScriptBlock(@"""$($_.Foreground.Blue)$($_.Foreground.Blue.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.Blue")
.AddItemScriptBlock(@"""$($_.Foreground.LightBlue)$($_.Foreground.LightBlue.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.LightBlue")
.AddItemScriptBlock(@"""$($_.Foreground.BrightBlue)$($_.Foreground.BrightBlue.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.BrightBlue")
.AddItemScriptBlock(@"""$($_.Foreground.Cyan)$($_.Foreground.Cyan.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.Cyan")
.AddItemScriptBlock(@"""$($_.Foreground.LightCyan)$($_.Foreground.LightCyan.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.LightCyan")
.AddItemScriptBlock(@"""$($_.Foreground.BrightCyan)$($_.Foreground.BrightCyan.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.BrightCyan")
.AddItemScriptBlock(@"""$($_.Foreground.Green)$($_.Foreground.Green.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.Green")
.AddItemScriptBlock(@"""$($_.Foreground.LightGreen)$($_.Foreground.LightGreen.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.LightGreen")
.AddItemScriptBlock(@"""$($_.Foreground.BrightGreen)$($_.Foreground.BrightGreen.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.BrightGreen")
.AddItemScriptBlock(@"""$($_.Foreground.Yellow)$($_.Foreground.Yellow.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.Yellow")
.AddItemScriptBlock(@"""$($_.Foreground.LightYellow)$($_.Foreground.LightYellow.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.LightYellow")
.AddItemScriptBlock(@"""$($_.Foreground.BrightYellow)$($_.Foreground.BrightYellow.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Foreground.BrightYellow")
.AddItemScriptBlock(@"""$($_.Background.Black)$($_.Background.Black.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.Black")
.AddItemScriptBlock(@"""$($_.Background.BrightBlack)$($_.Background.BrightBlack.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.BrightBlack")
.AddItemScriptBlock(@"""$($_.Background.White)$($_.Background.White.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.White")
.AddItemScriptBlock(@"""$($_.Background.DarkGray)$($_.Background.DarkGray.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.DarkGray")
.AddItemScriptBlock(@"""$($_.Background.LightGray)$($_.Background.LightGray.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.LightGray")
.AddItemScriptBlock(@"""$($_.Background.BrightWhite)$($_.Background.BrightWhite.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.BrightWhite")
.AddItemScriptBlock(@"""$($_.Background.Red)$($_.Background.Red.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.Red")
.AddItemScriptBlock(@"""$($_.Background.LightRed)$($_.Background.LightRed.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.LightRed")
.AddItemScriptBlock(@"""$($_.Background.BrightRed)$($_.Background.BrightRed.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.BrightRed")
.AddItemScriptBlock(@"""$($_.Background.Magenta)$($_.Background.Magenta.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.Magenta")
.AddItemScriptBlock(@"""$($_.Background.LightMagenta)$($_.Background.LightMagenta.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.LightMagenta")
.AddItemScriptBlock(@"""$($_.Background.BrightMagenta)$($_.Background.BrightMagenta.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.BrightMagenta")
.AddItemScriptBlock(@"""$($_.Background.Blue)$($_.Background.Blue.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.Blue")
.AddItemScriptBlock(@"""$($_.Background.LightBlue)$($_.Background.LightBlue.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.LightBlue")
.AddItemScriptBlock(@"""$($_.Background.BrightBlue)$($_.Background.BrightBlue.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.BrightBlue")
.AddItemScriptBlock(@"""$($_.Background.Cyan)$($_.Background.Cyan.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.Cyan")
.AddItemScriptBlock(@"""$($_.Background.LightCyan)$($_.Background.LightCyan.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.LightCyan")
.AddItemScriptBlock(@"""$($_.Background.BrightCyan)$($_.Background.BrightCyan.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.BrightCyan")
.AddItemScriptBlock(@"""$($_.Background.Green)$($_.Background.Green.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.Green")
.AddItemScriptBlock(@"""$($_.Background.LightGreen)$($_.Background.LightGreen.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.LightGreen")
.AddItemScriptBlock(@"""$($_.Background.BrightGreen)$($_.Background.BrightGreen.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.BrightGreen")
.AddItemScriptBlock(@"""$($_.Background.Yellow)$($_.Background.Yellow.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.Yellow")
.AddItemScriptBlock(@"""$($_.Background.LightYellow)$($_.Background.LightYellow.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.LightYellow")
.AddItemScriptBlock(@"""$($_.Background.BrightYellow)$($_.Background.BrightYellow.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Background.BrightYellow")
.EndEntry()
.EndList());
}
@ -2185,46 +2185,46 @@ namespace System.Management.Automation.Runspaces
ListControl.Create()
.StartEntry()
.AddItemScriptBlock(@"""$($_.Black)$($_.Black.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Black")
.AddItemScriptBlock(@"""$($_.BrightBlack)$($_.BrightBlack.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "BrightBlack")
.AddItemScriptBlock(@"""$($_.White)$($_.White.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "White")
.AddItemScriptBlock(@"""$($_.DarkGray)$($_.DarkGray.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "DarkGray")
.AddItemScriptBlock(@"""$($_.LightGray)$($_.LightGray.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "LightGray")
.AddItemScriptBlock(@"""$($_.BrightWhite)$($_.BrightWhite.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "BrightWhite")
.AddItemScriptBlock(@"""$($_.Red)$($_.Red.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Red")
.AddItemScriptBlock(@"""$($_.LightRed)$($_.LightRed.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "LightRed")
.AddItemScriptBlock(@"""$($_.BrightRed)$($_.BrightRed.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "BrightRed")
.AddItemScriptBlock(@"""$($_.Magenta)$($_.Magenta.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Magenta")
.AddItemScriptBlock(@"""$($_.LightMagenta)$($_.LightMagenta.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "LightMagenta")
.AddItemScriptBlock(@"""$($_.BrightMagenta)$($_.BrightMagenta.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "BrightMagenta")
.AddItemScriptBlock(@"""$($_.Blue)$($_.Blue.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Blue")
.AddItemScriptBlock(@"""$($_.LightBlue)$($_.LightBlue.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "LightBlue")
.AddItemScriptBlock(@"""$($_.BrightBlue)$($_.BrightBlue.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "BrightBlue")
.AddItemScriptBlock(@"""$($_.Cyan)$($_.Cyan.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Cyan")
.AddItemScriptBlock(@"""$($_.LightCyan)$($_.LightCyan.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "LightCyan")
.AddItemScriptBlock(@"""$($_.BrightCyan)$($_.BrightCyan.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "BrightCyan")
.AddItemScriptBlock(@"""$($_.Green)$($_.Green.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Green")
.AddItemScriptBlock(@"""$($_.LightGreen)$($_.LightGreen.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "LightGreen")
.AddItemScriptBlock(@"""$($_.BrightGreen)$($_.BrightGreen.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "BrightGreen")
.AddItemScriptBlock(@"""$($_.Yellow)$($_.Yellow.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Yellow")
.AddItemScriptBlock(@"""$($_.LightYellow)$($_.LightYellow.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "LightYellow")
.AddItemScriptBlock(@"""$($_.BrightYellow)$($_.BrightYellow.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "BrightYellow")
.EndEntry()
.EndList());
}
private static IEnumerable<FormatViewDefinition> ViewsOf_System_Management_Automation_PSStyleBackgroundColor()
{
yield return new FormatViewDefinition("System.Management.Automation.PSStyle+ForegroundColor",
yield return new FormatViewDefinition("System.Management.Automation.PSStyle+BackgroundColor",
ListControl.Create()
.StartEntry()
.AddItemScriptBlock(@"""$($_.Black)$($_.Black.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Black")
.AddItemScriptBlock(@"""$($_.BrightBlack)$($_.BrightBlack.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "BrightBlack")
.AddItemScriptBlock(@"""$($_.White)$($_.White.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "White")
.AddItemScriptBlock(@"""$($_.DarkGray)$($_.DarkGray.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "DarkGray")
.AddItemScriptBlock(@"""$($_.LightGray)$($_.LightGray.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "LightGray")
.AddItemScriptBlock(@"""$($_.BrightWhite)$($_.BrightWhite.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "BrightWhite")
.AddItemScriptBlock(@"""$($_.Red)$($_.Red.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Red")
.AddItemScriptBlock(@"""$($_.LightRed)$($_.LightRed.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "LightRed")
.AddItemScriptBlock(@"""$($_.BrightRed)$($_.BrightRed.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "BrightRed")
.AddItemScriptBlock(@"""$($_.Magenta)$($_.Magenta.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Magenta")
.AddItemScriptBlock(@"""$($_.LightMagenta)$($_.LightMagenta.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "LightMagenta")
.AddItemScriptBlock(@"""$($_.BrightMagenta)$($_.BrightMagenta.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "BrightMagenta")
.AddItemScriptBlock(@"""$($_.Blue)$($_.Blue.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Blue")
.AddItemScriptBlock(@"""$($_.LightBlue)$($_.LightBlue.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "LightBlue")
.AddItemScriptBlock(@"""$($_.BrightBlue)$($_.BrightBlue.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "BrightBlue")
.AddItemScriptBlock(@"""$($_.Cyan)$($_.Cyan.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Cyan")
.AddItemScriptBlock(@"""$($_.LightCyan)$($_.LightCyan.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "LightCyan")
.AddItemScriptBlock(@"""$($_.BrightCyan)$($_.BrightCyan.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "BrightCyan")
.AddItemScriptBlock(@"""$($_.Green)$($_.Green.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Green")
.AddItemScriptBlock(@"""$($_.LightGreen)$($_.LightGreen.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "LightGreen")
.AddItemScriptBlock(@"""$($_.BrightGreen)$($_.BrightGreen.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "BrightGreen")
.AddItemScriptBlock(@"""$($_.Yellow)$($_.Yellow.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "Yellow")
.AddItemScriptBlock(@"""$($_.LightYellow)$($_.LightYellow.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "LightYellow")
.AddItemScriptBlock(@"""$($_.BrightYellow)$($_.BrightYellow.Replace(""""`e"""",'`e'))$($PSStyle.Reset)""", label: "BrightYellow")
.EndEntry()
.EndList());
}

View file

@ -35,7 +35,7 @@ namespace System.Management.Automation
/// <summary>Classic rendering of progress.</summary>
Classic = 1,
}
#region PSStyle
/// <summary>
/// Contains configuration for how PowerShell renders text.
@ -53,19 +53,9 @@ namespace System.Management.Automation
public string Black { get; } = "\x1b[30m";
/// <summary>
/// Gets the color blue.
/// Gets the color red.
/// </summary>
public string Blue { get; } = "\x1b[34m";
/// <summary>
/// Gets the color cyan.
/// </summary>
public string Cyan { get; } = "\x1b[36m";
/// <summary>
/// Gets the color dark gray.
/// </summary>
public string DarkGray { get; } = "\x1b[90m";
public string Red { get; } = "\x1b[31m";
/// <summary>
/// Gets the color green.
@ -73,39 +63,14 @@ namespace System.Management.Automation
public string Green { get; } = "\x1b[32m";
/// <summary>
/// Gets the color light blue.
/// Gets the color yellow.
/// </summary>
public string LightBlue { get; } = "\x1b[94m";
public string Yellow { get; } = "\x1b[33m";
/// <summary>
/// Gets the color light cyan.
/// Gets the color blue.
/// </summary>
public string LightCyan { get; } = "\x1b[96m";
/// <summary>
/// Gets the color light gray.
/// </summary>
public string LightGray { get; } = "\x1b[97m";
/// <summary>
/// Gets the color light green.
/// </summary>
public string LightGreen { get; } = "\x1b[92m";
/// <summary>
/// Gets the color light magenta.
/// </summary>
public string LightMagenta { get; } = "\x1b[95m";
/// <summary>
/// Gets the color light red.
/// </summary>
public string LightRed { get; } = "\x1b[91m";
/// <summary>
/// Gets the color light yellow.
/// </summary>
public string LightYellow { get; } = "\x1b[93m";
public string Blue { get; } = "\x1b[34m";
/// <summary>
/// Gets the color magenta.
@ -113,9 +78,9 @@ namespace System.Management.Automation
public string Magenta { get; } = "\x1b[35m";
/// <summary>
/// Gets the color read.
/// Gets the color cyan.
/// </summary>
public string Red { get; } = "\x1b[31m";
public string Cyan { get; } = "\x1b[36m";
/// <summary>
/// Gets the color white.
@ -123,9 +88,44 @@ namespace System.Management.Automation
public string White { get; } = "\x1b[37m";
/// <summary>
/// Gets the color yellow.
/// Gets the color bright black.
/// </summary>
public string Yellow { get; } = "\x1b[33m";
public string BrightBlack { get; } = "\x1b[90m";
/// <summary>
/// Gets the color bright red.
/// </summary>
public string BrightRed { get; } = "\x1b[91m";
/// <summary>
/// Gets the color bright green.
/// </summary>
public string BrightGreen { get; } = "\x1b[92m";
/// <summary>
/// Gets the color bright yellow.
/// </summary>
public string BrightYellow { get; } = "\x1b[93m";
/// <summary>
/// Gets the color bright blue.
/// </summary>
public string BrightBlue { get; } = "\x1b[94m";
/// <summary>
/// Gets the color bright magenta.
/// </summary>
public string BrightMagenta { get; } = "\x1b[95m";
/// <summary>
/// Gets the color bright cyan.
/// </summary>
public string BrightCyan { get; } = "\x1b[96m";
/// <summary>
/// Gets the color bright white.
/// </summary>
public string BrightWhite { get; } = "\x1b[97m";
/// <summary>
/// Set as RGB (Red, Green, Blue).
@ -168,19 +168,9 @@ namespace System.Management.Automation
public string Black { get; } = "\x1b[40m";
/// <summary>
/// Gets the color blue.
/// Gets the color red.
/// </summary>
public string Blue { get; } = "\x1b[44m";
/// <summary>
/// Gets the color cyan.
/// </summary>
public string Cyan { get; } = "\x1b[46m";
/// <summary>
/// Gets the color dark gray.
/// </summary>
public string DarkGray { get; } = "\x1b[100m";
public string Red { get; } = "\x1b[41m";
/// <summary>
/// Gets the color green.
@ -188,39 +178,14 @@ namespace System.Management.Automation
public string Green { get; } = "\x1b[42m";
/// <summary>
/// Gets the color light blue.
/// Gets the color yellow.
/// </summary>
public string LightBlue { get; } = "\x1b[104m";
public string Yellow { get; } = "\x1b[43m";
/// <summary>
/// Gets the color light cyan.
/// Gets the color blue.
/// </summary>
public string LightCyan { get; } = "\x1b[106m";
/// <summary>
/// Gets the color light gray.
/// </summary>
public string LightGray { get; } = "\x1b[107m";
/// <summary>
/// Gets the color light green.
/// </summary>
public string LightGreen { get; } = "\x1b[102m";
/// <summary>
/// Gets the color light magenta.
/// </summary>
public string LightMagenta { get; } = "\x1b[105m";
/// <summary>
/// Gets the color light red.
/// </summary>
public string LightRed { get; } = "\x1b[101m";
/// <summary>
/// Gets the color light yellow.
/// </summary>
public string LightYellow { get; } = "\x1b[103m";
public string Blue { get; } = "\x1b[44m";
/// <summary>
/// Gets the color magenta.
@ -228,9 +193,9 @@ namespace System.Management.Automation
public string Magenta { get; } = "\x1b[45m";
/// <summary>
/// Gets the color read.
/// Gets the color cyan.
/// </summary>
public string Red { get; } = "\x1b[41m";
public string Cyan { get; } = "\x1b[46m";
/// <summary>
/// Gets the color white.
@ -238,9 +203,44 @@ namespace System.Management.Automation
public string White { get; } = "\x1b[47m";
/// <summary>
/// Gets the color yellow.
/// Gets the color bright black.
/// </summary>
public string Yellow { get; } = "\x1b[43m";
public string BrightBlack { get; } = "\x1b[100m";
/// <summary>
/// Gets the color bright red.
/// </summary>
public string BrightRed { get; } = "\x1b[101m";
/// <summary>
/// Gets the color bright green.
/// </summary>
public string BrightGreen { get; } = "\x1b[102m";
/// <summary>
/// Gets the color bright yellow.
/// </summary>
public string BrightYellow { get; } = "\x1b[103m";
/// <summary>
/// Gets the color bright blue.
/// </summary>
public string BrightBlue { get; } = "\x1b[104m";
/// <summary>
/// Gets the color bright magenta.
/// </summary>
public string BrightMagenta { get; } = "\x1b[105m";
/// <summary>
/// Gets the color bright cyan.
/// </summary>
public string BrightCyan { get; } = "\x1b[106m";
/// <summary>
/// Gets the color bright white.
/// </summary>
public string BrightWhite { get; } = "\x1b[107m";
/// <summary>
/// The color set as RGB (Red, Green, Blue).
@ -365,7 +365,7 @@ namespace System.Management.Automation
get => _error;
set => _error = ValidateNoContent(value);
}
private string _error = "\x1b[31;1m";
/// <summary>
@ -397,7 +397,7 @@ namespace System.Management.Automation
{
get => _debug;
set => _debug = ValidateNoContent(value);
}
}
private string _debug = "\x1b[33;1m";
}
@ -467,6 +467,16 @@ namespace System.Management.Automation
_extensionDictionary.Add(ValidateExtension(extension), ValidateNoContent(decoration));
}
/// <summary>
/// Add new extension and decoration to dictionary without validation.
/// </summary>
/// <param name="extension">Extension to add.</param>
/// <param name="decoration">ANSI string value to add.</param>
internal void AddWithoutValidation(string extension, string decoration)
{
_extensionDictionary.Add(extension, decoration);
}
/// <summary>
/// Remove an extension from dictionary.
/// </summary>
@ -543,19 +553,19 @@ namespace System.Management.Automation
Extension = new FileExtensionDictionary();
// archives
Extension.Add(".zip", "\x1b[31;1m");
Extension.Add(".tgz", "\x1b[31;1m");
Extension.Add(".gz", "\x1b[31;1m");
Extension.Add(".tar", "\x1b[31;1m");
Extension.Add(".nupkg", "\x1b[31;1m");
Extension.Add(".cab", "\x1b[31;1m");
Extension.Add(".7z", "\x1b[31;1m");
Extension.AddWithoutValidation(".zip", "\x1b[31;1m");
Extension.AddWithoutValidation(".tgz", "\x1b[31;1m");
Extension.AddWithoutValidation(".gz", "\x1b[31;1m");
Extension.AddWithoutValidation(".tar", "\x1b[31;1m");
Extension.AddWithoutValidation(".nupkg", "\x1b[31;1m");
Extension.AddWithoutValidation(".cab", "\x1b[31;1m");
Extension.AddWithoutValidation(".7z", "\x1b[31;1m");
// powershell
Extension.Add(".ps1", "\x1b[33;1m");
Extension.Add(".psd1", "\x1b[33;1m");
Extension.Add(".psm1", "\x1b[33;1m");
Extension.Add(".ps1xml", "\x1b[33;1m");
Extension.AddWithoutValidation(".ps1", "\x1b[33;1m");
Extension.AddWithoutValidation(".psd1", "\x1b[33;1m");
Extension.AddWithoutValidation(".psm1", "\x1b[33;1m");
Extension.AddWithoutValidation(".ps1xml", "\x1b[33;1m");
}
}
@ -688,7 +698,7 @@ namespace System.Management.Automation
private static string ValidateNoContent(string text)
{
var decorartedString = new StringDecorated(text);
var decorartedString = new ValueStringDecorated(text);
if (decorartedString.ContentLength > 0)
{
throw new ArgumentException(string.Format(PSStyleStrings.TextContainsContent, decorartedString.ToString(OutputRendering.PlainText)));

View file

@ -14,21 +14,21 @@
<!-- the following package(s) are from https://github.com/JamesNK/Newtonsoft.Json -->
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<!-- the Application Insights package -->
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.18.0" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.19.0" />
<!-- the following package(s) are from https://github.com/dotnet/corefx -->
<PackageReference Include="Microsoft.Win32.Registry.AccessControl" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="System.DirectoryServices" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="6.0.0-preview.5.21301.5" />
<PackageReference Include="System.Management" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="System.Security.AccessControl" Version="6.0.0-preview.5.21301.5" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="System.Security.Permissions" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="Microsoft.Win32.Registry.AccessControl" Version="6.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />
<PackageReference Include="System.DirectoryServices" Version="6.0.0" />
<!--PackageReference Include="System.IO.FileSystem.AccessControl" Version="6.0.0-preview.5.21301.5" /-->
<PackageReference Include="System.Management" Version="6.0.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageReference Include="System.Security.AccessControl" Version="6.0.0" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="6.0.0" />
<PackageReference Include="System.Security.Permissions" Version="6.0.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0" />
<!-- the following package(s) are from the powershell org -->
<PackageReference Include="Microsoft.Management.Infrastructure" Version="2.0.0" />
<PackageReference Include="Microsoft.PowerShell.Native" Version="7.2.0-preview.2" />
<PackageReference Include="Microsoft.PowerShell.Native" Version="7.2.0" />
</ItemGroup>
<PropertyGroup>

View file

@ -0,0 +1,58 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#nullable enable
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace System.Management.Automation
{
/// <summary>
/// To make it easier to specify a version, we add some conversions that wouldn't happen otherwise:
/// * A simple integer, i.e. 2;
/// * A string without a dot, i.e. "2".
/// </summary>
internal class ArgumentToVersionTransformationAttribute : ArgumentTransformationAttribute
{
/// <inheritdoc/>
public override object Transform(EngineIntrinsics engineIntrinsics, object inputData)
{
object version = PSObject.Base(inputData);
if (version is string versionStr)
{
if (TryConvertFromString(versionStr, out var convertedVersion))
{
return convertedVersion;
}
if (versionStr.Contains('.'))
{
// If the string contains a '.', let the Version constructor handle the conversion.
return inputData;
}
}
if (version is double)
{
// The conversion to int below is wrong, but the usual conversions will turn
// the double into a string, so just return the original object.
return inputData;
}
if (LanguagePrimitives.TryConvertTo<int>(version, out var majorVersion))
{
return new Version(majorVersion, 0);
}
return inputData;
}
protected virtual bool TryConvertFromString(string versionString, [NotNullWhen(true)] out Version? version)
{
version = null;
return false;
}
}
}

View file

@ -233,6 +233,13 @@ namespace System.Management.Automation.Internal
{
}
/// <summary>
/// When overridden in the derived class, performs clean-up after the command execution.
/// </summary>
internal virtual void DoCleanResource()
{
}
#endregion Override
/// <summary>

View file

@ -1813,9 +1813,14 @@ namespace System.Management.Automation
}
}
}
result = GetResultForAttributeArgument(completionContext, ref replacementIndex, ref replacementLength);
if (result != null) return result;
if (completionContext.TokenAtCursor.TokenFlags == TokenFlags.MemberName)
{
result = GetResultForAttributeArgument(completionContext, ref replacementIndex, ref replacementLength);
if (result is not null)
{
return result;
}
}
if ((tokenAtCursor.TokenFlags & TokenFlags.CommandName) != 0)
{

View file

@ -529,7 +529,7 @@ namespace System.Management.Automation
processor = scriptCommand != null
? new CommandProcessor(scriptCommand, _context, useLocalScope: true, fromScriptFile: false,
sessionState: scriptCommand.ScriptBlock.SessionStateInternal ?? Context.EngineSessionState)
: new CommandProcessor((CmdletInfo)this, _context) { UseLocalScope = true };
: new CommandProcessor((CmdletInfo)this, _context);
ParameterBinderController.AddArgumentsToCommandProcessor(processor, Arguments);
CommandProcessorBase oldCurrentCommandProcessor = Context.CurrentCommandProcessor;

View file

@ -875,8 +875,11 @@ process
end
{{{5}}}
clean
{{{6}}}
<#
{6}
{7}
#>
",
GetDecl(),
@ -885,6 +888,7 @@ end
GetBeginBlock(),
GetProcessBlock(),
GetEndBlock(),
GetCleanBlock(),
CodeGeneration.EscapeBlockCommentContent(helpComment));
return result;
@ -1063,6 +1067,11 @@ end
internal string GetProcessBlock()
{
// The reason we wrap scripts in 'try { } catch { throw }' (here and elsewhere) is to turn
// an exception that could be thrown from .NET method invocation into a terminating error
// that can be propagated up.
// By default, an exception thrown from .NET method is not terminating, but when enclosed
// in try/catch, it will be turned into a terminating error.
return @"
try {
$steppablePipeline.Process($_)
@ -1113,6 +1122,16 @@ end
";
}
internal string GetCleanBlock()
{
// Here we don't need to enclose the script in a 'try/catch' like elsewhere, because
// 1. the 'Clean' block doesn't propagate up any exception (terminating error);
// 2. only one expression in the script, so nothing else needs to be stopped when invoking the method fails.
return @"
$steppablePipeline.Clean()
";
}
#endregion
#region Helper methods for restricting commands needed by implicit and interactive remoting

View file

@ -309,13 +309,11 @@ namespace System.Management.Automation
internal override void ProcessRecord()
{
// Invoke the Command method with the request object
if (!this.RanBeginAlready)
{
RanBeginAlready = true;
try
{
// NOTICE-2004/06/08-JonN 959638
using (commandRuntime.AllowThisCommandToWrite(true))
{
if (Context._debuggingMode > 0 && Command is not PSScriptCmdlet)
@ -326,12 +324,9 @@ namespace System.Management.Automation
Command.DoBeginProcessing();
}
}
// 2004/03/18-JonN This is understood to be
// an FXCOP violation, cleared by KCwalina.
catch (Exception e) // Catch-all OK, 3rd party callout.
catch (Exception e)
{
// This cmdlet threw an exception, so
// wrap it and bubble it up.
// This cmdlet threw an exception, so wrap it and bubble it up.
throw ManageInvocationException(e);
}
}
@ -366,6 +361,7 @@ namespace System.Management.Automation
// NOTICE-2004/06/08-JonN 959638
using (commandRuntime.AllowThisCommandToWrite(true))
using (ParameterBinderBase.bindingTracer.TraceScope("CALLING ProcessRecord"))
{
if (CmdletParameterBinderController.ObsoleteParameterWarningList != null &&
CmdletParameterBinderController.ObsoleteParameterWarningList.Count > 0)
@ -400,14 +396,13 @@ namespace System.Management.Automation
}
catch (LoopFlowException)
{
// Win8:84066 - Don't wrap LoopFlowException, we incorrectly raise a PipelineStoppedException
// Don't wrap LoopFlowException, we incorrectly raise a PipelineStoppedException
// which gets caught by a script try/catch if we wrap here.
throw;
}
// 2004/03/18-JonN This is understood to be
// an FXCOP violation, cleared by KCwalina.
catch (Exception e) // Catch-all OK, 3rd party callout.
catch (Exception e)
{
// Catch-all OK, 3rd party callout.
exceptionToThrow = e;
}
finally

View file

@ -5,8 +5,7 @@ using System.Collections;
using System.Collections.ObjectModel;
using System.Management.Automation.Internal;
using System.Management.Automation.Language;
using Dbg = System.Management.Automation.Diagnostics;
using System.Runtime.InteropServices;
namespace System.Management.Automation
{
@ -46,6 +45,7 @@ namespace System.Management.Automation
string errorTemplate = expAttribute.ExperimentAction == ExperimentAction.Hide
? DiscoveryExceptions.ScriptDisabledWhenFeatureOn
: DiscoveryExceptions.ScriptDisabledWhenFeatureOff;
string errorMsg = StringUtil.Format(errorTemplate, expAttribute.ExperimentName);
ErrorRecord errorRecord = new ErrorRecord(
new InvalidOperationException(errorMsg),
@ -54,6 +54,8 @@ namespace System.Management.Automation
commandInfo);
throw new CmdletInvocationException(errorRecord);
}
HasCleanBlock = scriptCommand.ScriptBlock.HasCleanBlock;
}
CommandInfo = commandInfo;
@ -87,6 +89,11 @@ namespace System.Management.Automation
/// <value></value>
internal CommandInfo CommandInfo { get; set; }
/// <summary>
/// Gets whether the command has a 'Clean' block defined.
/// </summary>
internal bool HasCleanBlock { get; }
/// <summary>
/// This indicates whether this command processor is created from
/// a script file.
@ -371,13 +378,10 @@ namespace System.Management.Automation
Context.EngineSessionState = _previousCommandSessionState;
if (_previousScope != null)
{
// Restore the scope but use the same session state instance we
// got it from because the command may have changed the execution context
// session state...
CommandSessionState.CurrentScope = _previousScope;
}
// Restore the scope but use the same session state instance we
// got it from because the command may have changed the execution context
// session state...
CommandSessionState.CurrentScope = _previousScope;
}
private SessionStateScope _previousScope;
@ -452,16 +456,14 @@ namespace System.Management.Automation
HandleObsoleteCommand(ObsoleteAttribute);
}
}
catch (Exception)
catch (InvalidComObjectException e)
{
if (_useLocalScope)
{
// If we had an exception during Prepare, we're done trying to execute the command
// so the scope we created needs to release any resources it hold.s
CommandSessionState.RemoveScope(CommandScope);
}
// This type of exception could be thrown from parameter binding.
string msg = StringUtil.Format(ParserStrings.InvalidComObjectException, e.Message);
var newEx = new RuntimeException(msg, e);
throw;
newEx.SetErrorId("InvalidComObjectException");
throw newEx;
}
finally
{
@ -508,26 +510,23 @@ namespace System.Management.Automation
// The RedirectShellErrorOutputPipe flag is used by the V2 hosting API to force the
// redirection.
//
if (this.RedirectShellErrorOutputPipe || _context.ShellFunctionErrorOutputPipe != null)
if (RedirectShellErrorOutputPipe || _context.ShellFunctionErrorOutputPipe is not null)
{
_context.ShellFunctionErrorOutputPipe = this.commandRuntime.ErrorOutputPipe;
_context.ShellFunctionErrorOutputPipe = commandRuntime.ErrorOutputPipe;
}
_context.CurrentCommandProcessor = this;
SetCurrentScopeToExecutionScope();
using (commandRuntime.AllowThisCommandToWrite(true))
using (ParameterBinderBase.bindingTracer.TraceScope("CALLING BeginProcessing"))
{
using (ParameterBinderBase.bindingTracer.TraceScope(
"CALLING BeginProcessing"))
if (Context._debuggingMode > 0 && Command is not PSScriptCmdlet)
{
SetCurrentScopeToExecutionScope();
if (Context._debuggingMode > 0 && Command is not PSScriptCmdlet)
{
Context.Debugger.CheckCommand(this.Command.MyInvocation);
}
Command.DoBeginProcessing();
Context.Debugger.CheckCommand(Command.MyInvocation);
}
Command.DoBeginProcessing();
}
}
catch (Exception e)
@ -589,20 +588,14 @@ namespace System.Management.Automation
try
{
using (commandRuntime.AllowThisCommandToWrite(true))
using (ParameterBinderBase.bindingTracer.TraceScope("CALLING EndProcessing"))
{
using (ParameterBinderBase.bindingTracer.TraceScope(
"CALLING EndProcessing"))
{
this.Command.DoEndProcessing();
}
this.Command.DoEndProcessing();
}
}
// 2004/03/18-JonN This is understood to be
// an FXCOP violation, cleared by KCwalina.
catch (Exception e)
{
// This cmdlet threw an exception, so
// wrap it and bubble it up.
// This cmdlet threw an exception, wrap it as needed and bubble it up.
throw ManageInvocationException(e);
}
}
@ -631,44 +624,119 @@ namespace System.Management.Automation
// The RedirectShellErrorOutputPipe flag is used by the V2 hosting API to force the
// redirection.
//
if (this.RedirectShellErrorOutputPipe || _context.ShellFunctionErrorOutputPipe != null)
if (RedirectShellErrorOutputPipe || _context.ShellFunctionErrorOutputPipe is not null)
{
_context.ShellFunctionErrorOutputPipe = this.commandRuntime.ErrorOutputPipe;
_context.ShellFunctionErrorOutputPipe = commandRuntime.ErrorOutputPipe;
}
_context.CurrentCommandProcessor = this;
SetCurrentScopeToExecutionScope();
Complete();
}
finally
{
OnRestorePreviousScope();
_context.ShellFunctionErrorOutputPipe = oldErrorOutputPipe;
_context.CurrentCommandProcessor = oldCurrentCommandProcessor;
// Destroy the local scope at this point if there is one...
if (_useLocalScope && CommandScope != null)
{
CommandSessionState.RemoveScope(CommandScope);
}
RestorePreviousScope();
}
}
// and the previous scope...
if (_previousScope != null)
protected virtual void CleanResource()
{
try
{
using (commandRuntime.AllowThisCommandToWrite(permittedToWriteToPipeline: true))
using (ParameterBinderBase.bindingTracer.TraceScope("CALLING CleanResource"))
{
// Restore the scope but use the same session state instance we
// got it from because the command may have changed the execution context
// session state...
CommandSessionState.CurrentScope = _previousScope;
}
// Restore the previous session state
if (_previousCommandSessionState != null)
{
Context.EngineSessionState = _previousCommandSessionState;
Command.DoCleanResource();
}
}
catch (HaltCommandException)
{
throw;
}
catch (FlowControlException)
{
throw;
}
catch (Exception e)
{
// This cmdlet threw an exception, so wrap it and bubble it up.
throw ManageInvocationException(e);
}
}
internal void DoCleanup()
{
// The property 'PropagateExceptionsToEnclosingStatementBlock' controls whether a general exception
// (an exception thrown from a .NET method invocation, or an expression like '1/0') will be turned
// into a terminating error, which will be propagated up and thus stop the rest of the running script.
// It is usually used by TryStatement and TrapStatement, which makes the general exception catch-able.
//
// For the 'Clean' block, we don't want to bubble up the general exception when the command is enclosed
// in a TryStatement or has TrapStatement accompanying, because no exception can escape from 'Clean' and
// thus it's pointless to bubble up the general exception in this case.
//
// Therefore we set this property to 'false' here to mask off the previous setting that could be from a
// TryStatement or TrapStatement. Example:
// PS:1> function b { end {} clean { 1/0; Write-Host 'clean' } }
// PS:2> b
// RuntimeException: Attempted to divide by zero.
// clean
// ## Note that, outer 'try/trap' doesn't affect the general exception happens in 'Clean' block.
// ## so its behavior is consistent regardless of whether the command is enclosed by 'try/catch' or not.
// PS:3> try { b } catch { 'outer catch' }
// RuntimeException: Attempted to divide by zero.
// clean
//
// Be noted that, this doesn't affect the TryStatement/TrapStatement within the 'Clean' block. Example:
// ## 'try/trap' within 'Clean' block makes the general exception catch-able.
// PS:3> function a { end {} clean { try { 1/0; Write-Host 'clean' } catch { Write-Host "caught: $_" } } }
// PS:4> a
// caught: Attempted to divide by zero.
bool oldExceptionPropagationState = _context.PropagateExceptionsToEnclosingStatementBlock;
_context.PropagateExceptionsToEnclosingStatementBlock = false;
Pipe oldErrorOutputPipe = _context.ShellFunctionErrorOutputPipe;
CommandProcessorBase oldCurrentCommandProcessor = _context.CurrentCommandProcessor;
try
{
if (RedirectShellErrorOutputPipe || _context.ShellFunctionErrorOutputPipe is not null)
{
_context.ShellFunctionErrorOutputPipe = commandRuntime.ErrorOutputPipe;
}
_context.CurrentCommandProcessor = this;
SetCurrentScopeToExecutionScope();
CleanResource();
}
finally
{
_context.PropagateExceptionsToEnclosingStatementBlock = oldExceptionPropagationState;
_context.ShellFunctionErrorOutputPipe = oldErrorOutputPipe;
_context.CurrentCommandProcessor = oldCurrentCommandProcessor;
RestorePreviousScope();
}
}
internal void ReportCleanupError(Exception exception)
{
var error = exception is IContainsErrorRecord icer
? icer.ErrorRecord
: new ErrorRecord(exception, "Clean.ReportException", ErrorCategory.NotSpecified, targetObject: null);
PSObject errorWrap = PSObject.AsPSObject(error);
errorWrap.WriteStream = WriteStreamType.Error;
var errorPipe = commandRuntime.ErrorMergeTo == MshCommandRuntime.MergeDataStream.Output
? commandRuntime.OutputPipe
: commandRuntime.ErrorOutputPipe;
errorPipe.Add(errorWrap);
_context.QuestionMarkVariableValue = false;
}
/// <summary>
@ -777,23 +845,16 @@ namespace System.Management.Automation
{
do // false loop
{
ProviderInvocationException pie = e as ProviderInvocationException;
if (pie != null)
if (e is ProviderInvocationException pie)
{
// If a ProviderInvocationException occurred,
// discard the ProviderInvocationException and
// re-wrap in CmdletProviderInvocationException
e = new CmdletProviderInvocationException(
pie,
Command.MyInvocation);
// If a ProviderInvocationException occurred, discard the ProviderInvocationException
// and re-wrap it in CmdletProviderInvocationException.
e = new CmdletProviderInvocationException(pie, Command.MyInvocation);
break;
}
// 1021203-2005/05/09-JonN
// HaltCommandException will cause the command
// to stop, but not be reported as an error.
// 906445-2005/05/16-JonN
// FlowControlException should not be wrapped
// HaltCommandException will cause the command to stop, but not be reported as an error.
// FlowControlException should not be wrapped.
if (e is PipelineStoppedException
|| e is CmdletInvocationException
|| e is ActionPreferenceStopException
@ -813,9 +874,7 @@ namespace System.Management.Automation
}
// wrap all other exceptions
e = new CmdletInvocationException(
e,
Command.MyInvocation);
e = new CmdletInvocationException(e, Command.MyInvocation);
} while (false);
// commandRuntime.ManageException will always throw PipelineStoppedException
@ -943,15 +1002,27 @@ namespace System.Management.Automation
private void Dispose(bool disposing)
{
if (_disposed)
{
return;
}
if (disposing)
{
// 2004/03/05-JonN Look into using metadata to check
// whether IDisposable is implemented, in order to avoid
// this expensive reflection cast.
IDisposable id = Command as IDisposable;
if (id != null)
if (UseLocalScope)
{
// Clean up the PS drives that are associated with this local scope.
// This operation may be needed at multiple stages depending on whether the 'clean' block is declared:
// 1. when there is a 'clean' block, it needs to be done only after 'clean' block runs, because the scope
// needs to be preserved until the 'clean' block finish execution.
// 2. when there is no 'clean' block, it needs to be done when
// (1) there is any exception thrown from 'DoPrepare()', 'DoBegin()', 'DoExecute()', or 'DoComplete';
// (2) OR, the command runs to the end successfully;
// Doing this cleanup at those multiple stages is cumbersome. Since we will always dispose the command in
// the end, doing this cleanup here will cover all the above cases.
CommandSessionState.RemoveScope(CommandScope);
}
if (Command is IDisposable id)
{
id.Dispose();
}

View file

@ -525,9 +525,7 @@ namespace System.Management.Automation
/// </summary>
internal object GetVariableValue(VariablePath path, object defaultValue)
{
CmdletProviderContext context;
SessionStateScope scope;
return EngineSessionState.GetVariableValue(path, out context, out scope) ?? defaultValue;
return EngineSessionState.GetVariableValue(path, out _, out _) ?? defaultValue;
}
/// <summary>
@ -612,19 +610,15 @@ namespace System.Management.Automation
/// <returns></returns>
internal bool GetBooleanPreference(VariablePath preferenceVariablePath, bool defaultPref, out bool defaultUsed)
{
CmdletProviderContext context = null;
SessionStateScope scope = null;
object val = EngineSessionState.GetVariableValue(preferenceVariablePath, out context, out scope);
if (val == null)
object val = EngineSessionState.GetVariableValue(preferenceVariablePath, out _, out _);
if (val is null)
{
defaultUsed = true;
return defaultPref;
}
bool converted = defaultPref;
defaultUsed = !LanguagePrimitives.TryConvertTo<bool>
(val, out converted);
return (defaultUsed) ? defaultPref : converted;
defaultUsed = !LanguagePrimitives.TryConvertTo(val, out bool converted);
return defaultUsed ? defaultPref : converted;
}
#endregion GetSetVariable methods
@ -789,11 +783,6 @@ namespace System.Management.Automation
return oldPipe;
}
internal void RestoreErrorPipe(Pipe pipe)
{
ShellFunctionErrorOutputPipe = pipe;
}
/// <summary>
/// Reset all of the redirection book keeping variables. This routine should be called when starting to
/// execute a script.
@ -846,15 +835,13 @@ namespace System.Management.Automation
internal void AppendDollarError(object obj)
{
ErrorRecord objAsErrorRecord = obj as ErrorRecord;
if (objAsErrorRecord == null && obj is not Exception)
if (objAsErrorRecord is null && obj is not Exception)
{
Diagnostics.Assert(false, "Object to append was neither an ErrorRecord nor an Exception in ExecutionContext.AppendDollarError");
return;
}
object old = this.DollarErrorVariable;
ArrayList arraylist = old as ArrayList;
if (arraylist == null)
if (DollarErrorVariable is not ArrayList arraylist)
{
Diagnostics.Assert(false, "$error should be a global constant ArrayList");
return;
@ -1568,23 +1555,6 @@ namespace System.Management.Automation
private void InitializeCommon(AutomationEngine engine, PSHost hostInterface)
{
Engine = engine;
#if !CORECLR// System.AppDomain is not in CoreCLR
// Set the assembly resolve handler if it isn't already set...
if (!_assemblyEventHandlerSet)
{
// we only want to set the event handler once for the entire app domain...
lock (lockObject)
{
// Need to check again inside the lock due to possibility of a race condition...
if (!_assemblyEventHandlerSet)
{
AppDomain currentAppDomain = AppDomain.CurrentDomain;
currentAppDomain.AssemblyResolve += new ResolveEventHandler(PowerShellAssemblyResolveHandler);
_assemblyEventHandlerSet = true;
}
}
}
#endif
Events = new PSLocalEventManager(this);
transactionManager = new PSTransactionManager();
_debugger = new ScriptDebugger(this);
@ -1609,35 +1579,6 @@ namespace System.Management.Automation
}
private static readonly object lockObject = new object();
#if !CORECLR // System.AppDomain is not in CoreCLR
private static bool _assemblyEventHandlerSet = false;
/// <summary>
/// AssemblyResolve event handler that will look in the assembly cache to see
/// if the named assembly has been loaded. This is necessary so that assemblies loaded
/// with LoadFrom, which are in a different loaded context than Load, can still be used to
/// resolve types.
/// </summary>
/// <param name="sender">The event sender.</param>
/// <param name="args">The event args.</param>
/// <returns>The resolve assembly or null if not found.</returns>
private static Assembly PowerShellAssemblyResolveHandler(object sender, ResolveEventArgs args)
{
ExecutionContext ecFromTLS = Runspaces.LocalPipeline.GetExecutionContextFromTLS();
if (ecFromTLS != null)
{
if (ecFromTLS.AssemblyCache != null)
{
Assembly assembly;
ecFromTLS.AssemblyCache.TryGetValue(args.Name, out assembly);
return assembly;
}
}
return null;
}
#endif
}
/// <summary>

View file

@ -22,6 +22,9 @@ namespace System.Management.Automation
internal const string EngineSource = "PSEngine";
internal const string PSNativeCommandArgumentPassingFeatureName = "PSNativeCommandArgumentPassing";
internal const string PSNativeCommandErrorActionPreferenceFeatureName = "PSNativeCommandErrorActionPreference";
internal const string PSRemotingSSHTransportErrorHandling = "PSRemotingSSHTransportErrorHandling";
internal const string PSCleanBlockFeatureName = "PSCleanBlock";
#endregion
@ -122,6 +125,15 @@ namespace System.Management.Automation
new ExperimentalFeature(
name: "PSAnsiRenderingFileInfo",
description: "Enable coloring for FileInfo objects"),
new ExperimentalFeature(
name: PSNativeCommandErrorActionPreferenceFeatureName,
description: "Native commands with non-zero exit codes issue errors according to $ErrorActionPreference when $PSNativeCommandUseErrorActionPreference is $true"),
new ExperimentalFeature(
name: PSRemotingSSHTransportErrorHandling,
description: "Removes the SSH remoting transport stdErr stream message handling as terminating errors, and instead just writes error messages to console."),
new ExperimentalFeature(
name: PSCleanBlockFeatureName,
description: "Add support of a 'Clean' block to functions and script cmdlets for easy resource cleanup"),
};
EngineExperimentalFeatures = new ReadOnlyCollection<ExperimentalFeature>(engineFeatures);

View file

@ -1308,37 +1308,6 @@ namespace System.Management.Automation.Runspaces
}
}
#region VariableHelper
/// <summary>
/// A helper for adding variables to session state.
/// Experimental features can be handled here.
/// </summary>
/// <param name="variables">The variables to add to session state.</param>
private void AddVariables(IEnumerable<SessionStateVariableEntry> variables)
{
Variables.Add(variables);
// If the PSNativeCommandArgumentPassing feature is enabled, create the variable which controls the behavior
// Since the BuiltInVariables list is static, and this should be done dynamically
// we need to do this here. Also, since the defaults are different based on platform we need a
// bit more logic.
if (ExperimentalFeature.IsEnabled("PSNativeCommandArgumentPassing"))
{
NativeArgumentPassingStyle style = NativeArgumentPassingStyle.Standard;
if (Platform.IsWindows) {
style = NativeArgumentPassingStyle.Windows;
}
Variables.Add(
new SessionStateVariableEntry(
SpecialVariables.NativeArgumentPassing,
style,
RunspaceInit.NativeCommandArgumentPassingDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(NativeArgumentPassingStyle))));
}
}
#endregion
/// <summary>
/// Creates an initial session state from a PSSC configuration file.
/// </summary>
@ -1444,7 +1413,7 @@ namespace System.Management.Automation.Runspaces
}
// Add built-in variables.
iss.AddVariables(BuiltInVariables);
iss.Variables.Add(BuiltInVariables);
// wrap some commands in a proxy function to restrict their parameters
foreach (KeyValuePair<string, CommandMetadata> proxyFunction in CommandMetadata.GetRestrictedCommands(SessionCapabilities.RemoteServer))
@ -1465,9 +1434,6 @@ namespace System.Management.Automation.Runspaces
return iss;
}
// Porting note: moved to Platform so we have one list to maintain
private static readonly string[] s_PSCoreFormatFileNames = Platform.FormatFileNames.ToArray();
private static void IncludePowerShellCoreFormats(InitialSessionState iss)
{
string psHome = Utils.DefaultPowerShellAppBase;
@ -1477,7 +1443,7 @@ namespace System.Management.Automation.Runspaces
}
iss.Formats.Clear();
foreach (var coreFormat in s_PSCoreFormatFileNames)
foreach (var coreFormat in Platform.FormatFileNames)
{
iss.Formats.Add(new SessionStateFormatEntry(Path.Combine(psHome, coreFormat)));
}
@ -1531,7 +1497,7 @@ namespace System.Management.Automation.Runspaces
InitialSessionState ss = new InitialSessionState();
ss.AddVariables(BuiltInVariables);
ss.Variables.Add(BuiltInVariables);
ss.Commands.Add(new SessionStateApplicationEntry("*"));
ss.Commands.Add(new SessionStateScriptEntry("*"));
ss.Commands.Add(BuiltInFunctions);
@ -1598,7 +1564,7 @@ namespace System.Management.Automation.Runspaces
{
InitialSessionState ss = new InitialSessionState();
ss.AddVariables(BuiltInVariables);
ss.Variables.Add(BuiltInVariables);
ss.Commands.Add(new SessionStateApplicationEntry("*"));
ss.Commands.Add(new SessionStateScriptEntry("*"));
ss.Commands.Add(BuiltInFunctions);
@ -1639,7 +1605,7 @@ namespace System.Management.Automation.Runspaces
{
InitialSessionState ss = new InitialSessionState();
ss.AddVariables(this.Variables.Clone());
ss.Variables.Add(this.Variables.Clone());
ss.EnvironmentVariables.Add(this.EnvironmentVariables.Clone());
ss.Commands.Add(this.Commands.Clone());
ss.Assemblies.Add(this.Assemblies.Clone());
@ -4474,151 +4440,180 @@ end {
internal const bool DefaultWhatIfPreference = false;
internal const ConfirmImpact DefaultConfirmPreference = ConfirmImpact.High;
internal static readonly SessionStateVariableEntry[] BuiltInVariables = new SessionStateVariableEntry[]
static InitialSessionState()
{
// Engine variables that should be precreated before running profile
// Bug fix for Win7:2202228 Engine halts if initial command fulls up variable table
// Anytime a new variable that the engine depends on to run is added, this table
// must be updated...
new SessionStateVariableEntry(SpecialVariables.LastToken, null, string.Empty),
new SessionStateVariableEntry(SpecialVariables.FirstToken, null, string.Empty),
new SessionStateVariableEntry(SpecialVariables.StackTrace, null, string.Empty),
var builtinVariables = new List<SessionStateVariableEntry>()
{
// Engine variables that should be precreated before running profile
// Bug fix for Win7:2202228 Engine halts if initial command fulls up variable table
// Anytime a new variable that the engine depends on to run is added, this table
// must be updated...
new SessionStateVariableEntry(SpecialVariables.LastToken, null, string.Empty),
new SessionStateVariableEntry(SpecialVariables.FirstToken, null, string.Empty),
new SessionStateVariableEntry(SpecialVariables.StackTrace, null, string.Empty),
// Variable which controls the output rendering
new SessionStateVariableEntry(
SpecialVariables.PSStyle,
PSStyle.Instance,
RunspaceInit.PSStyleDescription,
ScopedItemOptions.None),
// Variable which controls the output rendering
new SessionStateVariableEntry(
SpecialVariables.PSStyle,
PSStyle.Instance,
RunspaceInit.PSStyleDescription,
ScopedItemOptions.None),
// Variable which controls the encoding for piping data to a NativeCommand
new SessionStateVariableEntry(
SpecialVariables.OutputEncoding,
Utils.utf8NoBom,
RunspaceInit.OutputEncodingDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(System.Text.Encoding))),
// Variable which controls the encoding for piping data to a NativeCommand
new SessionStateVariableEntry(
SpecialVariables.OutputEncoding,
Utils.utf8NoBom,
RunspaceInit.OutputEncodingDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(System.Text.Encoding))),
// Preferences
//
// NTRAID#Windows Out Of Band Releases-931461-2006/03/13
// ArgumentTypeConverterAttribute is applied to these variables,
// but this only reaches the global variable. If these are
// redefined in script scope etc, the type conversion
// is not applicable.
//
// Variables typed to ActionPreference
new SessionStateVariableEntry(
SpecialVariables.ConfirmPreference,
DefaultConfirmPreference,
RunspaceInit.ConfirmPreferenceDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(ConfirmImpact))),
new SessionStateVariableEntry(
SpecialVariables.DebugPreference,
DefaultDebugPreference,
RunspaceInit.DebugPreferenceDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(ActionPreference))),
new SessionStateVariableEntry(
SpecialVariables.ErrorActionPreference,
DefaultErrorActionPreference,
RunspaceInit.ErrorActionPreferenceDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(ActionPreference))),
new SessionStateVariableEntry(
SpecialVariables.ProgressPreference,
DefaultProgressPreference,
RunspaceInit.ProgressPreferenceDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(ActionPreference))),
new SessionStateVariableEntry(
SpecialVariables.VerbosePreference,
DefaultVerbosePreference,
RunspaceInit.VerbosePreferenceDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(ActionPreference))),
new SessionStateVariableEntry(
SpecialVariables.WarningPreference,
DefaultWarningPreference,
RunspaceInit.WarningPreferenceDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(ActionPreference))),
new SessionStateVariableEntry(
SpecialVariables.InformationPreference,
DefaultInformationPreference,
RunspaceInit.InformationPreferenceDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(ActionPreference))),
new SessionStateVariableEntry(
SpecialVariables.ErrorView,
DefaultErrorView,
RunspaceInit.ErrorViewDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(ErrorView))),
new SessionStateVariableEntry(
SpecialVariables.NestedPromptLevel,
0,
RunspaceInit.NestedPromptLevelDescription),
new SessionStateVariableEntry(
SpecialVariables.WhatIfPreference,
DefaultWhatIfPreference,
RunspaceInit.WhatIfPreferenceDescription),
new SessionStateVariableEntry(
FormatEnumerationLimit,
DefaultFormatEnumerationLimit,
RunspaceInit.FormatEnumerationLimitDescription),
// Preferences
//
// NTRAID#Windows Out Of Band Releases-931461-2006/03/13
// ArgumentTypeConverterAttribute is applied to these variables,
// but this only reaches the global variable. If these are
// redefined in script scope etc, the type conversion
// is not applicable.
//
// Variables typed to ActionPreference
new SessionStateVariableEntry(
SpecialVariables.ConfirmPreference,
DefaultConfirmPreference,
RunspaceInit.ConfirmPreferenceDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(ConfirmImpact))),
new SessionStateVariableEntry(
SpecialVariables.DebugPreference,
DefaultDebugPreference,
RunspaceInit.DebugPreferenceDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(ActionPreference))),
new SessionStateVariableEntry(
SpecialVariables.ErrorActionPreference,
DefaultErrorActionPreference,
RunspaceInit.ErrorActionPreferenceDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(ActionPreference))),
new SessionStateVariableEntry(
SpecialVariables.ProgressPreference,
DefaultProgressPreference,
RunspaceInit.ProgressPreferenceDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(ActionPreference))),
new SessionStateVariableEntry(
SpecialVariables.VerbosePreference,
DefaultVerbosePreference,
RunspaceInit.VerbosePreferenceDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(ActionPreference))),
new SessionStateVariableEntry(
SpecialVariables.WarningPreference,
DefaultWarningPreference,
RunspaceInit.WarningPreferenceDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(ActionPreference))),
new SessionStateVariableEntry(
SpecialVariables.InformationPreference,
DefaultInformationPreference,
RunspaceInit.InformationPreferenceDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(ActionPreference))),
new SessionStateVariableEntry(
SpecialVariables.ErrorView,
DefaultErrorView,
RunspaceInit.ErrorViewDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(ErrorView))),
new SessionStateVariableEntry(
SpecialVariables.NestedPromptLevel,
0,
RunspaceInit.NestedPromptLevelDescription),
new SessionStateVariableEntry(
SpecialVariables.WhatIfPreference,
DefaultWhatIfPreference,
RunspaceInit.WhatIfPreferenceDescription),
new SessionStateVariableEntry(
FormatEnumerationLimit,
DefaultFormatEnumerationLimit,
RunspaceInit.FormatEnumerationLimitDescription),
// variable for PSEmailServer
new SessionStateVariableEntry(
SpecialVariables.PSEmailServer,
string.Empty,
RunspaceInit.PSEmailServerDescription),
// variable for PSEmailServer
new SessionStateVariableEntry(
SpecialVariables.PSEmailServer,
string.Empty,
RunspaceInit.PSEmailServerDescription),
// Start: Variables which control remoting behavior
new SessionStateVariableEntry(
Microsoft.PowerShell.Commands.PSRemotingBaseCmdlet.DEFAULT_SESSION_OPTION,
new System.Management.Automation.Remoting.PSSessionOption(),
RemotingErrorIdStrings.PSDefaultSessionOptionDescription,
ScopedItemOptions.None),
new SessionStateVariableEntry(
SpecialVariables.PSSessionConfigurationName,
"http://schemas.microsoft.com/powershell/Microsoft.PowerShell",
RemotingErrorIdStrings.PSSessionConfigurationName,
ScopedItemOptions.None),
new SessionStateVariableEntry(
SpecialVariables.PSSessionApplicationName,
"wsman",
RemotingErrorIdStrings.PSSessionAppName,
ScopedItemOptions.None),
// End: Variables which control remoting behavior
// Start: Variables which control remoting behavior
new SessionStateVariableEntry(
Microsoft.PowerShell.Commands.PSRemotingBaseCmdlet.DEFAULT_SESSION_OPTION,
new System.Management.Automation.Remoting.PSSessionOption(),
RemotingErrorIdStrings.PSDefaultSessionOptionDescription,
ScopedItemOptions.None),
new SessionStateVariableEntry(
SpecialVariables.PSSessionConfigurationName,
"http://schemas.microsoft.com/powershell/Microsoft.PowerShell",
RemotingErrorIdStrings.PSSessionConfigurationName,
ScopedItemOptions.None),
new SessionStateVariableEntry(
SpecialVariables.PSSessionApplicationName,
"wsman",
RemotingErrorIdStrings.PSSessionAppName,
ScopedItemOptions.None),
// End: Variables which control remoting behavior
#region Platform
new SessionStateVariableEntry(
SpecialVariables.IsLinux,
Platform.IsLinux,
string.Empty,
ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
#region Platform
new SessionStateVariableEntry(
SpecialVariables.IsLinux,
Platform.IsLinux,
string.Empty,
ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateVariableEntry(
SpecialVariables.IsMacOS,
Platform.IsMacOS,
string.Empty,
ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateVariableEntry(
SpecialVariables.IsMacOS,
Platform.IsMacOS,
string.Empty,
ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateVariableEntry(
SpecialVariables.IsWindows,
Platform.IsWindows,
string.Empty,
ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateVariableEntry(
SpecialVariables.IsWindows,
Platform.IsWindows,
string.Empty,
ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateVariableEntry(
SpecialVariables.IsCoreCLR,
Platform.IsCoreCLR,
string.Empty,
ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
#endregion
};
new SessionStateVariableEntry(
SpecialVariables.IsCoreCLR,
Platform.IsCoreCLR,
string.Empty,
ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
#endregion
};
if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandErrorActionPreferenceFeatureName))
{
builtinVariables.Add(
new SessionStateVariableEntry(
SpecialVariables.PSNativeCommandUseErrorActionPreference,
value: false,
RunspaceInit.PSNativeCommandUseErrorActionPreferenceDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(bool))));
}
if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandArgumentPassingFeatureName))
{
builtinVariables.Add(
new SessionStateVariableEntry(
SpecialVariables.NativeArgumentPassing,
Platform.IsWindows ? NativeArgumentPassingStyle.Windows : NativeArgumentPassingStyle.Standard,
RunspaceInit.NativeCommandArgumentPassingDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(NativeArgumentPassingStyle))));
}
BuiltInVariables = builtinVariables.ToArray();
}
internal static readonly SessionStateVariableEntry[] BuiltInVariables;
/// <summary>
/// Returns a new array of alias entries everytime it's called. This

View file

@ -6,7 +6,6 @@ using System.Collections;
using System.Collections.Generic;
using System.Dynamic;
using System.Globalization;
using System.Linq;
using System.Linq.Expressions;
using System.Management.Automation;
using System.Management.Automation.Internal;
@ -15,8 +14,10 @@ using System.Management.Automation.PSTasks;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using CommonParamSet = System.Management.Automation.Internal.CommonParameters;
using Dbg = System.Management.Automation.Diagnostics;
using NotNullWhen = System.Diagnostics.CodeAnalysis.NotNullWhenAttribute;
namespace Microsoft.PowerShell.Commands
{
@ -2647,46 +2648,19 @@ namespace Microsoft.PowerShell.Commands
private SwitchParameter _off;
/// <summary>
/// To make it easier to specify a version, we add some conversions that wouldn't happen otherwise:
/// * A simple integer, i.e. 2
/// * A string without a dot, i.e. "2"
/// * The string 'latest', which we interpret to be the current version of PowerShell.
/// Handle 'latest', which we interpret to be the current version of PowerShell.
/// </summary>
private sealed class ArgumentToVersionTransformationAttribute : ArgumentTransformationAttribute
private sealed class ArgumentToPSVersionTransformationAttribute : ArgumentToVersionTransformationAttribute
{
public override object Transform(EngineIntrinsics engineIntrinsics, object inputData)
protected override bool TryConvertFromString(string versionString, [NotNullWhen(true)] out Version version)
{
object version = PSObject.Base(inputData);
string versionStr = version as string;
if (versionStr != null)
if (string.Equals("latest", versionString, StringComparison.OrdinalIgnoreCase))
{
if (versionStr.Equals("latest", StringComparison.OrdinalIgnoreCase))
{
return PSVersionInfo.PSVersion;
}
if (versionStr.Contains('.'))
{
// If the string contains a '.', let the Version constructor handle the conversion.
return inputData;
}
version = PSVersionInfo.PSVersion;
return true;
}
if (version is double)
{
// The conversion to int below is wrong, but the usual conversions will turn
// the double into a string, so just return the original object.
return inputData;
}
int majorVersion;
if (LanguagePrimitives.TryConvertTo<int>(version, out majorVersion))
{
return new Version(majorVersion, 0);
}
return inputData;
return base.TryConvertFromString(versionString, out version);
}
}
@ -2711,7 +2685,7 @@ namespace Microsoft.PowerShell.Commands
/// Gets or sets strict mode in the current scope.
/// </summary>
[Parameter(ParameterSetName = "Version", Mandatory = true)]
[ArgumentToVersionTransformation]
[ArgumentToPSVersionTransformation]
[ValidateVersion]
[Alias("v")]
public Version Version

View file

@ -928,7 +928,8 @@ namespace System.Management.Automation
/// </summary>
internal string PipelineVariable { get; set; }
private PSVariable _pipelineVarReference = null;
private PSVariable _pipelineVarReference;
private bool _shouldRemovePipelineVariable;
internal void SetupOutVariable()
{
@ -941,10 +942,8 @@ namespace System.Management.Automation
// Handle the creation of OutVariable in the case of Out-Default specially,
// as it needs to handle much of its OutVariable support itself.
if (
(!string.IsNullOrEmpty(this.OutVariable)) &&
(!(this.OutVariable.StartsWith('+'))) &&
string.Equals("Out-Default", _thisCommand.CommandInfo.Name, StringComparison.OrdinalIgnoreCase))
if (!OutVariable.StartsWith('+') &&
string.Equals("Out-Default", _commandInfo.Name, StringComparison.OrdinalIgnoreCase))
{
if (_state == null)
_state = new SessionState(Context.EngineSessionState);
@ -972,7 +971,7 @@ namespace System.Management.Automation
// This can't use the common SetupVariable implementation, as this needs to persist for an entire
// pipeline.
if (string.IsNullOrEmpty(this.PipelineVariable))
if (string.IsNullOrEmpty(PipelineVariable))
{
return;
}
@ -983,12 +982,24 @@ namespace System.Management.Automation
_state = new SessionState(Context.EngineSessionState);
// Create the pipeline variable
_pipelineVarReference = new PSVariable(this.PipelineVariable);
_state.PSVariable.Set(_pipelineVarReference);
_pipelineVarReference = new PSVariable(PipelineVariable);
object varToUse = _state.Internal.SetVariable(
_pipelineVarReference,
force: false,
CommandOrigin.Internal);
// Get the reference again in case we re-used one from the
// same scope.
_pipelineVarReference = _state.PSVariable.Get(this.PipelineVariable);
if (ReferenceEquals(_pipelineVarReference, varToUse))
{
// The returned variable is the exact same instance, which means we set a new variable.
// In this case, we will try removing the pipeline variable in the end.
_shouldRemovePipelineVariable = true;
}
else
{
// A variable with the same name already exists in the same scope and it was returned.
// In this case, we update the reference and don't remove the variable in the end.
_pipelineVarReference = (PSVariable)varToUse;
}
if (_thisCommand is not PSScriptCmdlet)
{
@ -996,6 +1007,15 @@ namespace System.Management.Automation
}
}
internal void RemovePipelineVariable()
{
if (_shouldRemovePipelineVariable)
{
// Remove pipeline variable when a pipeline is being torn down.
_state.PSVariable.Remove(PipelineVariable);
}
}
/// <summary>
/// Configures the number of objects to buffer before calling the downstream Cmdlet.
/// </summary>
@ -1063,7 +1083,7 @@ namespace System.Management.Automation
/// <see cref="System.Management.Automation.ActionPreferenceStopException"/>,
/// </remarks>
/// <example>
/// <snippet Code="C#">
/// <code>
/// namespace Microsoft.Samples.MSH.Cmdlet
/// {
/// [Cmdlet(VerbsCommon.Remove,"myobjecttype1")]
@ -1086,7 +1106,7 @@ namespace System.Management.Automation
/// }
/// }
/// }
/// </snippet>
/// </code>
/// </example>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string,string)"/>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string,string,string)"/>
@ -1157,7 +1177,7 @@ namespace System.Management.Automation
/// <see cref="System.Management.Automation.ActionPreferenceStopException"/>,
/// </remarks>
/// <example>
/// <snippet Code="C#">
/// <code>
/// namespace Microsoft.Samples.MSH.Cmdlet
/// {
/// [Cmdlet(VerbsCommon.Remove,"myobjecttype2")]
@ -1180,7 +1200,7 @@ namespace System.Management.Automation
/// }
/// }
/// }
/// </snippet>
/// </code>
/// </example>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string)"/>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string,string,string)"/>
@ -1260,7 +1280,7 @@ namespace System.Management.Automation
/// <see cref="System.Management.Automation.ActionPreferenceStopException"/>,
/// </remarks>
/// <example>
/// <snippet Code="C#">
/// <code>
/// namespace Microsoft.Samples.MSH.Cmdlet
/// {
/// [Cmdlet(VerbsCommon.Remove,"myobjecttype3")]
@ -1286,7 +1306,7 @@ namespace System.Management.Automation
/// }
/// }
/// }
/// </snippet>
/// </code>
/// </example>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string)"/>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string,string)"/>
@ -1375,7 +1395,7 @@ namespace System.Management.Automation
/// <see cref="System.Management.Automation.ActionPreferenceStopException"/>,
/// </remarks>
/// <example>
/// <snippet Code="C#">
/// <code>
/// namespace Microsoft.Samples.MSH.Cmdlet
/// {
/// [Cmdlet(VerbsCommon.Remove,"myobjecttype3")]
@ -1403,7 +1423,7 @@ namespace System.Management.Automation
/// }
/// }
/// }
/// </snippet>
/// </code>
/// </example>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string)"/>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string,string)"/>
@ -1681,7 +1701,7 @@ namespace System.Management.Automation
/// to ShouldProcess for the Cmdlet instance.
/// </remarks>
/// <example>
/// <snippet Code="C#">
/// <code>
/// namespace Microsoft.Samples.MSH.Cmdlet
/// {
/// [Cmdlet(VerbsCommon.Remove,"myobjecttype4")]
@ -1725,7 +1745,7 @@ namespace System.Management.Automation
/// }
/// }
/// }
/// </snippet>
/// </code>
/// </example>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldContinue(string,string,ref bool,ref bool)"/>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string)"/>
@ -1863,7 +1883,7 @@ namespace System.Management.Automation
/// to ShouldProcess for the Cmdlet instance.
/// </remarks>
/// <example>
/// <snippet Code="C#">
/// <code>
/// namespace Microsoft.Samples.MSH.Cmdlet
/// {
/// [Cmdlet(VerbsCommon.Remove,"myobjecttype4")]
@ -1912,7 +1932,7 @@ namespace System.Management.Automation
/// }
/// }
/// }
/// </snippet>
/// </code>
/// </example>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldContinue(string,string)"/>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string)"/>
@ -2404,7 +2424,6 @@ namespace System.Management.Automation
}
// Log a command health event
MshLog.LogCommandHealthEvent(
Context,
e,
@ -2804,8 +2823,16 @@ namespace System.Management.Automation
_WriteErrorSkipAllowCheck(errorRecord, preference);
}
// NOTICE-2004/06/08-JonN 959638
// Use this variant to skip the ThrowIfWriteNotPermitted check
/// <summary>
/// Write an error, skipping the ThrowIfWriteNotPermitted check.
/// </summary>
/// <param name="errorRecord">The error record to write.</param>
/// <param name="actionPreference">The configured error action preference.</param>
/// <param name="isFromNativeStdError">
/// True when this method is called to write from a native command's stderr stream.
/// When errors are written through a native stderr stream, they do not interact with the error preference system,
/// but must still present as errors in PowerShell.
/// </param>
/// <exception cref="System.Management.Automation.PipelineStoppedException">
/// The pipeline has already been terminated, or was terminated
/// during the execution of this method.
@ -2819,7 +2846,7 @@ namespace System.Management.Automation
/// but the command failure will ultimately be
/// <see cref="System.Management.Automation.ActionPreferenceStopException"/>,
/// </remarks>
internal void _WriteErrorSkipAllowCheck(ErrorRecord errorRecord, ActionPreference? actionPreference = null, bool isNativeError = false)
internal void _WriteErrorSkipAllowCheck(ErrorRecord errorRecord, ActionPreference? actionPreference = null, bool isFromNativeStdError = false)
{
ThrowIfStopping();
@ -2839,7 +2866,7 @@ namespace System.Management.Automation
this.PipelineProcessor.LogExecutionError(_thisCommand.MyInvocation, errorRecord);
}
if (!isNativeError)
if (!isFromNativeStdError)
{
this.PipelineProcessor.ExecutionFailed = true;
@ -2905,7 +2932,7 @@ namespace System.Management.Automation
// when tracing), so don't add the member again.
// We don't add a note property on messages that comes from stderr stream.
if (!isNativeError)
if (!isFromNativeStdError)
{
errorWrap.WriteStream = WriteStreamType.Error;
}
@ -3242,8 +3269,7 @@ namespace System.Management.Automation
{
if (!IsWhatIfFlagSet && !_isWhatIfPreferenceCached)
{
bool defaultUsed = false;
_whatIfFlag = Context.GetBooleanPreference(SpecialVariables.WhatIfPreferenceVarPath, _whatIfFlag, out defaultUsed);
_whatIfFlag = Context.GetBooleanPreference(SpecialVariables.WhatIfPreferenceVarPath, _whatIfFlag, out _);
_isWhatIfPreferenceCached = true;
}
@ -3736,8 +3762,10 @@ namespace System.Management.Automation
{
Diagnostics.Assert(_thisCommand is PSScriptCmdlet, "this is only done for script cmdlets");
if (_outVarList != null)
if (_outVarList != null && !OutputPipe.IgnoreOutVariableList)
{
// A null pipe is used when executing the 'Clean' block of a PSScriptCmdlet.
// In such a case, we don't capture output to the out variable list.
this.OutputPipe.AddVariableList(VariableStreamKind.Output, _outVarList);
}
@ -3758,26 +3786,13 @@ namespace System.Management.Automation
if (this.PipelineVariable != null)
{
// _state can be null if the current script block is dynamicparam, etc.
if (_state != null)
{
// Create the pipeline variable
_state.PSVariable.Set(_pipelineVarReference);
// Get the reference again in case we re-used one from the
// same scope.
_pipelineVarReference = _state.PSVariable.Get(this.PipelineVariable);
}
this.OutputPipe.SetPipelineVariable(_pipelineVarReference);
}
}
internal void RemoveVariableListsInPipe()
{
// Diagnostics.Assert(thisCommand is PSScriptCmdlet, "this is only done for script cmdlets");
if (_outVarList != null)
if (_outVarList != null && !OutputPipe.IgnoreOutVariableList)
{
this.OutputPipe.RemoveVariableList(VariableStreamKind.Output, _outVarList);
}
@ -3800,9 +3815,6 @@ namespace System.Management.Automation
if (this.PipelineVariable != null)
{
this.OutputPipe.RemovePipelineVariable();
// '_state' could be null when a 'DynamicParam' block runs because the 'DynamicParam' block runs in 'DoPrepare',
// before 'PipelineProcessor.SetupParameterVariables' is called, where '_state' is initialized.
_state?.PSVariable.Remove(this.PipelineVariable);
}
}
}

View file

@ -20,8 +20,6 @@ namespace System.Management.Automation
/// </summary>
internal class NativeCommandParameterBinder : ParameterBinderBase
{
private readonly VariablePath s_nativeArgumentPassingVarPath = new VariablePath(SpecialVariables.NativeArgumentPassing);
#region ctor
/// <summary>
@ -193,13 +191,13 @@ namespace System.Management.Automation
{
get
{
if (ExperimentalFeature.IsEnabled("PSNativeCommandArgumentPassing"))
if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandArgumentPassingFeatureName))
{
try
{
// This will default to the new behavior if it is set to anything other than Legacy
var preference = LanguagePrimitives.ConvertTo<NativeArgumentPassingStyle>(
Context.GetVariableValue(s_nativeArgumentPassingVarPath, NativeArgumentPassingStyle.Standard));
Context.GetVariableValue(SpecialVariables.NativeArgumentPassingVarPath, NativeArgumentPassingStyle.Standard));
return preference;
}
catch

View file

@ -3,21 +3,22 @@
#pragma warning disable 1634, 1691
using System.Diagnostics;
using System.IO;
using System.ComponentModel;
using System.Text;
using System.Collections;
using System.Threading;
using System.Management.Automation.Internal;
using System.Xml;
using System.Runtime.InteropServices;
using Dbg = System.Management.Automation.Diagnostics;
using System.Runtime.Serialization;
using System.Globalization;
using System.Diagnostics.CodeAnalysis;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Management.Automation.Internal;
using System.Management.Automation.Runspaces;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Text;
using System.Threading;
using System.Xml;
using Dbg = System.Management.Automation.Diagnostics;
namespace System.Management.Automation
{
@ -130,6 +131,100 @@ namespace System.Management.Automation
}
}
#nullable enable
/// <summary>
/// This exception is used by the NativeCommandProcessor to indicate an error
/// when a native command retuns a non-zero exit code.
/// </summary>
[Serializable]
public sealed class NativeCommandExitException : RuntimeException
{
// NOTE:
// When implementing the native error action preference integration,
// reusing ApplicationFailedException was rejected.
// Instead of reusing a type already used in another scenario
// it was decided instead to use a fresh type to avoid conflating the two scenarios:
// * ApplicationFailedException: PowerShell was not able to complete execution of the application.
// * NativeCommandExitException: the application completed execution but returned a non-zero exit code.
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="NativeCommandExitException"/> class with information on the native
/// command, a specified error message and a specified error ID.
/// </summary>
/// <param name="path">The full path of the native command.</param>
/// <param name="exitCode">The exit code returned by the native command.</param>
/// <param name="processId">The process ID of the process before it ended.</param>
/// <param name="message">The error message.</param>
/// <param name="errorId">The PowerShell runtime error ID.</param>
internal NativeCommandExitException(string path, int exitCode, int processId, string message, string errorId)
: base(message)
{
SetErrorId(errorId);
SetErrorCategory(ErrorCategory.NotSpecified);
Path = path;
ExitCode = exitCode;
ProcessId = processId;
}
/// <summary>
/// Initializes a new instance of the <see cref="NativeCommandExitException"/> class with serialized data.
/// </summary>
/// <param name="info"></param>
/// <param name="context"></param>
private NativeCommandExitException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
if (info is null)
{
throw new PSArgumentNullException(nameof(info));
}
Path = info.GetString(nameof(Path));
ExitCode = info.GetInt32(nameof(ExitCode));
ProcessId = info.GetInt32(nameof(ProcessId));
}
#endregion Constructors
/// <summary>
/// Serializes the exception data.
/// </summary>
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info is null)
{
throw new PSArgumentNullException(nameof(info));
}
base.GetObjectData(info, context);
info.AddValue(nameof(Path), Path);
info.AddValue(nameof(ExitCode), ExitCode);
info.AddValue(nameof(ProcessId), ProcessId);
}
/// <summary>
/// Gets the path of the native command.
/// </summary>
public string? Path { get; }
/// <summary>
/// Gets the exit code returned by the native command.
/// </summary>
public int ExitCode { get; }
/// <summary>
/// Gets the native command's process ID.
/// </summary>
public int ProcessId { get; }
}
#nullable restore
/// <summary>
/// Provides way to create and execute native commands.
/// </summary>
@ -762,8 +857,35 @@ namespace System.Management.Automation
}
this.Command.Context.SetVariable(SpecialVariables.LastExitCodeVarPath, _nativeProcess.ExitCode);
if (_nativeProcess.ExitCode != 0)
this.commandRuntime.PipelineProcessor.ExecutionFailed = true;
if (_nativeProcess.ExitCode == 0)
{
return;
}
this.commandRuntime.PipelineProcessor.ExecutionFailed = true;
if (!ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandErrorActionPreferenceFeatureName)
|| !Command.Context.GetBooleanPreference(SpecialVariables.PSNativeCommandUseErrorActionPreferenceVarPath, defaultPref: false, out _))
{
return;
}
const string errorId = nameof(CommandBaseStrings.ProgramExitedWithNonZeroCode);
string errorMsg = StringUtil.Format(
CommandBaseStrings.ProgramExitedWithNonZeroCode,
NativeCommandName,
_nativeProcess.ExitCode);
var exception = new NativeCommandExitException(
Path,
_nativeProcess.ExitCode,
_nativeProcess.Id,
errorMsg,
errorId);
var errorRecord = new ErrorRecord(exception, errorId, ErrorCategory.NotSpecified, targetObject: Path);
this.commandRuntime._WriteErrorSkipAllowCheck(errorRecord);
}
}
catch (Win32Exception e)
@ -979,15 +1101,9 @@ namespace System.Management.Automation
#if UNIX
return false;
#else
if (!Platform.IsWindowsDesktop) { return false; }
// SHGetFileInfo() does not understand reparse points and returns 0 ("non exe or error")
// so we are trying to get a real path before.
// It is a workaround for Microsoft Store applications.
string realPath = Microsoft.PowerShell.Commands.InternalSymbolicLinkLinkCodeMethods.WinInternalGetTarget(fileName);
if (realPath is not null)
if (!Platform.IsWindowsDesktop)
{
fileName = realPath;
return false;
}
SHFILEINFO shinfo = new SHFILEINFO();
@ -1087,7 +1203,7 @@ namespace System.Management.Automation
ErrorRecord record = outputValue.Data as ErrorRecord;
Dbg.Assert(record != null, "ProcessReader should ensure that data is ErrorRecord");
record.SetInvocationInfo(this.Command.MyInvocation);
this.commandRuntime._WriteErrorSkipAllowCheck(record, isNativeError: true);
this.commandRuntime._WriteErrorSkipAllowCheck(record, isFromNativeStdError: true);
}
else if (outputValue.Stream == MinishellStream.Output)
{

View file

@ -64,6 +64,7 @@ namespace System.Management.Automation
private static readonly SemanticVersion s_psV62Version = new SemanticVersion(6, 2, 0, preReleaseLabel: null, buildLabel: null);
private static readonly SemanticVersion s_psV7Version = new SemanticVersion(7, 0, 0, preReleaseLabel: null, buildLabel: null);
private static readonly SemanticVersion s_psV71Version = new SemanticVersion(7, 1, 0, preReleaseLabel: null, buildLabel: null);
private static readonly SemanticVersion s_psV72Version = new SemanticVersion(7, 2, 0, preReleaseLabel: null, buildLabel: null);
private static readonly SemanticVersion s_psSemVersion;
private static readonly Version s_psVersion;
@ -110,7 +111,7 @@ namespace System.Management.Automation
s_psVersionTable[PSVersionInfo.PSVersionName] = s_psSemVersion;
s_psVersionTable[PSVersionInfo.PSEditionName] = PSEditionValue;
s_psVersionTable[PSGitCommitIdName] = rawGitCommitId;
s_psVersionTable[PSCompatibleVersionsName] = new Version[] { s_psV1Version, s_psV2Version, s_psV3Version, s_psV4Version, s_psV5Version, s_psV51Version, s_psV6Version, s_psV61Version, s_psV62Version, s_psV7Version, s_psV71Version, s_psVersion };
s_psVersionTable[PSCompatibleVersionsName] = new Version[] { s_psV1Version, s_psV2Version, s_psV3Version, s_psV4Version, s_psV5Version, s_psV51Version, s_psV6Version, s_psV61Version, s_psV62Version, s_psV7Version, s_psV71Version, s_psV72Version, s_psVersion };
s_psVersionTable[PSVersionInfo.SerializationVersionName] = new Version(InternalSerializer.DefaultVersion);
s_psVersionTable[PSVersionInfo.PSRemotingProtocolVersionName] = RemotingConstants.ProtocolVersion;
s_psVersionTable[PSVersionInfo.WSManStackVersionName] = GetWSManStackVersion();

View file

@ -109,6 +109,13 @@ namespace System.Management.Automation.Internal
/// </summary>
internal int OutBufferCount { get; set; } = 0;
/// <summary>
/// Gets whether the out variable list should be ignored.
/// This is used for scenarios like the `clean` block, where writing to output stream is intentionally
/// disabled and thus out variables should also be ignored.
/// </summary>
internal bool IgnoreOutVariableList { get; set; }
/// <summary>
/// If true, then all input added to this pipe will simply be discarded...
/// </summary>

View file

@ -247,6 +247,30 @@ namespace System.Management.Automation
return commandMetadata.GetEndBlock();
}
/// <summary>
/// This method constructs a string representing the clean block of the command
/// specified by <paramref name="commandMetadata"/>. The returned string only contains the
/// script, it is not enclosed in "clean { }".
/// </summary>
/// <param name="commandMetadata">
/// An instance of CommandMetadata representing a command.
/// </param>
/// <returns>
/// A string representing the end block of the command.
/// </returns>
/// <exception cref="ArgumentNullException">
/// If <paramref name="commandMetadata"/> is null.
/// </exception>
public static string GetClean(CommandMetadata commandMetadata)
{
if (commandMetadata == null)
{
throw PSTraceSource.NewArgumentNullException(nameof(commandMetadata));
}
return commandMetadata.GetCleanBlock();
}
private static T GetProperty<T>(PSObject obj, string property) where T : class
{
T result = null;

View file

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Management.Automation.Internal;
using System.Management.Automation.Language;
using System.Management.Automation.Runspaces;
using System.Reflection;
using Dbg = System.Management.Automation.Diagnostics;
@ -47,7 +48,7 @@ namespace System.Management.Automation
protected bool _dontUseScopeCommandOrigin;
/// <summary>
/// If true, then an exit exception will be rethrown to instead of caught and processed...
/// If true, then an exit exception will be rethrown instead of caught and processed...
/// </summary>
protected bool _rethrowExitException;
@ -237,6 +238,7 @@ namespace System.Management.Automation
private MutableTuple _localsTuple;
private bool _runOptimizedCode;
private bool _argsBound;
private bool _anyClauseExecuted;
private FunctionContext _functionContext;
internal DlrScriptCommandProcessor(ScriptBlock scriptBlock, ExecutionContext context, bool useNewScope, CommandOrigin origin, SessionStateInternal sessionState, object dollarUnderbar)
@ -327,8 +329,7 @@ namespace System.Management.Automation
ScriptBlock.LogScriptBlockStart(_scriptBlock, Context.CurrentRunspace.InstanceId);
// Even if there is no begin, we need to set up the execution scope for this
// script...
// Even if there is no begin, we need to set up the execution scope for this script...
SetCurrentScopeToExecutionScope();
CommandProcessorBase oldCurrentCommandProcessor = Context.CurrentCommandProcessor;
try
@ -410,6 +411,7 @@ namespace System.Management.Automation
if (_scriptBlock.HasEndBlock)
{
var endBlock = _runOptimizedCode ? _scriptBlock.EndBlock : _scriptBlock.UnoptimizedEndBlock;
if (this.CommandRuntime.InputPipe.ExternalReader == null)
{
if (IsPipelineInputExpected())
@ -433,7 +435,33 @@ namespace System.Management.Automation
}
finally
{
ScriptBlock.LogScriptBlockEnd(_scriptBlock, Context.CurrentRunspace.InstanceId);
if (!_scriptBlock.HasCleanBlock)
{
ScriptBlock.LogScriptBlockEnd(_scriptBlock, Context.CurrentRunspace.InstanceId);
}
}
}
protected override void CleanResource()
{
if (_scriptBlock.HasCleanBlock && _anyClauseExecuted)
{
// The 'Clean' block doesn't write to pipeline.
Pipe oldOutputPipe = _functionContext._outputPipe;
_functionContext._outputPipe = new Pipe { NullPipe = true };
try
{
RunClause(
clause: _runOptimizedCode ? _scriptBlock.CleanBlock : _scriptBlock.UnoptimizedCleanBlock,
dollarUnderbar: AutomationNull.Value,
inputToProcess: AutomationNull.Value);
}
finally
{
_functionContext._outputPipe = oldOutputPipe;
ScriptBlock.LogScriptBlockEnd(_scriptBlock, Context.CurrentRunspace.InstanceId);
}
}
}
@ -459,6 +487,7 @@ namespace System.Management.Automation
{
ExecutionContext.CheckStackDepth();
_anyClauseExecuted = true;
Pipe oldErrorOutputPipe = this.Context.ShellFunctionErrorOutputPipe;
// If the script block has a different language mode than the current,
@ -553,7 +582,7 @@ namespace System.Management.Automation
}
finally
{
this.Context.RestoreErrorPipe(oldErrorOutputPipe);
Context.ShellFunctionErrorOutputPipe = oldErrorOutputPipe;
if (oldLanguageMode.HasValue)
{
@ -584,15 +613,12 @@ namespace System.Management.Automation
}
catch (RuntimeException e)
{
ManageScriptException(e); // always throws
// This quiets the compiler which wants to see a return value
// in all codepaths.
throw;
// This method always throws.
ManageScriptException(e);
}
catch (Exception e)
{
// This cmdlet threw an exception, so
// wrap it and bubble it up.
// This cmdlet threw an exception, so wrap it and bubble it up.
throw ManageInvocationException(e);
}
}

View file

@ -204,6 +204,7 @@ namespace System.Management.Automation
internal static readonly VariablePath PSModuleAutoLoadingPreferenceVarPath = new VariablePath("global:" + PSModuleAutoLoading);
#region Platform Variables
internal const string IsLinux = "IsLinux";
internal static readonly VariablePath IsLinuxPath = new VariablePath("IsLinux");
@ -221,6 +222,7 @@ namespace System.Management.Automation
internal static readonly VariablePath IsCoreCLRPath = new VariablePath("IsCoreCLR");
#endregion
#region Preference Variables
internal const string DebugPreference = "DebugPreference";
@ -257,6 +259,11 @@ namespace System.Management.Automation
#endregion Preference Variables
internal const string PSNativeCommandUseErrorActionPreference = nameof(PSNativeCommandUseErrorActionPreference);
internal static readonly VariablePath PSNativeCommandUseErrorActionPreferenceVarPath =
new(PSNativeCommandUseErrorActionPreference);
// Native command argument passing style
internal const string NativeArgumentPassing = "PSNativeCommandArgumentPassing";
@ -321,25 +328,30 @@ namespace System.Management.Automation
/* PSCommandPath */ typeof(string),
};
internal static readonly string[] PreferenceVariables = {
SpecialVariables.DebugPreference,
SpecialVariables.VerbosePreference,
SpecialVariables.ErrorActionPreference,
SpecialVariables.WhatIfPreference,
SpecialVariables.WarningPreference,
SpecialVariables.InformationPreference,
SpecialVariables.ConfirmPreference,
};
// This array and the one below it exist to optimize the way common parameters work in advanced functions.
// Common parameters work by setting preference variables in the scope of the function and restoring the old value afterward.
// Variables that don't correspond to common cmdlet parameters don't need to be added here.
internal static readonly string[] PreferenceVariables =
{
SpecialVariables.DebugPreference,
SpecialVariables.VerbosePreference,
SpecialVariables.ErrorActionPreference,
SpecialVariables.WhatIfPreference,
SpecialVariables.WarningPreference,
SpecialVariables.InformationPreference,
SpecialVariables.ConfirmPreference,
};
internal static readonly Type[] PreferenceVariableTypes = {
/* DebugPreference */ typeof(ActionPreference),
/* VerbosePreference */ typeof(ActionPreference),
/* ErrorPreference */ typeof(ActionPreference),
/* WhatIfPreference */ typeof(SwitchParameter),
/* WarningPreference */ typeof(ActionPreference),
/* InformationPreference */ typeof(ActionPreference),
/* ConfirmPreference */ typeof(ConfirmImpact),
};
internal static readonly Type[] PreferenceVariableTypes =
{
/* DebugPreference */ typeof(ActionPreference),
/* VerbosePreference */ typeof(ActionPreference),
/* ErrorPreference */ typeof(ActionPreference),
/* WhatIfPreference */ typeof(SwitchParameter),
/* WarningPreference */ typeof(ActionPreference),
/* InformationPreference */ typeof(ActionPreference),
/* ConfirmPreference */ typeof(ConfirmImpact),
};
// The following variables are created in every session w/ AllScope. We avoid creating local slots when we
// see an assignment to any of these variables so that they get handled properly (either throwing an exception

View file

@ -1747,7 +1747,7 @@ namespace System.Management.Automation.Runspaces
/// <summary>
/// This exception is used by TypeTable constructor to indicate errors
/// occured during construction time.
/// occurred during construction time.
/// </summary>
[Serializable]
public class TypeTableLoadException : RuntimeException
@ -1796,7 +1796,7 @@ namespace System.Management.Automation.Runspaces
/// time.
/// </summary>
/// <param name="loadErrors">
/// The errors that occured
/// The errors that occurred
/// </param>
internal TypeTableLoadException(ConcurrentBag<string> loadErrors)
: base(TypesXmlStrings.TypeTableLoadErrors)

View file

@ -680,10 +680,7 @@ namespace System.Management.Automation.Runspaces
AddMember(
errors,
typeName,
new PSCodeProperty(
@"Target",
GetMethodInfo(typeof(Microsoft.PowerShell.Commands.InternalSymbolicLinkLinkCodeMethods), @"GetTarget"),
setterCodeReference: null),
new PSAliasProperty(@"Target", @"LinkTarget", conversionType: null),
typeMembers,
isOverride: false);
@ -808,10 +805,7 @@ namespace System.Management.Automation.Runspaces
AddMember(
errors,
typeName,
new PSCodeProperty(
@"Target",
GetMethodInfo(typeof(Microsoft.PowerShell.Commands.InternalSymbolicLinkLinkCodeMethods), @"GetTarget"),
setterCodeReference: null),
new PSAliasProperty(@"Target", @"LinkTarget", conversionType: null),
typeMembers,
isOverride: false);

View file

@ -801,7 +801,7 @@ namespace System.Management.Automation
/// <see cref="System.Management.Automation.ActionPreferenceStopException"/>,
/// </remarks>
/// <example>
/// <snippet Code="C#">
/// <code>
/// namespace Microsoft.Samples.MSH.Cmdlet
/// {
/// [Cmdlet(VerbsCommon.Remove,"myobjecttype1")]
@ -824,7 +824,7 @@ namespace System.Management.Automation
/// }
/// }
/// }
/// </snippet>
/// </code>
/// </example>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string,string)"/>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string,string,string)"/>
@ -897,7 +897,7 @@ namespace System.Management.Automation
/// <see cref="System.Management.Automation.ActionPreferenceStopException"/>,
/// </remarks>
/// <example>
/// <snippet Code="C#">
/// <code>
/// namespace Microsoft.Samples.MSH.Cmdlet
/// {
/// [Cmdlet(VerbsCommon.Remove,"myobjecttype2")]
@ -920,7 +920,7 @@ namespace System.Management.Automation
/// }
/// }
/// }
/// </snippet>
/// </code>
/// </example>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string)"/>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string,string,string)"/>
@ -1001,7 +1001,7 @@ namespace System.Management.Automation
/// <see cref="System.Management.Automation.ActionPreferenceStopException"/>,
/// </remarks>
/// <example>
/// <snippet Code="C#">
/// <code>
/// namespace Microsoft.Samples.MSH.Cmdlet
/// {
/// [Cmdlet(VerbsCommon.Remove,"myobjecttype3")]
@ -1027,7 +1027,7 @@ namespace System.Management.Automation
/// }
/// }
/// }
/// </snippet>
/// </code>
/// </example>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string)"/>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string,string)"/>
@ -1117,7 +1117,7 @@ namespace System.Management.Automation
/// <see cref="System.Management.Automation.ActionPreferenceStopException"/>,
/// </remarks>
/// <example>
/// <snippet Code="C#">
/// <code>
/// namespace Microsoft.Samples.MSH.Cmdlet
/// {
/// [Cmdlet(VerbsCommon.Remove,"myobjecttype3")]
@ -1145,7 +1145,7 @@ namespace System.Management.Automation
/// }
/// }
/// }
/// </snippet>
/// </code>
/// </example>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string)"/>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string,string)"/>
@ -1233,7 +1233,7 @@ namespace System.Management.Automation
/// to ShouldProcess for the Cmdlet instance.
/// </remarks>
/// <example>
/// <snippet Code="C#">
/// <code>
/// namespace Microsoft.Samples.MSH.Cmdlet
/// {
/// [Cmdlet(VerbsCommon.Remove,"myobjecttype4")]
@ -1277,7 +1277,7 @@ namespace System.Management.Automation
/// }
/// }
/// }
/// </snippet>
/// </code>
/// </example>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldContinue(string,string,ref bool,ref bool)"/>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string)"/>
@ -1362,7 +1362,7 @@ namespace System.Management.Automation
/// to ShouldProcess for the Cmdlet instance.
/// </remarks>
/// <example>
/// <snippet Code="C#">
/// <code>
/// namespace Microsoft.Samples.MSH.Cmdlet
/// {
/// [Cmdlet(VerbsCommon.Remove,"myobjecttype4")]
@ -1411,7 +1411,7 @@ namespace System.Management.Automation
/// }
/// }
/// }
/// </snippet>
/// </code>
/// </example>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldContinue(string,string)"/>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string)"/>
@ -1502,7 +1502,7 @@ namespace System.Management.Automation
/// to ShouldProcess for the Cmdlet instance.
/// </remarks>
/// <example>
/// <snippet Code="C#">
/// <code>
/// namespace Microsoft.Samples.MSH.Cmdlet
/// {
/// [Cmdlet(VerbsCommon.Remove,"myobjecttype4")]
@ -1551,7 +1551,7 @@ namespace System.Management.Automation
/// }
/// }
/// }
/// </snippet>
/// </code>
/// </example>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldContinue(string,string)"/>
/// <seealso cref="System.Management.Automation.Cmdlet.ShouldProcess(string)"/>

View file

@ -531,15 +531,16 @@ namespace System.Management.Automation
// Not found. First, we check if the line/column is before any real code. If so, we'll
// move the breakpoint to the first interesting sequence point (could be a dynamicparam,
// begin, process, or end block.)
// begin, process, end, or clean block.)
if (scriptBlock != null)
{
var ast = scriptBlock.Ast;
var bodyAst = ((IParameterMetadataProvider)ast).Body;
if ((bodyAst.DynamicParamBlock == null || bodyAst.DynamicParamBlock.Extent.IsAfter(Line, Column)) &&
(bodyAst.BeginBlock == null || bodyAst.BeginBlock.Extent.IsAfter(Line, Column)) &&
(bodyAst.ProcessBlock == null || bodyAst.ProcessBlock.Extent.IsAfter(Line, Column)) &&
(bodyAst.EndBlock == null || bodyAst.EndBlock.Extent.IsAfter(Line, Column)))
if ((bodyAst.DynamicParamBlock == null || bodyAst.DynamicParamBlock.Extent.IsAfter(Line, Column))
&& (bodyAst.BeginBlock == null || bodyAst.BeginBlock.Extent.IsAfter(Line, Column))
&& (bodyAst.ProcessBlock == null || bodyAst.ProcessBlock.Extent.IsAfter(Line, Column))
&& (bodyAst.EndBlock == null || bodyAst.EndBlock.Extent.IsAfter(Line, Column))
&& (bodyAst.CleanBlock == null || bodyAst.CleanBlock.Extent.IsAfter(Line, Column)))
{
SetBreakpoint(functionContext, 0);
return true;

View file

@ -1458,7 +1458,7 @@ namespace System.Management.Automation.Host
/// Provided for clearing regions -- less chatty than passing an array of cells.
/// </remarks>
/// <example>
/// <snippet Code="C#">
/// <code>
/// using System;
/// using System.Management.Automation;
/// using System.Management.Automation.Host;
@ -1474,7 +1474,7 @@ namespace System.Management.Automation.Host
/// }
/// }
/// }
/// </snippet>
/// </code>
/// </example>
/// <seealso cref="System.Management.Automation.Host.PSHostRawUserInterface.NewBufferCellArray(int, int, BufferCell)"/>
/// <seealso cref="System.Management.Automation.Host.PSHostRawUserInterface.NewBufferCellArray(Size, BufferCell)"/>

View file

@ -445,7 +445,7 @@ namespace System.Management.Automation.Runspaces
///
/// This flag is used to force the redirection. By default it is false to maintain compatibility with
/// V1, but the V2 hosting interface (PowerShell class) sets this flag to true to ensure the global
/// error output pipe is always set and $ErrorActionPreference when invoking the Pipeline.
/// error output pipe is always set and $ErrorActionPreference is checked when invoking the Pipeline.
/// </summary>
internal bool RedirectShellErrorOutputPipe { get; set; } = false;

View file

@ -1280,7 +1280,42 @@ namespace System.Management.Automation
{
// then pop this pipeline and dispose it...
_context.PopPipelineProcessor(true);
_pipeline.Dispose();
Dispose();
}
}
/// <summary>
/// Clean resources for script commands of this steppable pipeline.
/// </summary>
/// <remarks>
/// The way we handle 'Clean' blocks in a steppable pipeline makes sure that:
/// 1. The 'Clean' blocks get to run if any exception is thrown from 'Begin/Process/End'.
/// 2. The 'Clean' blocks get to run if 'End' finished successfully.
/// However, this is not enough for a steppable pipeline, because the function, where the steppable
/// pipeline gets used, may fail (think about a proxy function). And that may lead to the situation
/// where "no exception was thrown from the steppable pipeline" but "the steppable pipeline didn't
/// run to the end". In that case, 'Clean' won't run unless it's triggered explicitly on the steppable
/// pipeline. This method allows a user to do that from the 'Clean' block of the proxy function.
/// </remarks>
public void Clean()
{
if (_pipeline.Commands is null)
{
// The pipeline commands have been disposed. In this case, 'Clean'
// should have already been called on the pipeline processor.
return;
}
try
{
_context.PushPipelineProcessor(_pipeline);
_pipeline.DoCleanup();
}
finally
{
// then pop this pipeline and dispose it...
_context.PopPipelineProcessor(true);
Dispose();
}
}
@ -1293,23 +1328,13 @@ namespace System.Management.Automation
/// When this object is disposed, the contained pipeline should also be disposed.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool disposing)
{
if (_disposed)
{
return;
}
if (disposing)
{
_pipeline.Dispose();
}
_pipeline.Dispose();
_disposed = true;
}

View file

@ -2026,6 +2026,7 @@ namespace System.Management.Automation.Language
scriptBlock.BeginBlock = CompileTree(_beginBlockLambda, compileInterpretChoice);
scriptBlock.ProcessBlock = CompileTree(_processBlockLambda, compileInterpretChoice);
scriptBlock.EndBlock = CompileTree(_endBlockLambda, compileInterpretChoice);
scriptBlock.CleanBlock = CompileTree(_cleanBlockLambda, compileInterpretChoice);
scriptBlock.LocalsMutableTupleType = LocalVariablesTupleType;
scriptBlock.LocalsMutableTupleCreator = MutableTuple.TupleCreator(LocalVariablesTupleType);
scriptBlock.NameToIndexMap = nameToIndexMap;
@ -2036,6 +2037,7 @@ namespace System.Management.Automation.Language
scriptBlock.UnoptimizedBeginBlock = CompileTree(_beginBlockLambda, compileInterpretChoice);
scriptBlock.UnoptimizedProcessBlock = CompileTree(_processBlockLambda, compileInterpretChoice);
scriptBlock.UnoptimizedEndBlock = CompileTree(_endBlockLambda, compileInterpretChoice);
scriptBlock.UnoptimizedCleanBlock = CompileTree(_cleanBlockLambda, compileInterpretChoice);
scriptBlock.UnoptimizedLocalsMutableTupleType = LocalVariablesTupleType;
scriptBlock.UnoptimizedLocalsMutableTupleCreator = MutableTuple.TupleCreator(LocalVariablesTupleType);
}
@ -2221,6 +2223,7 @@ namespace System.Management.Automation.Language
private Expression<Action<FunctionContext>> _beginBlockLambda;
private Expression<Action<FunctionContext>> _processBlockLambda;
private Expression<Action<FunctionContext>> _endBlockLambda;
private Expression<Action<FunctionContext>> _cleanBlockLambda;
private readonly List<LoopGotoTargets> _loopTargets = new List<LoopGotoTargets>();
private bool _generatingWhileOrDoLoop;
@ -2463,6 +2466,13 @@ namespace System.Management.Automation.Language
}
_endBlockLambda = CompileNamedBlock(scriptBlockAst.EndBlock, funcName, rootForDefiningTypesAndUsings);
rootForDefiningTypesAndUsings = null;
}
if (scriptBlockAst.CleanBlock != null)
{
_cleanBlockLambda = CompileNamedBlock(scriptBlockAst.CleanBlock, funcName + "<Clean>", rootForDefiningTypesAndUsings);
rootForDefiningTypesAndUsings = null;
}
return null;

Some files were not shown because too many files have changed in this diff Show more