This improves the performance of the listener by not relying on a new
process starting up to run the listener. It improves the debugability
of tests by providing more direct access to the session executing
the listener. It also reverses the blocking nature of starting the
listener. By default, Start-HttpListener will no longer block, you need
to use -Foreground to have Start-HttpListener block. Lastly, create
a way to catch errors if the listener has a problem. If code in the
listener throws, it emits an error record.
Fixed tests that were failing or throwing unnecessary information on-screen.
Updated the paths to powershell.exe as per the new artifact layout.
Added Publish-PSTestTools to Compress-TestContent
Added PS Test tools to PSModulePath before starting tests.
Added try/catch within the enumeration loop to allow the enumeration to continue after encountering an error such as an item within the directory being deleted or renamed.
To assist in testing, two new internal test hooks have been added which cause Get-ChildItem to either delete or rename a specific file (file name hard-coded) when encountered during enumeration.
* Fixing ConvertFrom-Json on CoreCLR to be able to handle a collection of strings which represent a JSON content.
* Adding test case for ConvertFrom-Json to process an array of PSObjects as a single string.
* Support Link Header pagination in WebCmdlets to make it easier for the end user implementing:
https://github.com/PowerShell/PowerShell-RFC/blob/master/2-Draft-Accepted/RFC0021-Link-header-based-pagination-for-WebCmdlets.md
When the response includes a Link Header (https://tools.ietf.org/html/rfc5988#page-6), for Invoke-WebRequest we
create a RelationLink property that is a Dictionary representing the URLs and rel attributes and ensure the
URLs are absolute to make it easier for the developer to use. For Invoke-RestMethod, we expose a -FollowRelLink
switch to automatically follow 'next' rel links to the end until we hit the optional -MaxRelLink parameter value.
* removed unnecessary refs to namespaces
* addressed code review feedback
Use the method NativeCommandParameterBinder.NeedQuotes, which is used by powershell native command processor, to check if quotes are needed. If yes, add quotes in the same way as our native command processor.
Also, make 'Invoke-Item' on Linux and OSX able to invoke an executable properly.
Make changes to not expose the aliases "gin", "gsv", "sasv" and "spsv" in Unix platforms.
Also refactored aliases related tests and added new tests covering the complete list of built-in aliases/cmdlets.
The code paths deleted where using the undocumented Win32 APIs on WIn8 and newer for the following purposes:
* Faster filtering
* Getting two properties (left empty on Win7 and below)
* Logging using Certificate components when a cert is deleted or copied.
After the change, all the code uses public APIs. Filtering is done in PowerShell using existing code. I don't believe the logging is needed.
Implements support for backgrounding pipelines with &. Putting & at the end of a pipeline will cause the pipeline
to be run as a PowerShell job. When a pipeline is backgrounded a job object is returned. Once the pipeline is
running as a job, all of the normal job cmdlets can be used to manage the job. Variables (ignoring process-specific
variables) used in the pipeline are automatically copied to the job so
copy $foo $bar &
just works. The job is also run in the current directory instead of the user's home directory as is the case with Start-Job.Implement
* Add autoload for TestHelpers.psm1
Test.Helpers.psm1 was renamed to TestHelpers.psm1
* Resolve conflit and rebase Add autoload for TestLanguage.psm1
* Remove unneeded comments from PSD1 files
* Rename test modules
Remove approved verbs (Get-Verb) from module names.
* Enhance ShouldBeErrorId to output exception into pipeline for later analysis
* Remove unneeded comments
* Resolve merge conflict
The appropriate [SemanticVersion] constructor now accepts a [version] instance that has only major and minor components specified, in which case the patch component now defaults to 0.
Brings the Get-ChildItem more in line with the Unix ls -r and the Windows DIR /S native commands. Like these commands, the cmdlet will display symbolic links to directories found during recursion but will not recurse into them.
Like the Unix ls command---and unlike the Windows DIR /S command--- the cmdlet will recurse into symlinks given on the command line.
`$psversiontable.psversion -gt "3.0"` which is used by PowerShellGet to determine if a module is compatible with the current version of PowerShell.
Change is to allow specifying only major or major+minor where the missing segments default to zero by providing overloaded constructors and allow
the string parsing method to not require major, minor, and patch segments to all be specified (only major is required).
Based on the [response](https://github.com/mojombo/semver/issues/368) from the maintainer of semver, there is no requirement to have strict
conformance for the inputs to the constructor and allowing "3.0" to result in a semver of 3.0.0 is reasonable.
when automating test execution, some environments don't have a tty which causes
the tests to fail. df is just as good a test as stty as it is also guaranteed to be
present. This change also allows the tests to be run on OSX
* Fix Rename-Item to allow Unix globbing patterns in -Literal paths (#2799)
In the process of normalizing a relative path, PowerShell checks to see
see if the path exists, which it does by invoking
Directory.EnumerateFiles(directory, filename);
On Unix platforms, if the filename contains globbing patterns, such as [ab],
EnumerateFiles (and EnumerateDirectories) will perform the globbing. Using
globbing patterns, a file named 'file[txt].txt' is reported as not existing.
This fix changes the file-existence test on Unix to use a native function
instead of either of the Directory.EnumerateXXX functions.
* Fix for AppVeyor failure
* Changes per code review, and a couple of letter-casing changes.
This change enables globbing (wildcard expansion) against the file system for native commands like '/bin/ls'. The expansion is only done in the file system. In non-filesystem drives expansion is not done and the pattern is returned unchanged.
Limitations of the fix:
Currently quoting is not honored so for a command like /bin/ls "*.txt", wildcard expansion will still be done. Adding support for bare word detection will come in a future PR. Use --% to suppress wildcard expansion e.g. git add --% *
This fixes issue #2607.
'RequiredModules' is a field in module manifest that can reference other modules using ModuleSpecification format.
The basic version of this format (just module name) was working fine, however, there was a problem when a more detailed version of the format was used (the one that uses module versions or/and GUIDs).
During module import, there is a check for cyclic references through 'RequiredModules' field. The bug was in this check for cyclic references, related to comparison rules for ModuleSpecification objects - as a result, the code was incorrectly reporting 'cyclic reference' error in cases when there was none.
Also, added tests for different ModuleSpecification formats and a test for error when there is actually a cyclic reference.
When 'Remove-Item' is used to remove a symbolic link in Windows, only the link itself is removed. The '-Force' switch is no longer required.
If the directory pointed to by the link has child items, the cmdlet no longer prompts the user to remove the child items---those child items are not removed. The '-Recurse' switch, if given, is ignored.
This brings 'Remove-Item' more in line with the behavior of the 'rm' command on Unix.
* fixes summary block typo
* Adds support for Port parameter for SSH PSSessions
* Reverted back to master, modified based on PR feedback
* Update exception message
* remove unused line
* Add existing constructor back in as to not break public contract
* remove port check
* pass nested inner exception straight to Should
* dispose runspace after each test
* Add SSHHostParameterSet attribute for Invoke-Command Port property
* Update ParseSSHConnectionHashTable method to accept Port value as integer
* Add helper method for validating port in range. Refactor port parameter constructor overload to use original constructor
* rename method
* Adds GetSSHConnectionStringParameter and GetSSHConnectionIntParameter methods for retrieving SSHConnection hashtable values
* Adds method comments
* Adds helper method comment
* Change methods to add C# 7 patterns
string. If the string was a uri with spaces, ToString() doesn't return the escaped version. The AbsoluteUri property
should be used instead which returns an escaped absolute uri (if valid).
Also renamed TestModuleManfest.ps1 to TestModuleManifest.Tests.ps1 so that it gets picked up correctly as Pester test.
Since HelpInfoUri is just a string, ensure it is a valid absolute uri and escaped correctly whereas before it was just
an opaque string that wasn't validated.
* Add dockerfile and test so we can test simple remoting behaviors
this docker file creates an image which can be used to test remoting with containers.
We start with the microsoft/windowsservercore image and then set up the system for
testing by adding a user, setting up configuration for basic auth, installing
PowerShell Core, and creating a configuration endpoint for PSCore.
The tests are very simple; it retrieve $PSVersionTable.PSVersion in the following
connections:
Full -> Full
Full -> Core
Core -> Full
Core -> Core
* Add new file to bootstrap the docker image
fix the tests to be more resilient to changes in the version of the PSCore package
* update script to use local user cmdlets rather than net.exe
also remove pscore.msi at the end of the image build process to save space
* clean up commented lines and remove an unused parameter from one of the functions
also use constants more consistently
* remove reference to docker image name by string and use variable instead.
Rather than relying on case-insensitive string compares of source and destination paths, use operating system calls to determine whether two paths refer to the same file. This solves not only the case-insensitivity issue but also allows the cmdlet to operate properly if the destination is a hard or symbolic link to the source.
The Windows side is implemented in C#. The Unix side is implemented partially in native code.
This makes it possibe to write for example
[ValidatePattern('[A-Z]:', ErrorMessage='The Drive should be specified as a single letter followed by a colon, for example "D:"')]
[string] $Drive,
The element being validated is also passed, so {0} can be used in the custom error message
This change moves powershell to .NET Core 2.0. Major changes are:
1. PowerShell assemblies are now targeting `netcoreapp2.0`. We are using `microsoft.netcore.app-2.0.0-preview1-001913-00`, which is from dotnet-core build 4/4/17. We cannot target `netstandard2.0` because the packages `System.Reflection.Emit` and `System.Reflection.Emit.Lightweight`, which are needed for powershell class, cannot be referenced when targeting `netstandard2.0`.
2. Refactor code to remove most CLR stub types and extension types.
3. Update build scripts to enable CI builds. The `-cache` section is specified to depend on `appveyor.yml`, so the cache will be invalidated if `appveyor.yml` is changed.
4. Ship `netcoreapp` reference assemblies with powershell to fix the issues in `Add-Type` (#2764). By default `Add-Type` will reference all those reference assemblies when compiling C# code. If `-ReferenceAssembly` is specified, then we search reference assemblies first, then the framework runtime assemblies, and lastly the loaded assemblies (possibly a third-party one that was already loaded).
5. `dotnet publish` generates executable on Unix platforms, but doesn't set "x" permission and thus it cannot execute. Currently, the "x" permission is set in the build script, `dotnet/cli` issue [#6286](https://github.com/dotnet/cli/issues/6286) is tracking this.
6. Replace the use of some APIs with the ones that take `SecureString`.
7. osx.10.12 is required to update to `netcoreapp2.0` because `dotnet-cli` 2.0.0-preview only works on osx.10.12.
8. Add dependency to `System.ValueTuple` to work around a ambiguous type identity issue in coreclr. The issue is tracked by `dotnet/corefx` [#17797](https://github.com/dotnet/corefx/issues/17797). When moving to newer version of `netcoreapp2.0`, we need to verify if this dependency is still needed.
Now `New-Item` can create a file symlink to a file target or to a non-existent target. It can also create a directory symlink to a directory target on Windows.
On Unix, it is a convention for shells to accept `-i` for an interactive shell and many
tools expect this behavior (`script` for example, and when setting powershell as the
default shell) and calls the shell with the `-i` switch. This change is breaking in
that `-i` previously could be used as short hand to match `-inputformat` which now will
need to be `-in`.
There are cases like using PowerShell via Puppet where the account being
used does not have a home directory. Updated PowerShell to use a process
specific temporary directory if HOME, CONFIG, CACHE, and DATA directories
are not available. Temporary directory is removed when last runspace
is disposed.
- Removed the -TimeoutSec option and modified the expected Error to be consistent across platforms.
- Changed the port of the phony proxy to 9 which is reserved for the Discard Protocol. So even if the system is listening, it's supposed to discard that TCP request (UDP may use it for Wake-on-Lan, but doesn't affect this).
* Help was incorrectly returning multiple instances of the same help file if it existed under a culture path and the parent was in the search path as well
* updated test to use generated help file rather than an actual one
* Fixed test to have module in $pshome path and casing of en-US culture
Related #3238
1. Add autoload for test modules
2. Move TestHostCS.psm1 to 'test\tools\Modules\' folder
3. Remove explicit load TestHostCS.psm1 from test files
- FullCLR build is disabled in this change.
- FullCLR build related functionalities in `build.psm1` and `AppVeyor.psm1` are disabled. They are not cleaned up from `build.psm1` and `AppVeyor.psm1` yet. We need to adopt .NET Core 2.0 to verify the portable module concept, and if that works well, we will remove the Windows PowerShell source code and clean up our scripts.
- `dnxcore50` and `portable-net5+win8` target framework monikers are removed.
- Dependency on `Microsoft.NETCore.Portable.Compatibility` is removed. It's not necessary, but it may come back when we work on supporting the `portable module`. Its necessity can be reviewed at that time.
- I didn't spend the time to try building powershell in Visual Studio 2017. We should have a separate issue for that. It's tracked by #3400
The `TypeCatalogParser` project is replaced by a MSBuild target to gather the dependency information.
Due to .NET Core SDK issue [#1021](https://github.com/dotnet/sdk/issues/1021), our meta-package project `Microsoft.PowerShell.SDK` starts to generate an empty assembly during the build and that results in an empty assembly `Microsoft.PowerShell.SDK.dll` appear in `publish` folder and in `.deps.json` file. We cannot simply remove the assembly because it's now part of the TPA, and removing it will cause powershell to crash at startup. We have to live with this empty assembly until that .NET Core SDK issue is fixed. It's tracked by #3401.
* Make Get-ComputerInfo tests handle the case of the root\Microsoft\Windows\DeviceGuard namespace not found on the test machine.
Catch CIM exceptions, but don't look specifically for namespace-not-found
* Update Get-ComputerInfo test to properly test DeviceGuard items.
Our assembly cache contains assemblies that are explicitly loaded by powershell egine, such as via module loading or the assembly entries from InitialSessionState. We should search it before searching all loaded assemblies to give preference to resolve a type against the assemblies contained in the cache, so that in case there is a conflict, we might have a preferred assembly to use for a type resolution.
Changes:
- Search from context.AssemblyCache.Values before search from all loaded assemblies.
- Skip assemblies that we already searched and found no matching type.
- Skip checking PS types kept in the scope and type accelerators when it's not necessary.
* PowerShell transcripts should include the configuration name in the transcript header
* adding test case for PowerShell transcripts should include the configuration name in the transcript header #2890
* corrected use of PSModulePath casing to be consistent with Windows PowerShell
addresses #3227
* addressing review feedback
make "PSModulePath" into const
fixed some test workarounds due to failures for external reasons that wasn't meant to be checked in
* addressing review feedback
make "PSModulePath" into const
fixed some test workarounds due to failures for external reasons that wasn't meant to be checked in
* Refactoring ParsePathCommand.cs (SplitPathCommand) for readability
- Using auto properties when no when there is no logic in getter/setter
- Removing unused code
- Removing redundant qualifiers
- Removing Redundant initializers
* Add -Extension and -Leafbase switches to Split-Path cmdlet
- Extension and LeafBase are specializations of Leaf, and uses System.IO.Path.GetExtension and System.IO.Path.GetFilenameWithoutExtension to extract parts from the Leaf
* Adding tests for Split-Path -LeafBase and Split-Path -Extension
Resolving #3242
At this point, user account is created even if user attributes assignment
(like setting password) fails. The cmdlet throws a
non-terminating error but ends up creating the user. This behavior is
confusing. As per the changes, the localuser account will be rolled back
in case of failure in user attributes assignment.
Two updates with this PR:
- reclassified automounted drives tests to be 'Feature' instead of 'CI' because this is more accurate;
- fixed failures in tests setup caused by "subst.exe" native utility having problems running as child process of powershell process tree run under "runas.exe /trustlevel:0x20000" (in Start-UnelevatedProcess in build.psm1).