Merge remote-tracking branch 'origin/master' into SetVariablePesterUnitTest

This commit is contained in:
JumpingYang001 committed 2016-04-13 22:39:31 -07:00
commit 60c3b58f9e
42 files changed
+1060 -766

No files matched your search

-7
View File
@@ -1,10 +1,3 @@
[submodule "src/omi"]
path = src/omi
url = https://github.com/Microsoft/omi.git
branch = psrp/features
[submodule "src/omi-provider"]
path = src/omi-provider
url = https://github.com/PowerShell/psl-omi-provider.git
[submodule "src/windows-build"]
path = src/windows-build
url = https://github.com/PowerShell/psl-windows-build.git
+9 -5
View File
@@ -1,16 +1,20 @@
language: cpp
sudo: required
dist: trusty
matrix:
include:
- os: linux
dist: trusty
sudo: required
# - os: osx
# language: generic
# env: PATH+=/usr/local/share/dotnet
git:
submodules: false
before_install:
- git config --global url.git@github.com:.insteadOf https://github.com/
- git submodule update --init -- src/windows-build src/Modules/Pester src/libpsl-native/test/googletest
- ./bootstrap.sh
- ./download.sh
- sudo dpkg -i ./powershell.deb
script:
- powershell -c "Import-Module ./PowerShellGitHubDev.psm1; Start-PSBuild; Start-PSxUnit; Start-PSPester"
- powershell -c "Import-Module ./PowerShellGitHubDev.psm1; Start-PSBootstrap; Start-PSBuild; Start-PSPester"
notifications:
slack:
secure: sKYd4n61+ZFzGZuWGUl8V1kN0NM16wRVOFVlNhlFCwnkrEsKROb++EvXf5uwnKuzxkhEjvPWO+UFgeshQDoR93y4s5YLfhC5JupK4nUzjPzWs208KTrh8u/x9MY8X6Ojxi85EEAiku5GzMoMlkucSStZUYwbIfnelzqdw8uoRwmm2MW4XCPwsuEuDUVghyiva0Mdx1G6MopCrK8T96WywJXT3chhfZQgVt+sQCBt9g+2kjDaObKrzG0P07IVK43ZpDgnu6AoxlyBzIx9mJH2Oa/tki3/kTO72Wcp3ps3qvmiStADamzVKR9p1VlWCLWAd6VOehxuByCGEyujpzk135Wud2DZYO+8LD6inZVhFe3Wt5pCU9BDXZppiATfMCqgXEH7nK54pEn79yHcjthRJ2+Z9ot7As2fu3RSBmTAi8nRP0fxRyX/jctR3S6P0qt0y1ynx9nzBfhmhPQW0PMVazWS/nruQIvK/3iiYXjZxM5bBwIvabmwV00EYeTdbL6ufXWNgQcG1ZWkDsi2I3vst/ytUbHwaFYg83bXWpxg9DCzJeWLVUvE5/3NfBxRAuCTot/fgTEA9IYScvrlL7Q/bT0cOt0vEM98MPf1UO+WP85uxhsRgHtwDEo+jMaL6ZFkPhlV6mmmED4NdY2//a571cLNXdnuMAze5O3TWGBG53g=
+132 -41
View File
@@ -23,6 +23,7 @@ try {
function Start-PSBuild {
[CmdletBinding(DefaultParameterSetName='CoreCLR')]
param(
[switch]$NoPath,
[switch]$Restore,
[Parameter(ParameterSetName='CoreCLR')]
@@ -57,6 +58,15 @@ function Start-PSBuild {
$FullCLR = $true
}
if (-not $NoPath) {
Write-Verbose "Appending probable .NET CLI tool path"
if ($IsWindows) {
$env:Path += ";$env:LocalAppData\Microsoft\dotnet\cli"
} elseif ($IsOSX) {
$env:PATH += ":/usr/local/share/dotnet"
}
}
# verify we have all tools in place to do the build
$precheck = precheck 'dotnet' "Build dependency 'dotnet' not found in PATH! See: https://dotnet.github.io/getting-started/"
if ($FullCLR) {
@@ -65,12 +75,13 @@ function Start-PSBuild {
# msbuild is needed to build powershell.exe
# msbuild is part of .NET Framework, we can try to get it from well-known location.
if (-not (Get-Command -Name msbuild -ErrorAction Ignore)) {
if (-nopt $NoPath -and -not (Get-Command -Name msbuild -ErrorAction Ignore)) {
Write-Verbose "Appending probable Visual C++ tools path"
$env:path += ";${env:SystemRoot}\Microsoft.Net\Framework\v4.0.30319"
}
$precheck = $precheck -and (precheck 'msbuild' 'msbuild not found. Install Visual Studio 2015.')
} elseif ($IsLinux -Or $IsOSX) {
} elseif ($IsLinux -or $IsOSX) {
$InstallCommand = if ($IsLinux) {
'apt-get'
} elseif ($IsOSX) {
@@ -82,14 +93,14 @@ function Start-PSBuild {
}
}
if (-Not $Runtime) {
if (-not $Runtime) {
$Runtime = dotnet --info | % {
if ($_ -match "RID") {
$_ -split "\s+" | Select-Object -Last 1
}
}
if (-Not $Runtime) {
if (-not $Runtime) {
Write-Warning "Could not determine Runtime Identifier, please update dotnet"
$precheck = $false
} else {
@@ -111,7 +122,7 @@ function Start-PSBuild {
$Framework = 'netstandardapp1.5'
}
if ($IsLinux -Or $IsOSX) {
if ($IsLinux -or $IsOSX) {
$Configuration = "Linux"
$Executable = "powershell"
} else {
@@ -132,7 +143,7 @@ function Start-PSBuild {
# Build the Output path in script scope
$script:Output = [IO.Path]::Combine($Top, "bin", $Configuration, $Framework)
# FullCLR only builds a library, so there is no runtime component
if (-Not $FullCLR) {
if (-not $FullCLR) {
$script:Output = [IO.Path]::Combine($script:Output, $Runtime)
}
# Publish injects the publish directory
@@ -144,7 +155,7 @@ function Start-PSBuild {
Write-Verbose "script:Output is $script:Output"
# handle Restore
if ($Restore -Or -Not (Test-Path "$Top/project.lock.json")) {
if ($Restore -or -not (Test-Path "$Top/project.lock.json")) {
log "Run dotnet restore"
$RestoreArguments = @("--verbosity")
@@ -160,7 +171,7 @@ function Start-PSBuild {
}
# Build native components
if ($IsLinux -Or $IsOSX) {
if ($IsLinux -or $IsOSX) {
$Ext = if ($IsLinux) {
"so"
} elseif ($IsOSX) {
@@ -180,7 +191,7 @@ function Start-PSBuild {
Pop-Location
}
if (-Not (Test-Path $Lib)) {
if (-not (Test-Path $Lib)) {
throw "Compilation of $Lib failed"
}
} elseif ($FullCLR) {
@@ -217,7 +228,7 @@ function Start-PSBuild {
function Get-PSOutput {
[CmdletBinding()]param()
if (-Not $Output) {
if (-not $Output) {
throw '$script:Output is not defined, run Start-PSBuild'
}
@@ -261,38 +272,112 @@ function Start-PSxUnit {
}
}
function Start-PSBootstrap {
[CmdletBinding()]param()
Write-Host "Installing Open PowerShell build dependencies"
if ($IsLinux) {
precheck 'curl' "Bootstrap dependency 'curl' not found in PATH, please install!" > $null
precheck 'apt-get' "Bootstrap dependency 'apt-get' not found in PATH, this only supports Ubuntu 14.04!" > $null
# Setup LLVM feed
curl -s http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add -
echo "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.6 main" | sudo tee /etc/apt/sources.list.d/llvm.list
sudo apt-get update -qq
# Install ours and .NET's dependencies
sudo apt-get install -y make g++ cmake libc6 libgcc1 libstdc++6 libcurl3 libgssapi-krb5-2 libicu52 liblldb-3.6 liblttng-ust0 libssl1.0.0 libunwind8 libuuid1 zlib1g clang-3.5
# Install .NET CLI packages
Remove-Item dotnet*.deb
wget https://dotnetcli.blob.core.windows.net/dotnet/beta/Installers/Latest/dotnet-host-ubuntu-x64.latest.deb
sudo dpkg -i dotnet-host-ubuntu-x64.latest.deb
wget https://dotnetcli.blob.core.windows.net/dotnet/beta/Installers/Latest/dotnet-sharedframework-ubuntu-x64.latest.deb
sudo dpkg -i dotnet-sharedframework-ubuntu-x64.latest.deb
wget https://dotnetcli.blob.core.windows.net/dotnet/beta/Installers/Latest/dotnet-sdk-ubuntu-x64.latest.deb
sudo dpkg -i dotnet-sdk-ubuntu-x64.latest.deb
} elseif ($IsOSX) {
precheck 'brew' "Bootstrap dependency 'brew' not found, must install Homebrew! See http://brew.sh/"
# Install ours and .NET's dependencies
brew install cmake wget openssl
# Install .NET CLI packages
Remove-Item dotnet*.pkg
wget https://dotnetcli.blob.core.windows.net/dotnet/beta/Installers/Latest/dotnet-dev-osx-x64.latest.pkg
sudo installer -pkg dotnet-dev-osx-x64.latest.pkg -target /
} elseif ($IsWindows -And -Not $IsCore) {
Invoke-WebRequest -Uri https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/install.ps1 -OutFile install.ps1
./install.ps1
} else {
Write-Warning "Start-PSBootstrap cannot be run in Core PowerShell on Windows (need Invoke-WebRequest!)"
}
}
function Start-PSPackage {
# PowerShell packages use Semantic Versioning http://semver.org/
#
# Ubuntu and OS X packages are supported.
[CmdletBinding()]param(
# PowerShell packages use Semantic Versioning http://semver.org/
[string]$Version,
# Package iteration version (rarely changed)
[int]$Iteration = 1,
# Ubuntu, CentOS, and OS X packages are supported
[ValidateSet("deb", "osxpkg", "rpm")]
[string]$Type
)
$Description = @"
Open PowerShell on .NET Core
PowerShell is an open-source, cross-platform, scripting language and rich object shell.
Built upon .NET Core, it is also a C# REPL.
"@
if ($IsWindows) { throw "Building Windows packages is not yet supported!" }
if (-Not (Get-Command "fpm" -ErrorAction SilentlyContinue)) {
if (-not (Get-Command "fpm" -ErrorAction SilentlyContinue)) {
throw "Build dependency 'fpm' not found in PATH! See: https://github.com/jordansissel/fpm"
}
if (-Not(Test-Path "$PSScriptRoot/bin/powershell")) {
throw "Please Start-PSBuild with the corresponding runtime for the package"
$Source = Split-Path -Parent (Get-PSOutput)
if ((Split-Path -Leaf $Source) -ne "publish") {
throw "Please Start-PSBuild -Package with the corresponding runtime for the package"
}
# Change permissions for packaging
chmod -R go=u "$PSScriptRoot/bin"
# Decide package output type
if (-Not($Type)) {
if (-not $Type) {
$Type = if ($IsLinux) { "deb" } elseif ($IsOSX) { "osxpkg" }
Write-Warning "-Type was not specified, continuing with $Type"
}
# Follow the Filesystem Hierarchy Standard for Linux and OS X
$Destination = if ($IsLinux) {
"/opt/microsoft/powershell"
} elseif ($IsOSX) {
"/usr/local/microsoft/powershell"
}
# Destination for symlink to powershell executable
$Link = if ($IsLinux) {
"/usr/bin"
} elseif ($IsOSX) {
"/usr/local/bin"
}
New-Item -Force -ItemType SymbolicLink -Path /tmp/powershell -Target $Destination/powershell >$null
# Change permissions for packaging
chmod -R go=u $Source /tmp/powershell
# Use Git tag if not given a version
if (-Not($Version)) {
if (-not $Version) {
$Version = (git --git-dir="$PSScriptRoot/.git" describe) -Replace '^v'
}
@@ -306,26 +391,32 @@ function Start-PSPackage {
"rpm" { "libicu" }
}
$Arguments = @(
"--force", "--verbose",
"--name", "powershell",
"--version", $Version,
"--iteration", $Iteration,
"--maintainer", "Andrew Schwartzmeyer <andschwa@microsoft.com>",
"--vendor", "Microsoft <mageng@microsoft.com>",
"--url", "https://github.com/PowerShell/PowerShell",
"--license", "Unlicensed",
"--description", $Description,
"--category", "shells",
"--rpm-os", "linux",
"--depends", $libunwind,
"--depends", $libicu,
"--deb-build-depends", "dotnet",
"--deb-build-depends", "cmake",
"--deb-build-depends", "g++",
"-t", $Type,
"-s", "dir",
"$Source/=$Destination/",
"/tmp/powershell=$Link"
)
# Build package
fpm --force --verbose `
--name "powershell" `
--version $Version `
--iteration $Iteration `
--maintainer "Andrew Schwartzmeyer <andschwa@microsoft.com>" `
--vendor "Microsoft <mageng@microsoft.com>" `
--url "https://github.com/PowerShell/PowerShell" `
--license "Unlicensed" `
--description "Open PowerShell on .NET Core\nPowerShell is an open-source, cross-platform, scripting language and rich object shell. Built upon .NET Core, it is also a C# REPL.\n" `
--category "shells" `
--depends $libunwind `
--depends $libicu `
--deb-build-depends "dotnet" `
--deb-build-depends "cmake" `
--deb-build-depends "g++" `
-t $Type `
-s dir `
"$PSScriptRoot/bin/=/usr/local/share/powershell/" `
"$PSScriptRoot/package/powershell=/usr/local/bin"
fpm $Arguments
}
@@ -348,7 +439,7 @@ function Start-DevPSGitHub {
$env:COMPLUS_ZapDisable = 1
}
if (-Not (Test-Path $binDir\powershell.exe.config)) {
if (-not (Test-Path $binDir\powershell.exe.config)) {
$configContents = @"
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
+31 -4
View File
@@ -26,7 +26,7 @@ Get PowerShell
| | Linux | Windows .NET Core | Windows .NET Full | OS X | PSRP |
|-----------------------|-------|-------------------|-------------------|------|------|
| Build from **Source** | [Instructions](docs/building/linux.md) | [Instructions](docs/building/windows-core.md) | [Instructions](docs/building/windows-full.md) | [Instructions](docs/building/osx.md) | [Instructions](docs/building/psrp.md) |
| Build from **Source** | [Instructions](docs/building/linux.md) | [Instructions](docs/building/windows-core.md) | [Instructions](docs/building/windows-full.md) | [Instructions](docs/building/osx.md) | [Instructions][psrp] |
| Get **Binaries** | [Releases][] | [Artifacts][] | [Artifacts][] | [Releases][] | TBD |
Building summary: `Start-PSBuild` from the module
@@ -38,6 +38,7 @@ instructions.
[releases]: https://github.com/PowerShell/PowerShell/releases
[artifacts]: https://ci.appveyor.com/project/PowerShell/powershell-linux/build/artifacts
[psrp]: https://github.com/PowerShell/psl-omi-provider
Team coordination
-----------------
@@ -67,6 +68,32 @@ rules, and Git best practices.
Clone this repository. It is a "superproject" and has a number of
other repositories embedded within it as submodules. *Please* see the
contributing guidelines and learn about submodules. Not every
submodule is required on every system; see the individual build
instructions for the necessary subsets.
contributing guidelines and learn about submodules. To make things
easy, we can just clone recursively.
```sh
git clone --recursive https://github.com/PowerShell/PowerShell.git
```
You can verify that the submodules were initialized properly with:
```sh
git submodule status
```
If they're initialized, it will look like this:
```
f23641488f8d7bf8630ca3496e61562aa3a64009 src/Modules/Pester (f23641488)
c99458533a9b4c743ed51537e25989ea55944908 src/libpsl-native/test/googletest (release-1.7.0)
e6bf85694ae8352d77175c4c7d304946e018808c src/windows-build (monad/cc6afbeb-3/31)
```
If they're not, there will be minuses in front (and the folders will
be empty):
```
-f23641488f8d7bf8630ca3496e61562aa3a64009 src/Modules/Pester (f23641488)
-c99458533a9b4c743ed51537e25989ea55944908 src/libpsl-native/test/googletest (release-1.7.0)
-e6bf85694ae8352d77175c4c7d304946e018808c src/windows-build (monad/cc6afbeb-3/31)
```
+1 -4
View File
@@ -18,13 +18,10 @@ install:
- ps: Set-Content c:\users\appveyor\.ssh\id_rsa $fileContent
- git config --global url.git@github.com:.insteadOf https://github.com/
- git submodule update --init -- src/windows-build src/Modules/Pester
- ps: Invoke-WebRequest -Uri https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/install.ps1 -OutFile install.ps1
- ps: ./install.ps1 -version 1.0.0-beta-002198
- ps: Import-Module .\PowerShellGitHubDev.psm1; Start-PSBootstrap
build_script:
- ps: |
$env:Path += ";$env:LocalAppData\Microsoft\dotnet\cli"
dotnet --version
Import-Module .\PowerShellGitHubDev.psm1
Start-PSBuild -Publish
Start-PSBuild -FullCLR
-20
View File
@@ -1,20 +0,0 @@
#!/usr/bin/env bash
echo "Installing build dependencies"
curl http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add -
echo "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.6 main" | sudo tee /etc/apt/sources.list.d/llvm.list
sudo apt-get update -qq
sudo apt-get install -y wget make g++ cmake \
libc6 libgcc1 libstdc++6 \
libcurl3 libgssapi-krb5-2 libicu52 liblldb-3.6 liblttng-ust0 libssl1.0.0 libunwind8 libuuid1 zlib1g clang-3.5
wget -P /tmp https://dotnetcli.blob.core.windows.net/dotnet/beta/Installers/Latest/dotnet-host-ubuntu-x64.latest.deb
sudo dpkg -i /tmp/dotnet-host-ubuntu-x64.latest.deb
wget -P /tmp https://dotnetcli.blob.core.windows.net/dotnet/beta/Installers/Latest/dotnet-sharedframework-ubuntu-x64.latest.deb
sudo dpkg -i /tmp/dotnet-sharedframework-ubuntu-x64.latest.deb
wget -P /tmp https://dotnetcli.blob.core.windows.net/dotnet/beta/Installers/Latest/dotnet-sdk-ubuntu-x64.latest.deb
sudo dpkg -i /tmp/dotnet-sdk-ubuntu-x64.latest.deb
+1 -1
View File
@@ -2,7 +2,7 @@
if hash powershell 2>/dev/null; then
echo 'Continuing with `powershell -c Start-PSBuild`'
powershell -c Start-PSBuild
powershell -c "Import-Module ./PowerShellGitHubDev.psm1; Start-PSBuild"
else
echo 'No `powershell`, see docs/building/linux.md or osx.md to build PowerShell!'
fi
+46 -39
View File
@@ -10,6 +10,16 @@ Environment
These instructions are written assuming the Ubuntu 14.04 LTS, since
that's the distro the team uses.
Git Setup
---------
Using Git requires it to be setup correctly; refer to the
[README](../../README.md) and
[Contributing Guidelines](../../CONTRIBUTING.md).
This guide assumes that you have recursively cloned the PowerShell
repository and `cd`ed into it.
Toolchain Setup
---------------
@@ -26,16 +36,46 @@ Unfortunately, the `apt-get` feed for `dotnet` has been deprecated,
and the latest version is only distributed in the form of three
separate packages, which require manual dependency resolution.
**To ease this process, just run `./bootstrap.sh` and enter password
for `sudo` when prompted.**
Installing the toolchain is as easy as running `Start-PSBootstrap` in
PowerShell. Of course, this requires a self-hosted copy of PowerShell
on Linux.
The [bootstrap script](../../bootstrap.sh) does the following:
Fortunately, this is as easy as downloading and installing the
package. Unfortunately, while the repository is still private, the
package cannot be downloaded as simply as with `wget`. We have a
script that wraps the GitHub API and uses a personal access token to
authorize in order to obtain the package.
The `./download.sh` script will also install the PowerShell package.
> You can alternativelly download via a browser, upload it to your
> box via some other method, and manually install it.
In Bash:
```sh
GITHUB_TOKEN=<replace with your token> ./download.sh
powershell
```
You should now be in a `powershell` console host that is installed
separately from any development copy you're about to build. Just
import our module, bootsrap the dependencies, and build!
In PowerShell:
```powershell
Import-Module ./PowerShellGitHubDev.psm1
Start-PSBootstrap
```
The `Start-PSBootstrap` function does the following:
- Adds the LLVM package feed
- Installs our dependencies combined with the dependencies of the .NET
CLI toolchain via `apt-get`
- Installs the .NET CLI host, shared framework, and SDK by downloading
the three `.deb` packages to `/tmp` and using `dpkg -i`
the three `.deb` packages and using `dpkg -i`
[dotnet-cli]: https://github.com/dotnet/cli#new-to-net-cli
[CMake]: https://cmake.org/cmake/help/v2.8.12/cmake.html
@@ -55,44 +95,13 @@ uninstall prior any prior versions.
[cli-docs]: https://dotnet.github.io/getting-started/
Git Setup
---------
Using Git requires it to be setup correctly; refer to the
[Contributing Guidelines](../../CONTRIBUTING.md).
Please clone the superproject (this repo) and initialize a subset of
the submodules:
```sh
git clone https://github.com/PowerShell/PowerShell.git
cd PowerShell
git submodule update --init -- src/windows-build src/Modules/Pester src/libpsl-native/test/googletest
```
Build using our module
======================
We maintain a [PowerShell module](../../PowerShellGitHubDev.psm1) with
the function `Start-PSBuild` to build PowerShell. Since this is
PowerShell code, it requires self-hosting. Fortunately, this is as
easy as downloading and installing the package. Unfortunately, while
the repository is still private, the package cannot be downloaded as
simply as with `wget`. We have a script that wraps the GitHub API and
uses a personal access token to authorize and obtain the package.
> You can alternativelly download via a browser and upload it to your
> box via some other method.
```sh
GITHUB_TOKEN=<replace with your token> ./download.sh
sudo dpkg -i ./powershell.deb
powershell
```
You should now be in a `powershell` console host that is installed
separately from any development copy you're about to build. Just
import our module and build!
PowerShell code, it requires self-hosting. If you have followed the
toolchain setup section above, you should have `powershell` installed.
> If you cannot or do not want to self-host, `Start-PSBuild` is just a
> convenience; you can execute each step of the build process yourself
@@ -107,8 +116,6 @@ Congratulations! If everything went right, PowerShell is now built.
The `Start-PSBuild` script will output the location of the executable:
`./src/Microsoft.PowerShell.CoreConsoleHost/bin/Linux/netstandardapp1.5/ubuntu.14.04-x64/powershell`.
> Note that the `./build.sh` script is deprecated and will be removed
You can run our cross-platform Pester tests with `Start-PSPester`, and
our xUnit tests with `Start-PSxUnit`.
+10 -13
View File
@@ -11,22 +11,19 @@ Environment
===========
You will want [Homebrew](http://brew.sh/), the missing package manager
for OS X. Once installed, use `brew` to install the following
dependencies.
for OS X. Once installed, follow the same instructions to download and
install a self-hosted copy of PowerShell on your OS X machine, and use
`Start-PSBootstrap` to install the dependencies.
```sh
brew install openssl cmake wget
```
The `Start-PSBootstrap` function does the following:
Instead of using Linux `./bootstrap.sh` to install .NET CLI's Ubuntu
packages, you will want to use the official PKG installer for OS X.
- Uses `brew` to install CMake, OpenSSL, and GNU WGet
- Downloads and installs the latest .NET CLI package
- Adds `/usr/local/share/dotnet` to the process path
```sh
wget https://dotnetcli.blob.core.windows.net/dotnet/beta/Installers/Latest/dotnet-dev-osx-x64.latest.pkg
open ./dotnet-dev-osx-x64.latest.pkg
```
Then follow the wizard's instructions to complete installation.
Please heed that last step. You may want to add the .NET CLI tool
location to your path more permanently by adding it to your shell's
profile.
Build using our module
======================
-106
View File
@@ -1,106 +0,0 @@
PowerShell Remoting Protocol
============================
This guide supplements the [Linux instructions](./linux.md), as
building PowerShell Remoting Protocol (PSRP) support first requires
PowerShell on Linux built.
PSRP communication is tunneled through the Open Management
Infrastructure (OMI) using the [OMI provider][].
> PSRP has been observed working on OS X, but the changes made to OMI to
> accomplish this are not even beta-ready and need to be done correctly. They
> exist on the `andschwa-osx` branch of the OMI repository.
[OMI provider]: https://github.com/PowerShell/psl-omi-provider/
Environment
===========
Toolchain Setup
---------------
PSRP requires the following additional packages:
```sh
sudo apt-get install libpam0g-dev libssl-dev libcurl4-openssl-dev libboost-filesystem-dev
```
Git Setup
---------
Two additional submodules need to be initialized:
```sh
git submodule update --init -- src/omi src/omi-provider
```
The `src/omi` submodule requires your GitHub user to have joined the
Microsoft organization. If it fails to check out, Git will give up and
not check out further submodules either. Please follow the
instructions on the [Open Source Hub][].
[Open Source Hub]: https://opensourcehub.microsoft.com/articles/how-to-join-microsoft-github-org-self-service
Building
========
Run `./omibuild.sh` to build OMI and the provider.
This script first builds OMI in developer mode:
```sh
pushd src/omi/Unix
./configure --dev
make -j
popd
```
Then it builds and registers the provider:
```sh
pushd src/omi-provider
cmake -DCMAKE_BUILD_TYPE=Debug .
make -j
popd
```
The provider maintains its own native host library to initialize the
CLR, but there are plans to refactor .NET's packaged host as a shared
library.
Running
-------
Some initial setup on Windows is required. Open an administrative command
prompt and execute the following:
```cmd
winrm set winrm/config/Client @{AllowUnencrypted="true"}
winrm set winrm/config/Client @{TrustedHosts="*"}
```
> You can also set the `TrustedHosts` to include the target's IP address.
Then on Linux, launch `omiserver` (after building with the
instructions above):
```sh
./psrp.sh
```
Now in a PowerShell prompt on Windows (opened after setting the WinRM client
configurations):
```powershell
Enter-PSSession -ComputerName <IP address of Linux machine> -Credential $cred -Authentication basic
```
> The `$cred` variable can be empty; a credentials prompt will appear, enter
> any fake credentials you wish as authentication is not yet implemented.
The IP address of the Linux machine can be obtained with:
```sh
ip -f inet addr show dev eth0
```
+20 -19
View File
@@ -11,17 +11,33 @@ Environment
These instructions are tested on Windows 10 and Windows Server 2012
R2, though they should work anywhere the dependencies work.
Git Setup
---------
Using Git requires it to be setup correctly; refer to the
[README](../../README.md) and
[Contributing Guidelines](../../CONTRIBUTING.md).
This guide assumes that you have recursively cloned the PowerShell
repository and `cd`ed into it.
.NET CLI
--------
We use the [.NET Command Line Interface][dotnet-cli] (`dotnet`) to
build PowerShell. The following script will install `dotnet` and add
it to your PowerShell session's path:
build PowerShell. The `Start-PSBootstrap` function will automatically
install it and add it to your path:
```powershell
Import-Module ./PowerShellGitHubDev.psm1
Start-PSBootstrap
```
The `Start-PSBootstrap` function itself does exactly this:
```powershell
Invoke-WebRequest -Uri https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/install.ps1 -OutFile install.ps1
./install.ps1 -version 1.0.0-beta-002198
$env:Path += ";$env:LocalAppData\Microsoft\dotnet\cli"
./install.ps1
```
If you have any problems installing `dotnet`, please see their
@@ -43,21 +59,6 @@ CLI can cause odd failures when running. Please check your version.
[redist-2012]: https://www.microsoft.com/en-us/download/confirmation.aspx?id=30679
[redist-2015]: https://www.microsoft.com/en-us/download/details.aspx?id=48145
Git Setup
---------
Using Git requires it to be setup correctly; refer to the
[Contributing Guidelines](../../CONTRIBUTING.md).
Please clone the superproject (this repo) and initialize a subset of
the submodules:
```sh
git clone https://github.com/PowerShell/PowerShell.git
cd PowerShell
git submodule update --init -- src/windows-build src/Modules/Pester
```
Build using our module
======================
+24 -8
View File
@@ -6,34 +6,50 @@ Supports Ubuntu 14.04, CentOS 7.1, and OS X 10.11.
Once the package is installed, `powershell` will be in your path,
ready to be launched from a terminal. It will read
`~/.powershell/profile.ps1` for your user profile, and
`/usr/local/share/powershell/PSL_profile.ps1` for the system profile.
`/opt/microsoft/powershell/Microsoft.PowerShellCore_profile.ps1` for
the host profile.
Similarly, it will search `~/.powershell/Modules` and
`/usr/local/share/powershell/Modules` for user and system modules.
`/opt/microsoft/powershell/Modules` for user and system modules.
To place PowerShell in your path, a symlink to the
`/opt/microsoft/powershell/powershell` executable is placed at
`/usr/bin/powershell`.
Ubuntu 14.04
============
Using a stock Ubuntu 14.04 image, download the
`powershell_0.2.0-1_amd64.deb` file, and then execute the following:
`powershell_0.3.0-1_amd64.deb` file, and then execute the following:
```sh
sudo apt-get install libunwind8 libicu52
sudo dpkg -i powershell_0.2.0-1_amd64.deb
sudo dpkg -i powershell_0.3.0-1_amd64.deb
```
CentOS 7.1
==========
Using a stock CentOS 7.1 image, download the
`powershell-0.2.0-1.x86_64.rpm` file, and then execute the following:
`powershell-0.3.0-1.x86_64.rpm` file, and then execute the following:
```sh
sudo yum install powershell-0.2.0-1.x86_64.rpm
sudo yum install powershell-0.3.0-1.x86_64.rpm
```
OS X 10.11
==========
Using an OS X 10.11 machine, download the `powershell-0.2.0.pkg` file,
double-click it, and follow the prompts.
Using an OS X 10.11 machine, download the `powershell-0.3.0.pkg` file,
double-click it, and follow the prompts. Or install it from the
terminal:
```sh
sudo installer -pkg powershell-0.3.0.pkg -target /
```
Note that because OS X is a derivation of BSD, instead of `/opt`, the
prefix used is `/usr/local`; thus, `powershell` lives at
`/usr/local/microsoft/powershell`, and the symlink is placed at
`/usr/local/bin/powershell`. This affects the system modules and
profile as well.
+34 -4
View File
@@ -2,13 +2,43 @@
[[ -n $GITHUB_TOKEN ]] || { echo >&2 "GITHUB_TOKEN variable is undefined, please provide token"; exit 1; }
# Set OS specific asset ID and package name
case "$OSTYPE" in
linux*)
asset='1536045'
package='powershell_0.3.0-1_amd64.deb'
# Install curl and wget to download package
sudo apt-get install -y curl wget
;;
darwin*)
asset='1536063'
package='powershell-0.3.0.pkg'
;;
*)
exit 2 >&2 "$OSTYPE not supported!"
;;
esac
# Authorizes with read-only access to GitHub API
# Retrieves URL of v0.2.0 release asset
# Downloads asset to powershell.deb
# Retrieves URL of v0.3.0 release asset
curl -s -i \
-H "Authorization: token $GITHUB_TOKEN " \
-H 'Accept: application/octet-stream' \
'https://api.github.com/repos/PowerShell/PowerShell/releases/assets/1398546' |
"https://api.github.com/repos/PowerShell/PowerShell/releases/assets/$asset" |
grep location |
sed 's/location: //g' |
wget -i - -O powershell.deb
wget -i - -O $package
# Installs PowerShell package
case "$OSTYPE" in
linux*)
# Install dependencies
sudo apt-get install -y libunwind8 libicu52
sudo dpkg -i ./$package
;;
darwin*)
sudo installer -pkg ./$package -target /
;;
esac
echo "Congratulations! PowerShell is now installed."
-13
View File
@@ -1,13 +0,0 @@
#!/usr/bin/env bash
# Build OMI
pushd src/omi/Unix
./configure --dev
make -j
popd
# Build the OMI Provider
pushd src/omi-provider
cmake -DCMAKE_BUILD_TYPE=Debug .
make -j
popd
-1
View File
@@ -1 +0,0 @@
../share/powershell/powershell
-2
View File
@@ -1,2 +0,0 @@
export CORE_ROOT=$(pwd)/bin
sudo -E ./src/omi/Unix/output/bin/omiserver -l --loglevel 2
@@ -11,7 +11,7 @@
"warningsAsErrors": true
},
"dependencies": {
"NETStandard.Library": "1.5.0-rc3-24004-00",
"NETStandard.Library": "1.5.0-rc3-24011-00",
"System.Security.SecureString": "1.0.0-*"
}
},
@@ -19,8 +19,8 @@
"define": [ "_CORECLR" ]
},
"dependencies": {
"System.Runtime.Serialization.Xml": "4.1.1-rc3-24004-00",
"System.Threading.ThreadPool": "4.0.10-rc3-24004-00"
"System.Runtime.Serialization.Xml": "4.1.1-rc3-24011-00",
"System.Threading.ThreadPool": "4.0.10-rc3-24011-00"
}
},
"net451": {
@@ -19,8 +19,8 @@
"define": [ "CORECLR" ]
},
"dependencies": {
"System.ServiceProcess.ServiceController": "4.1.0-rc3-24004-00",
"System.Net.NameResolution": "4.0.0-rc3-24004-00"
"System.ServiceProcess.ServiceController": "4.1.0-rc3-24011-00",
"System.Net.NameResolution": "4.0.0-rc3-24011-00"
}
},
"net451": {
@@ -141,9 +141,8 @@ namespace System.Management.Automation
string asmCultureName = assemblyName.CultureName ?? string.Empty;
string asmFilePath = null;
for (int i = 0; i < probingPaths.Count; i++)
foreach (var probingPath in probingPaths)
{
string probingPath = probingPaths[i];
string asmCulturePath = Path.Combine(probingPath, asmCultureName);
for (int k = 0; k < extensions.Length; k++)
{
@@ -184,19 +183,21 @@ namespace System.Management.Automation
assemblyName.FullName);
}
// Try loading it from the TPA list. All PowerShell dependencies are in the
// TPA list when published with dotnet-cli.
try
{
asmLoaded = Assembly.Load(assemblyName);
}
// If it wasn't there, try loading from path
catch (FileNotFoundException)
{
asmLoaded = asmFilePath.EndsWith(".ni.dll", StringComparison.OrdinalIgnoreCase)
? LoadFromNativeImagePath(asmFilePath, null)
: LoadFromAssemblyPath(asmFilePath);
}
// Since .NET CLI built versions of PowerShell have all the
// built-in assemblies in the TPA list, the above will throw,
// and we have to use Assembly.Load. However, we must try the
// above first, otherwise assemblies that exist outside the TPA
// list will go into a recursive loop.
catch (System.IO.FileLoadException)
{
asmLoaded = System.Reflection.Assembly.Load(assemblyName);
}
// If it loaded, add it to the cache
if (asmLoaded != null)
@@ -250,20 +251,22 @@ namespace System.Management.Automation
if (TryGetAssemblyFromCache(assemblyName, out asmLoaded))
return asmLoaded;
// Try loading it from the TPA list. All PowerShell dependencies are in the
// TPA list when published with dotnet-cli.
try
{
asmLoaded = Assembly.Load(assemblyName);
}
// If it wasn't there, try loading from path
catch (FileNotFoundException)
{
// Load the assembly through 'LoadFromNativeImagePath' or 'LoadFromAssemblyPath'
asmLoaded = assemblyPath.EndsWith(".ni.dll", StringComparison.OrdinalIgnoreCase)
? LoadFromNativeImagePath(assemblyPath, null)
: LoadFromAssemblyPath(assemblyPath);
}
// Since .NET CLI built versions of PowerShell have all the
// built-in assemblies in the TPA list, the above will throw,
// and we have to use Assembly.Load. However, we must try the
// above first, otherwise assemblies that exist outside the TPA
// list will go into a recursive loop.
catch (System.IO.FileLoadException)
{
asmLoaded = System.Reflection.Assembly.Load(assemblyName);
}
if (asmLoaded != null)
{
@@ -503,11 +506,11 @@ namespace System.Management.Automation
// Porting note: it's much easier to send an LPStr on Linux
private const UnmanagedType stringType =
#if LINUX
#if LINUX
UnmanagedType.LPStr
#else
#else
UnmanagedType.LPWStr
#endif
#endif
;
/// <summary>
@@ -1045,52 +1045,52 @@ namespace System.Management.Automation
typeCatalog["System.Linq.ILookup`2"] = "System.Linq, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.IOrderedEnumerable`1"] = "System.Linq, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Lookup`2"] = "System.Linq, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.IOrderedQueryable"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.IOrderedQueryable`1"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.IQueryable"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.IQueryable`1"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.IQueryProvider"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.BinaryExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.BlockExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.CatchBlock"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.ConditionalExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.ConstantExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.DebugInfoExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.DefaultExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.ElementInit"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.Expression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.Expression`1"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.ExpressionType"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.ExpressionVisitor"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.GotoExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.GotoExpressionKind"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.IArgumentProvider"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.IDynamicExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.IndexExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.InvocationExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.LabelExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.LabelTarget"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.LambdaExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.ListInitExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.LoopExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.MemberAssignment"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.MemberBinding"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.MemberBindingType"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.MemberExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.MemberInitExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.MemberListBinding"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.MemberMemberBinding"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.MethodCallExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.NewArrayExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.NewExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.ParameterExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.RuntimeVariablesExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.SwitchCase"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.SwitchExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.SymbolDocumentInfo"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.TryExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.TypeBinaryExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.UnaryExpression"] = "System.Linq.Expressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.IOrderedQueryable"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.IOrderedQueryable`1"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.IQueryable"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.IQueryable`1"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.IQueryProvider"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.BinaryExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.BlockExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.CatchBlock"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.ConditionalExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.ConstantExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.DebugInfoExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.DefaultExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.ElementInit"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.Expression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.Expression`1"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.ExpressionType"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.ExpressionVisitor"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.GotoExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.GotoExpressionKind"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.IArgumentProvider"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.IDynamicExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.IndexExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.InvocationExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.LabelExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.LabelTarget"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.LambdaExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.ListInitExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.LoopExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.MemberAssignment"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.MemberBinding"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.MemberBindingType"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.MemberExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.MemberInitExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.MemberListBinding"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.MemberMemberBinding"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.MethodCallExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.NewArrayExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.NewExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.ParameterExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.RuntimeVariablesExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.SwitchCase"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.SwitchExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.SymbolDocumentInfo"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.TryExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.TypeBinaryExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Linq.Expressions.UnaryExpression"] = "System.Linq.Expressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Net.Http.ByteArrayContent"] = "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Net.Http.ClientCertificateOption"] = "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Net.Http.DelegatingHandler"] = "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
@@ -2197,16 +2197,16 @@ namespace System.Management.Automation
typeCatalog["System.Text.UTF32Encoding"] = "System.Text.Encoding.Extensions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.UTF7Encoding"] = "System.Text.Encoding.Extensions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.UTF8Encoding"] = "System.Text.Encoding.Extensions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.RegularExpressions.Capture"] = "System.Text.RegularExpressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.RegularExpressions.CaptureCollection"] = "System.Text.RegularExpressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.RegularExpressions.Group"] = "System.Text.RegularExpressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.RegularExpressions.GroupCollection"] = "System.Text.RegularExpressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.RegularExpressions.Match"] = "System.Text.RegularExpressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.RegularExpressions.MatchCollection"] = "System.Text.RegularExpressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.RegularExpressions.MatchEvaluator"] = "System.Text.RegularExpressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.RegularExpressions.Regex"] = "System.Text.RegularExpressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.RegularExpressions.RegexMatchTimeoutException"] = "System.Text.RegularExpressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.RegularExpressions.RegexOptions"] = "System.Text.RegularExpressions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.RegularExpressions.Capture"] = "System.Text.RegularExpressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.RegularExpressions.CaptureCollection"] = "System.Text.RegularExpressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.RegularExpressions.Group"] = "System.Text.RegularExpressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.RegularExpressions.GroupCollection"] = "System.Text.RegularExpressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.RegularExpressions.Match"] = "System.Text.RegularExpressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.RegularExpressions.MatchCollection"] = "System.Text.RegularExpressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.RegularExpressions.MatchEvaluator"] = "System.Text.RegularExpressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.RegularExpressions.Regex"] = "System.Text.RegularExpressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.RegularExpressions.RegexMatchTimeoutException"] = "System.Text.RegularExpressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Text.RegularExpressions.RegexOptions"] = "System.Text.RegularExpressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Threading.AbandonedMutexException"] = "System.Threading, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Threading.AsyncLocal`1"] = "System.Threading, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
typeCatalog["System.Threading.AsyncLocalValueChangedArgs`1"] = "System.Threading, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
@@ -22,8 +22,8 @@
"define": [ "CORECLR" ]
},
"dependencies": {
"NETStandard.Library": "1.5.0-rc3-24004-00",
"System.Runtime.Loader": "4.0.0-rc3-24004-00"
"NETStandard.Library": "1.5.0-rc3-24011-00",
"System.Runtime.Loader": "4.0.0-rc3-24011-00"
}
}
}
@@ -23,9 +23,9 @@
"define": [ "CORECLR" ]
},
"dependencies": {
"System.Security.Principal": "4.0.1-rc3-24004-00",
"System.Security.Principal.Windows": "4.0.0-rc3-24004-00",
"System.Diagnostics.TraceSource": "4.0.0-rc3-24004-00",
"System.Security.Principal": "4.0.1-rc3-24011-00",
"System.Security.Principal.Windows": "4.0.0-rc3-24011-00",
"System.Diagnostics.TraceSource": "4.0.0-rc3-24011-00",
"System.Security.SecureString": "1.0.0-*"
}
}
@@ -9,6 +9,7 @@ namespace Microsoft.PowerShell.CoreConsoleHost
using System.Text;
using System.IO;
using System.Runtime.InteropServices;
using System.Linq;
using PowerShell = System.Management.Automation.PowerShell;
public static class Program
@@ -562,27 +563,78 @@ OPTIONS
this.myHost.UI.Write(prompt);
ConsoleReadLine.ReadResult result = consoleReadLine.Read(false, initialCommand);
switch(result.state)
string input;
if (TryInvokeUserDefinedReadLine(out input, true))
{
case ConsoleReadLine.ReadResult.State.Abort:
incompleteLine = false;
partialLine = string.Empty;
initialCommand = String.Empty;
break;
case ConsoleReadLine.ReadResult.State.Redraw:
initialCommand = result.command;
break;
case ConsoleReadLine.ReadResult.State.Complete:
default:
this.Execute(result.command);
initialCommand = String.Empty;
break;
this.Execute(input);
}
else
{
ConsoleReadLine.ReadResult result = consoleReadLine.Read(false, initialCommand);
switch(result.state)
{
case ConsoleReadLine.ReadResult.State.Abort:
incompleteLine = false;
partialLine = string.Empty;
initialCommand = String.Empty;
break;
case ConsoleReadLine.ReadResult.State.Redraw:
initialCommand = result.command;
break;
case ConsoleReadLine.ReadResult.State.Complete:
default:
this.Execute(result.command);
initialCommand = String.Empty;
break;
}
}
}
}
/// <summary>
/// Helper function to test if PSReadLine or another alternate ReadLine has been loaded
/// </summary>
const string CustomReadlineCommand = "PSConsoleHostReadLine";
private bool TryInvokeUserDefinedReadLine(out string input, bool useUserDefinedCustomReadLine)
{
if (useUserDefinedCustomReadLine)
{
var runspace = this.myHost.Runspace;
if (runspace != null
&& runspace.ExecutionContext.EngineIntrinsics.InvokeCommand.GetCommands(CustomReadlineCommand, CommandTypes.Function | CommandTypes.Cmdlet, nameIsPattern: false).Any())
{
try
{
PowerShell ps;
if ((runspace.ExecutionContext.EngineHostInterface.NestedPromptCount > 0) && (Runspace.DefaultRunspace != null))
{
ps = PowerShell.Create(RunspaceMode.CurrentRunspace);
}
else
{
ps = PowerShell.Create();
ps.Runspace = runspace;
}
var result = ps.AddCommand(CustomReadlineCommand).Invoke();
if (result.Count == 1)
{
input = PSObject.Base(result[0]) as string;
return true;
}
}
catch (Exception e)
{
CommandProcessorBase.CheckForSevereException(e);
}
}
}
input = null;
return false;
}
/// <summary>
/// Method to handle the Debugger DebuggerStop event.
/// </summary>
@@ -11,8 +11,8 @@
"dependencies": {
"Newtonsoft.Json": "8.0.2",
"System.Xml.XDocument": "4.0.11-rc3-24004-00",
"System.IO.MemoryMappedFiles": "4.0.0-rc3-24004-00",
"System.Xml.XDocument": "4.0.11-rc3-24011-00",
"System.IO.MemoryMappedFiles": "4.0.0-rc3-24011-00",
"Microsoft.PowerShell.Commands.Management": "1.0.0-*",
"Microsoft.PowerShell.Commands.Utility": "1.0.0-*"
},
-12
View File
@@ -14,9 +14,6 @@
<TableColumnHeader>
<Width>35</Width>
</TableColumnHeader>
<TableColumnHeader>
<Width>10</Width>
</TableColumnHeader>
<TableColumnHeader>
<Width>20</Width>
</TableColumnHeader>
@@ -31,9 +28,6 @@
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Type</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Repository</PropertyName>
</TableColumnItem>
@@ -52,9 +46,6 @@
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Width>25</Width>
</TableColumnHeader>
<TableColumnHeader>
<Width>25</Width>
</TableColumnHeader>
@@ -69,9 +60,6 @@
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>PackageManagementProvider</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>InstallationPolicy</PropertyName>
</TableColumnItem>
Binary file not shown.
+246 -118
View File
@@ -271,8 +271,8 @@ function PackageManagementMessageResolver($MsgID, $Message) {
if($Message)
{
$tempMessage = $Message -creplace "PackageSource", "PSRepository"
$tempMessage = $Message -creplace "packagesource", "psrepository"
$tempMessage = $Message -creplace "Package", "Module"
$tempMessage = $tempMessage -creplace "packagesource", "psrepository"
$tempMessage = $tempMessage -creplace "Package", "Module"
$tempMessage = $tempMessage -creplace "package", "module"
$tempMessage = $tempMessage -creplace "Sources", "Repositories"
$tempMessage = $tempMessage -creplace "sources", "repositories"
@@ -369,8 +369,8 @@ function PackageManagementMessageResolverForScripts($MsgID, $Message) {
if($Message)
{
$tempMessage = $Message -creplace "PackageSource", "PSRepository"
$tempMessage = $Message -creplace "packagesource", "psrepository"
$tempMessage = $Message -creplace "Package", "Script"
$tempMessage = $tempMessage -creplace "packagesource", "psrepository"
$tempMessage = $tempMessage -creplace "Package", "Script"
$tempMessage = $tempMessage -creplace "package", "script"
$tempMessage = $tempMessage -creplace "Sources", "Repositories"
$tempMessage = $tempMessage -creplace "sources", "repositories"
@@ -511,7 +511,11 @@ function Publish-Module
[Parameter()]
[ValidateNotNullOrEmpty()]
[Uri]
$ProjectUri
$ProjectUri,
[Parameter()]
[switch]
$Force
)
Begin
@@ -561,7 +565,7 @@ function Publish-Module
-ExceptionObject $ProjectUri
}
Install-NuGetClientBinaries -CallerPSCmdlet $PSCmdlet -BootstrapNuGetExe
Install-NuGetClientBinaries -CallerPSCmdlet $PSCmdlet -BootstrapNuGetExe -Force:$Force
}
Process
@@ -891,7 +895,7 @@ function Publish-Module
}
$shouldProcessMessage = $LocalizedData.PublishModulewhatIfMessage -f ($moduleInfo.Version, $moduleInfo.Name)
if($PSCmdlet.ShouldProcess($shouldProcessMessage, "Publish-Module"))
if($Force -or $PSCmdlet.ShouldProcess($shouldProcessMessage, "Publish-Module"))
{
Publish-PSArtifactUtility -PSModuleInfo $moduleInfo `
-ManifestPath $manifestPath `
@@ -2183,7 +2187,11 @@ function Publish-Script
[Parameter()]
[ValidateNotNullOrEmpty()]
[string]
$Repository = $Script:PSGalleryModuleSource
$Repository = $Script:PSGalleryModuleSource,
[Parameter()]
[switch]
$Force
)
Begin
@@ -2200,7 +2208,7 @@ function Publish-Script
Get-PSGalleryApiAvailability -Repository $Repository
Install-NuGetClientBinaries -CallerPSCmdlet $PSCmdlet -BootstrapNuGetExe
Install-NuGetClientBinaries -CallerPSCmdlet $PSCmdlet -BootstrapNuGetExe -Force:$Force
}
Process
@@ -2407,7 +2415,7 @@ function Publish-Script
}
$shouldProcessMessage = $LocalizedData.PublishScriptwhatIfMessage -f ($PSScriptInfo.Version, $scriptName)
if($PSCmdlet.ShouldProcess($shouldProcessMessage, "Publish-Script"))
if($Force -or $PSCmdlet.ShouldProcess($shouldProcessMessage, "Publish-Script"))
{
Publish-PSArtifactUtility -PSScriptInfo $PSScriptInfo `
-NugetApiKey $NuGetApiKey `
@@ -3492,41 +3500,50 @@ function Register-PSRepository
<#
.ExternalHelp PSGet.psm1-help.xml
#>
[CmdletBinding(PositionalBinding=$false,
[CmdletBinding(DefaultParameterSetName='NameParameterSet',
HelpUri='http://go.microsoft.com/fwlink/?LinkID=517129')]
Param
(
[Parameter(Mandatory=$true)]
[Parameter(Mandatory=$true,
Position=0,
ParameterSetName='NameParameterSet')]
[ValidateNotNullOrEmpty()]
[string]
$Name,
[Parameter(Mandatory=$true)]
[Parameter(Mandatory=$true,
Position=1,
ParameterSetName='NameParameterSet')]
[ValidateNotNullOrEmpty()]
[Uri]
$SourceLocation,
[Parameter()]
[Parameter(ParameterSetName='NameParameterSet')]
[ValidateNotNullOrEmpty()]
[Uri]
$PublishLocation,
[Parameter()]
[Parameter(ParameterSetName='NameParameterSet')]
[ValidateNotNullOrEmpty()]
[Uri]
$ScriptSourceLocation,
[Parameter()]
[Parameter(ParameterSetName='NameParameterSet')]
[ValidateNotNullOrEmpty()]
[Uri]
$ScriptPublishLocation,
[Parameter(Mandatory=$true,
ParameterSetName='PSGalleryParameterSet')]
[Switch]
$Default,
[Parameter()]
[ValidateSet('Trusted','Untrusted')]
[string]
$InstallationPolicy = 'Untrusted',
[Parameter()]
[Parameter(ParameterSetName='NameParameterSet')]
[ValidateNotNullOrEmpty()]
[string]
$PackageManagementProvider
@@ -3585,62 +3602,86 @@ function Register-PSRepository
Process
{
# Ping and resolve the specified location
$SourceLocation = Resolve-Location -Location (Get-LocationString -LocationUri $SourceLocation) `
-LocationParameterName 'SourceLocation' `
-CallerPSCmdlet $PSCmdlet
if(-not $SourceLocation)
if($PSCmdlet.ParameterSetName -eq 'PSGalleryParameterSet')
{
# Above Resolve-Location function throws an error when it is not able to resolve a location
return
}
if(-not $Default)
{
return
}
if($InstallationPolicy -eq "Trusted")
{
$PSBoundParameters.Add("Trusted", $true)
}
$providerName = $null
if($PackageManagementProvider)
{
$providerName = $PackageManagementProvider
}
elseif($selctedProviderName)
{
$providerName = $selctedProviderName
$PSBoundParameters['Name'] = $Script:PSGalleryModuleSource
$null = $PSBoundParameters.Remove('Default')
}
else
{
$providerName = Get-PackageManagementProviderName -Location $SourceLocation
if($Name -eq $Script:PSGalleryModuleSource)
{
$message = $LocalizedData.UseDefaultParameterSetOnRegisterPSRepository
ThrowError -ExceptionName "System.ArgumentException" `
-ExceptionMessage $message `
-ErrorId 'UseDefaultParameterSetOnRegisterPSRepository' `
-CallerPSCmdlet $PSCmdlet `
-ErrorCategory InvalidArgument `
-ExceptionObject $Name
return
}
# Ping and resolve the specified location
$SourceLocation = Resolve-Location -Location (Get-LocationString -LocationUri $SourceLocation) `
-LocationParameterName 'SourceLocation' `
-CallerPSCmdlet $PSCmdlet
if(-not $SourceLocation)
{
# Above Resolve-Location function throws an error when it is not able to resolve a location
return
}
$providerName = $null
if($PackageManagementProvider)
{
$providerName = $PackageManagementProvider
}
elseif($selctedProviderName)
{
$providerName = $selctedProviderName
}
else
{
$providerName = Get-PackageManagementProviderName -Location $SourceLocation
}
if($providerName)
{
$PSBoundParameters[$script:PackageManagementProviderParam] = $providerName
}
if($PublishLocation)
{
$PSBoundParameters[$script:PublishLocation] = Get-LocationString -LocationUri $PublishLocation
}
if($ScriptPublishLocation)
{
$PSBoundParameters[$script:ScriptPublishLocation] = Get-LocationString -LocationUri $ScriptPublishLocation
}
if($ScriptSourceLocation)
{
$PSBoundParameters[$script:ScriptSourceLocation] = Get-LocationString -LocationUri $ScriptSourceLocation
}
$PSBoundParameters["Location"] = Get-LocationString -LocationUri $SourceLocation
$null = $PSBoundParameters.Remove("SourceLocation")
}
if($providerName)
if($InstallationPolicy -eq "Trusted")
{
$PSBoundParameters[$script:PackageManagementProviderParam] = $providerName
$PSBoundParameters['Trusted'] = $true
}
if($PublishLocation)
{
$PSBoundParameters[$script:PublishLocation] = Get-LocationString -LocationUri $PublishLocation
}
if($ScriptPublishLocation)
{
$PSBoundParameters[$script:ScriptPublishLocation] = Get-LocationString -LocationUri $ScriptPublishLocation
}
if($ScriptSourceLocation)
{
$PSBoundParameters[$script:ScriptSourceLocation] = Get-LocationString -LocationUri $ScriptSourceLocation
}
$PSBoundParameters["Provider"] = $script:PSModuleProviderName
$PSBoundParameters["Location"] = Get-LocationString -LocationUri $SourceLocation
$null = $PSBoundParameters.Remove("SourceLocation")
$null = $PSBoundParameters.Remove("InstallationPolicy")
$PSBoundParameters["Provider"] = $script:PSModuleProviderName
$PSBoundParameters["MessageResolver"] = $script:PackageManagementMessageResolverScriptBlock
$null = PackageManagement\Register-PackageSource @PSBoundParameters
@@ -3656,17 +3697,16 @@ function Set-PSRepository
HelpUri='http://go.microsoft.com/fwlink/?LinkID=517128')]
Param
(
[Parameter(Mandatory=$true)]
[Parameter(Mandatory=$true, Position=0)]
[ValidateNotNullOrEmpty()]
[string]
$Name,
[Parameter()]
[Parameter(Position=1)]
[ValidateNotNullOrEmpty()]
[Uri]
$SourceLocation,
[Parameter()]
[ValidateNotNullOrEmpty()]
[Uri]
@@ -5925,6 +5965,50 @@ function Set-PSGetSettingsVariable
}
}
function Set-PSGalleryRepository
{
[CmdletBinding()]
param([switch]$Trusted)
$psgalleryLocation = Resolve-Location -Location $Script:PSGallerySourceUri `
-LocationParameterName 'SourceLocation' `
-ErrorAction SilentlyContinue `
-WarningAction SilentlyContinue
$scriptSourceLocation = Resolve-Location -Location $Script:PSGalleryScriptSourceUri `
-LocationParameterName 'ScriptSourceLocation' `
-ErrorAction SilentlyContinue `
-WarningAction SilentlyContinue
if($psgalleryLocation)
{
$result = Ping-Endpoint -Endpoint $Script:PSGalleryPublishUri -AllowAutoRedirect:$false
if ($result.ContainsKey($Script:ResponseUri) -and $result[$Script:ResponseUri])
{
$script:PSGalleryPublishUri = $result[$Script:ResponseUri]
}
$repository = Microsoft.PowerShell.Utility\New-Object PSCustomObject -Property ([ordered]@{
Name = $Script:PSGalleryModuleSource
SourceLocation = $psgalleryLocation
PublishLocation = $Script:PSGalleryPublishUri
ScriptSourceLocation = $scriptSourceLocation
ScriptPublishLocation = $Script:PSGalleryPublishUri
Trusted=$Trusted
Registered=$true
InstallationPolicy = if($Trusted) {'Trusted'} else {'Untrusted'}
PackageManagementProvider=$script:NuGetProviderName
ProviderOptions = @{}
})
$repository.PSTypeNames.Insert(0, "Microsoft.PowerShell.Commands.PSRepository")
$script:PSGetModuleSources[$Script:PSGalleryModuleSource] = $repository
Save-ModuleSources
return $repository
}
}
function Set-ModuleSourcesVariable
{
[CmdletBinding()]
@@ -5943,39 +6027,7 @@ function Set-ModuleSourcesVariable
if(-not $script:PSGetModuleSources.Contains($Script:PSGalleryModuleSource))
{
$isPersistRequired = $true
$psgalleryLocation = Resolve-Location -Location $Script:PSGallerySourceUri `
-LocationParameterName 'SourceLocation' `
-ErrorAction SilentlyContinue `
-WarningAction SilentlyContinue
$scriptSourceLocation = Resolve-Location -Location $Script:PSGalleryScriptSourceUri `
-LocationParameterName 'ScriptSourceLocation' `
-ErrorAction SilentlyContinue `
-WarningAction SilentlyContinue
if($psgalleryLocation)
{
$result = Ping-Endpoint -Endpoint $Script:PSGalleryPublishUri -AllowAutoRedirect:$false
if ($result.ContainsKey($Script:ResponseUri) -and $result[$Script:ResponseUri])
{
$script:PSGalleryPublishUri = $result[$Script:ResponseUri]
}
$moduleSource = Microsoft.PowerShell.Utility\New-Object PSCustomObject -Property ([ordered]@{
Name = $Script:PSGalleryModuleSource
SourceLocation = $psgalleryLocation
PublishLocation = $Script:PSGalleryPublishUri
ScriptSourceLocation = $scriptSourceLocation
ScriptPublishLocation = $Script:PSGalleryPublishUri
Trusted=$false
Registered=$true
InstallationPolicy = 'Untrusted'
PackageManagementProvider=$script:NuGetProviderName
ProviderOptions = @{}
})
$moduleSource.PSTypeNames.Insert(0, "Microsoft.PowerShell.Commands.PSRepository")
$script:PSGetModuleSources.Add($Script:PSGalleryModuleSource, $moduleSource)
}
$null = Set-PSGalleryRepository
}
}
@@ -7552,7 +7604,7 @@ function Publish-PSArtifactUtility
Microsoft.PowerShell.Management\Remove-Item $NupkgPath -Force -ErrorAction SilentlyContinue -WarningAction SilentlyContinue -Confirm:$false -WhatIf:$false
Microsoft.PowerShell.Management\Remove-Item $NuspecPath -Force -ErrorAction SilentlyContinue -WarningAction SilentlyContinue -Confirm:$false -WhatIf:$false
Microsoft.PowerShell.Management\Set-Content -Value $nuspec -Path $NuspecPath
Microsoft.PowerShell.Management\Set-Content -Value $nuspec -Path $NuspecPath -Force -Confirm:$false -WhatIf:$false
# Create .nupkg file
$output = & $script:NuGetExePath pack $NuspecPath -OutputDirectory $NugetPackageRoot
@@ -7950,15 +8002,14 @@ function Get-DynamicOptions
Write-Output -InputObject (New-DynamicOption -Category $category -Name $script:PackageManagementProviderParam -ExpectedType String -IsRequired $false)
Write-Output -InputObject (New-DynamicOption -Category $category `
-Name $script:PSArtifactType `
-ExpectedType String `
-IsRequired $false `
-PermittedValues @($script:PSArtifactTypeModule,$script:PSArtifactTypeScript, $script:All))
switch($category)
{
Package {
Write-Output -InputObject (New-DynamicOption -Category $category `
-Name $script:PSArtifactType `
-ExpectedType String `
-IsRequired $false `
-PermittedValues @($script:PSArtifactTypeModule,$script:PSArtifactTypeScript, $script:All))
Write-Output -InputObject (New-DynamicOption -Category $category -Name $script:Filter -ExpectedType String -IsRequired $false)
Write-Output -InputObject (New-DynamicOption -Category $category -Name $script:Tag -ExpectedType StringArray -IsRequired $false)
Write-Output -InputObject (New-DynamicOption -Category $category -Name Includes -ExpectedType StringArray -IsRequired $false -PermittedValues $script:IncludeValidSet)
@@ -7975,6 +8026,11 @@ function Get-DynamicOptions
Install
{
Write-Output -InputObject (New-DynamicOption -Category $category `
-Name $script:PSArtifactType `
-ExpectedType String `
-IsRequired $false `
-PermittedValues @($script:PSArtifactTypeModule,$script:PSArtifactTypeScript, $script:All))
Write-Output -InputObject (New-DynamicOption -Category $category -Name "Scope" -ExpectedType String -IsRequired $false -PermittedValues @("CurrentUser","AllUsers"))
Write-Output -InputObject (New-DynamicOption -Category $category -Name "InstallUpdate" -ExpectedType Switch -IsRequired $false)
Write-Output -InputObject (New-DynamicOption -Category $category -Name 'NoPathUpdate' -ExpectedType Switch -IsRequired $false)
@@ -8001,6 +8057,11 @@ function Add-PackageSource
Set-ModuleSourcesVariable -Force
if(-not $Name)
{
return
}
$IsNewModuleSource = $false
$Options = $request.Options
@@ -8047,6 +8108,17 @@ function Add-PackageSource
$PublishLocation = $null
if($Options.ContainsKey($script:PublishLocation))
{
if($Name -eq $Script:PSGalleryModuleSource)
{
$message = $LocalizedData.ParameterIsNotAllowedWithPSGallery -f ('PublishLocation')
ThrowError -ExceptionName "System.ArgumentException" `
-ExceptionMessage $message `
-ErrorId 'ParameterIsNotAllowedWithPSGallery' `
-CallerPSCmdlet $PSCmdlet `
-ErrorCategory InvalidArgument `
-ExceptionObject $PublishLocation
}
$PublishLocation = $Options[$script:PublishLocation]
if(-not (Microsoft.PowerShell.Management\Test-Path $PublishLocation) -and
@@ -8079,6 +8151,17 @@ function Add-PackageSource
$ScriptSourceLocation = $null
if($Options.ContainsKey($script:ScriptSourceLocation))
{
if($Name -eq $Script:PSGalleryModuleSource)
{
$message = $LocalizedData.ParameterIsNotAllowedWithPSGallery -f ('ScriptSourceLocation')
ThrowError -ExceptionName "System.ArgumentException" `
-ExceptionMessage $message `
-ErrorId 'ParameterIsNotAllowedWithPSGallery' `
-CallerPSCmdlet $PSCmdlet `
-ErrorCategory InvalidArgument `
-ExceptionObject $ScriptSourceLocation
}
$ScriptSourceLocation = $Options[$script:ScriptSourceLocation]
if(-not (Microsoft.PowerShell.Management\Test-Path $ScriptSourceLocation) -and
@@ -8111,6 +8194,17 @@ function Add-PackageSource
$ScriptPublishLocation = $null
if($Options.ContainsKey($script:ScriptPublishLocation))
{
if($Name -eq $Script:PSGalleryModuleSource)
{
$message = $LocalizedData.ParameterIsNotAllowedWithPSGallery -f ('ScriptPublishLocation')
ThrowError -ExceptionName "System.ArgumentException" `
-ExceptionMessage $message `
-ErrorId 'ParameterIsNotAllowedWithPSGallery' `
-CallerPSCmdlet $PSCmdlet `
-ErrorCategory InvalidArgument `
-ExceptionObject $ScriptPublishLocation
}
$ScriptPublishLocation = $Options[$script:ScriptPublishLocation]
if(-not (Microsoft.PowerShell.Management\Test-Path $ScriptPublishLocation) -and
@@ -8140,10 +8234,53 @@ function Add-PackageSource
}
}
# Ping and resolve the specified location
$Location = Resolve-Location -Location $Location `
-LocationParameterName 'Location' `
-CallerPSCmdlet $PSCmdlet
$currentSourceObject = $null
# Check if Name is already registered
if($script:PSGetModuleSources.Contains($Name))
{
$currentSourceObject = $script:PSGetModuleSources[$Name]
}
# Location is not allowed for PSGallery source
# However OneGet passes Location value during Set-PackageSource cmdlet,
# that's why ensuring that Location value is same as the current SourceLocation
#
if(($Name -eq $Script:PSGalleryModuleSource) -and
$Location -and
((-not $IsUpdatePackageSource) -or ($currentSourceObject -and $currentSourceObject.SourceLocation -ne $Location)))
{
$message = $LocalizedData.ParameterIsNotAllowedWithPSGallery -f ('Location, NewLocation or SourceLocation')
ThrowError -ExceptionName "System.ArgumentException" `
-ExceptionMessage $message `
-ErrorId 'ParameterIsNotAllowedWithPSGallery' `
-CallerPSCmdlet $PSCmdlet `
-ErrorCategory InvalidArgument `
-ExceptionObject $Location
}
if($Name -eq $Script:PSGalleryModuleSource)
{
# Add or update the PSGallery repostory
$repository = Set-PSGalleryRepository -Trusted:$Trusted
if($repository)
{
# return the package source object.
Write-Output -InputObject (New-PackageSourceFromModuleSource -ModuleSource $repository)
}
return
}
if($Location)
{
# Ping and resolve the specified location
$Location = Resolve-Location -Location $Location `
-LocationParameterName 'Location' `
-CallerPSCmdlet $PSCmdlet
}
if(-not $Location)
{
# Above Resolve-Location function throws an error when it is not able to resolve a location
@@ -8204,14 +8341,6 @@ function Add-PackageSource
-ErrorCategory InvalidArgument
}
$currentSourceObject = $null
# Check if Name is already registered
if($script:PSGetModuleSources.Contains($Name))
{
$currentSourceObject = $script:PSGetModuleSources[$Name]
}
if(-not $PublishLocation -and $currentSourceObject -and $currentSourceObject.PublishLocation)
{
$PublishLocation = $currentSourceObject.PublishLocation
@@ -10632,7 +10761,6 @@ function New-SoftwareIdentityFromPackage
}
$details.Add( "PackageManagementProvider" , $PackageManagementProviderName )
$details.Add( "Type" , $Type )
if($InstalledLocation)
{
@@ -2723,7 +2723,10 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal
bool missingDefaultConstructor = false;
if (type.GetTypeInfo().IsValueType)
{
supported = true;
if (mapPrimitiveDotNetTypeToMof.ContainsKey(type))
{
supported = true;
}
}
else if (!type.GetTypeInfo().IsAbstract)
{
@@ -2010,7 +2010,8 @@ namespace Microsoft.PowerShell.Commands
}
// Test the required .NET Framework version
Version requestedDotNetFrameworkVersion;
Version requestedDotNetFrameworkVersion = new Version (0, 0, 0, 0);
#if !CORECLR
if (
!GetScalarFromData(data, moduleManifestPath, "DotNetFrameworkVersion", manifestProcessingFlags,
out requestedDotNetFrameworkVersion))
@@ -2044,6 +2045,7 @@ namespace Microsoft.PowerShell.Commands
WriteVerbose(cannotDetectNetFrameworkVersionMessage);
}
}
#endif
// HelpInfo URI
string helpInfoUri = null;
@@ -471,7 +471,12 @@ namespace System.Management.Automation.Runspaces
/// <summary>
/// Runspace is based on a named pipe transport.
/// </summary>
NamedPipeTransport = 0x2
NamedPipeTransport = 0x2,
/// <summary>
/// Runspace is based on a VM socket transport.
/// </summary>
VMSocketTransport = 0x4
}
#endregion
@@ -1000,6 +1000,10 @@ namespace System.Management.Automation
{
returnCaps |= RunspaceCapability.NamedPipeTransport;
}
else if (_connectionInfo is VMConnectionInfo)
{
returnCaps |= RunspaceCapability.VMSocketTransport;
}
else
{
ContainerConnectionInfo containerConnectionInfo = _connectionInfo as ContainerConnectionInfo;
@@ -879,6 +879,7 @@ namespace System.Management.Automation
data.RunspacePoolId,
hostInfo,
streamOptions,
noInput,
addToHistory);
return;
@@ -1209,6 +1210,7 @@ namespace System.Management.Automation
/// <param name="runspacePoolId">RunspacePool Id</param>
/// <param name="hostInfo">Host Info</param>
/// <param name="streamOptions">Remote stream options</param>
/// <param name="noInput">False when input is provided</param>
/// <param name="addToHistory">Add to history</param>
private void StartPowerShellCommandOnPushedRunspace(
PowerShell powershell,
@@ -1216,6 +1218,7 @@ namespace System.Management.Automation
Guid runspacePoolId,
HostInfo hostInfo,
RemoteStreamOptions streamOptions,
bool noInput,
bool addToHistory)
{
Runspace runspace = this.remoteHost.PushedRunspace;
@@ -1223,7 +1226,7 @@ namespace System.Management.Automation
ServerPowerShellDriver driver = new ServerPowerShellDriver(
powershell,
null,
true,
noInput,
powershellId,
runspacePoolId,
this,
+30 -30
View File
@@ -30,36 +30,36 @@
"Microsoft.PowerShell.CoreCLR.AssemblyLoadContext": "1.0.0-*",
"Microsoft.PowerShell.CoreCLR.Eventing": "1.0.0-*",
"Microsoft.CSharp": "4.0.1-rc3-24004-00",
"Microsoft.Win32.Registry.AccessControl": "4.0.0-rc3-24004-00",
"System.Collections.Specialized": "4.0.1-rc3-24004-00",
"System.Collections.NonGeneric": "4.0.1-rc3-24004-00",
"System.ComponentModel.EventBasedAsync": "4.0.11-rc3-24004-00",
"System.ComponentModel.TypeConverter": "4.0.1-rc3-24004-00",
"System.Data.Common": "4.0.1-rc3-24004-00",
"System.Diagnostics.Contracts": "4.0.1-rc3-24004-00",
"System.Diagnostics.FileVersionInfo": "4.0.0-rc3-24004-00",
"System.Diagnostics.Process": "4.1.0-rc3-24004-00",
"System.Diagnostics.StackTrace": "4.0.1-rc3-24004-00",
"System.Diagnostics.TraceSource": "4.0.0-rc3-24004-00",
"System.Dynamic.Runtime": "4.0.11-rc3-24004-00",
"System.IO.FileSystem.AccessControl": "4.0.0-rc3-24004-00",
"System.IO.FileSystem.DriveInfo": "4.0.0-rc3-24004-00",
"System.IO.FileSystem.Watcher": "4.0.0-rc3-24004-00",
"System.IO.Pipes": "4.0.0-rc3-24004-00",
"System.Linq.Expressions": "4.0.11-rc3-24004-00",
"System.Net.Http": "4.0.1-rc3-24004-00",
"System.Net.NetworkInformation": "4.1.0-rc3-24004-00",
"System.Reflection.Emit": "4.0.1-rc3-24004-00",
"System.Reflection.Emit.Lightweight": "4.0.1-rc3-24004-00",
"System.Security.AccessControl": "4.0.0-rc3-24004-00",
"System.Security.Cryptography.Algorithms": "4.1.0-rc3-24004-00",
"System.Security.Cryptography.X509Certificates": "4.1.0-rc3-24004-00",
"System.Threading.Thread": "4.0.0-rc3-24004-00",
"System.Threading.Tasks.Parallel": "4.0.1-rc3-24004-00",
"System.Xml.XPath.XmlDocument": "4.0.1-rc3-24004-00",
"System.Xml.XmlDocument": "4.0.1-rc3-24004-00",
"System.Xml.XmlSerializer": "4.0.11-rc3-24004-00"
"Microsoft.CSharp": "4.0.1-rc3-24011-00",
"Microsoft.Win32.Registry.AccessControl": "4.0.0-rc3-24011-00",
"System.Collections.Specialized": "4.0.1-rc3-24011-00",
"System.Collections.NonGeneric": "4.0.1-rc3-24011-00",
"System.ComponentModel.EventBasedAsync": "4.0.11-rc3-24011-00",
"System.ComponentModel.TypeConverter": "4.0.1-rc3-24011-00",
"System.Data.Common": "4.0.1-rc3-24011-00",
"System.Diagnostics.Contracts": "4.0.1-rc3-24011-00",
"System.Diagnostics.FileVersionInfo": "4.0.0-rc3-24011-00",
"System.Diagnostics.Process": "4.1.0-rc3-24011-00",
"System.Diagnostics.StackTrace": "4.0.1-rc3-24011-00",
"System.Diagnostics.TraceSource": "4.0.0-rc3-24011-00",
"System.Dynamic.Runtime": "4.0.11-rc3-24011-00",
"System.IO.FileSystem.AccessControl": "4.0.0-rc3-24011-00",
"System.IO.FileSystem.DriveInfo": "4.0.0-rc3-24011-00",
"System.IO.FileSystem.Watcher": "4.0.0-rc3-24011-00",
"System.IO.Pipes": "4.0.0-rc3-24011-00",
"System.Linq.Expressions": "4.0.11-rc3-24011-00",
"System.Net.Http": "4.0.1-rc3-24011-00",
"System.Net.NetworkInformation": "4.1.0-rc3-24011-00",
"System.Reflection.Emit": "4.0.1-rc3-24011-00",
"System.Reflection.Emit.Lightweight": "4.0.1-rc3-24011-00",
"System.Security.AccessControl": "4.0.0-rc3-24011-00",
"System.Security.Cryptography.Algorithms": "4.1.0-rc3-24011-00",
"System.Security.Cryptography.X509Certificates": "4.1.0-rc3-24011-00",
"System.Threading.Thread": "4.0.0-rc3-24011-00",
"System.Threading.Tasks.Parallel": "4.0.1-rc3-24011-00",
"System.Xml.XPath.XmlDocument": "4.0.1-rc3-24011-00",
"System.Xml.XmlDocument": "4.0.1-rc3-24011-00",
"System.Xml.XmlSerializer": "4.0.11-rc3-24011-00"
}
},
"net451": {
@@ -2144,33 +2144,8 @@ namespace System.Management.Automation.Security
[DllImport("wintrust.dll", CharSet = CharSet.Unicode)]
internal static extern IntPtr CryptCATStoreFromHandle(
IntPtr hCatalog
);
[DllImport("wintrust.dll", CharSet = CharSet.Unicode)]
internal static extern bool CryptCATAdminAcquireContext2(
ref IntPtr phCatAdmin,
IntPtr pgSubsystem,
[MarshalAs(UnmanagedType.LPWStr)]
string pwszHashAlgorithm,
IntPtr pStrongHashPolicy,
DWORD dwFlags
);
[DllImport("wintrust.dll", CharSet = CharSet.Unicode)]
internal static extern bool CryptCATAdminReleaseContext(
IntPtr phCatAdmin,
DWORD dwFlags
);
[DllImport("wintrust.dll", CharSet = CharSet.Unicode)]
internal static extern bool CryptCATAdminCalcHashFromFileHandle2(
IntPtr hCatAdmin,
SafeFileHandle hFile,
[In, Out] ref DWORD pcbHash,
IntPtr pbHash,
DWORD dwFlags
);
);
[DllImport("wintrust.dll", CharSet = CharSet.Unicode)]
internal static extern IntPtr CryptCATEnumerateMember(
IntPtr hCatalog,
@@ -12,7 +12,7 @@
"frameworks": {
"netstandard1.5": {
"dependencies": {
"NETStandard.Library": "1.5.0-rc3-24004-00"
"NETStandard.Library": "1.5.0-rc3-24011-00"
},
"imports": [ "dnxcore50" ]
}
Submodule src/omi deleted from 6fbc8b0b62.
+194 -140
View File
@@ -1,140 +1,194 @@
Describe "Get-Variable" {
It "Should be able to call with no parameters without error" {
{ Get-Variable } | Should Not Throw
}
It "Should return environment variables when called with no parameters" {
(Get-Variable).Name -contains "$" | Should Be $true
(Get-Variable).Name -contains "?" | Should Be $true
(Get-Variable).Name -contains "HOST" | Should Be $true
(Get-Variable).Name -contains "PWD" | Should Be $true
(Get-Variable).Name -contains "PID" | Should Be $true
(Get-Variable).Name -contains "^" | Should Be $true
}
It "Should return the value of an object" {
New-Variable -Name tempVar -Value 1
(Get-Variable tempVar).Value | Should Be (1)
}
It "Should be able to call using the gv alias" {
{ gv } | Should Not Throw
}
It "Should be able to call using the Name switch" {
New-Variable -Name var1 -Value 4
{ Get-Variable -Name var1 } | Should Not Throw
(Get-Variable -Name var1).Value | Should Be 4
Remove-Variable var1
}
It "Should be able to use wildcard characters in the Name field" {
New-Variable -Name var1 -Value 4
New-Variable -Name var2 -Value "test"
(Get-Variable -Name var*).Value[0] | Should be 4
(Get-Variable -Name var*).Value[1] | Should be "test"
Remove-Variable var1
Remove-Variable var2
}
It "Should return only the value if the value switch is used" {
New-Variable -Name var1 -Value 4
Get-Variable -Name var1 -ValueOnly | Should be 4
Remove-Variable var1
}
It "Should pipe string to the name field without the Name field being specified"{
New-Variable -Name var1 -Value 3
("var1" | Get-Variable ).Value | Should Be 3
Remove-Variable var1
}
It "Should be able to include a set of variables to get" {
New-Variable -Name var1 -Value 4
New-Variable -Name var2 -Value 2
$actual = Get-Variable -Include var1, var2
$actual[0].Name | Should Be var1
$actual[1].Name | Should Be var2
$actual[0].Value | Should Be 4
$actual[1].Value | Should Be 2
Remove-Variable var1
Remove-Variable var2
}
It "Should be able to exclude a set of variables to get" {
New-Variable -Name var1 -Value 4
New-Variable -Name var2 -Value 2
New-Variable -Name var3 -Value "test"
$actual = Get-Variable -Exclude var1, var2
$actual | Where-Object { $_.Name -eq "var3" } | Should Not BeNullOrEmpty
}
Context "Scope Tests" {
# This will violate the DRY principle. Tread softly.
It "Should be able to get a global scope variable using the global switch" {
New-Variable globalVar -Value 1 -Scope global -Force
(Get-Variable -Name globalVar -Scope global)[0].Value | Should Be 1
}
It "Should not be able to clear a global scope variable using the local switch" {
New-Variable globalVar -Value 1 -Scope global -Force
Get-Variable -Name globalVar -Scope local -ErrorAction SilentlyContinue | Should Throw
}
It "Should be able to get a global variable when there's one in the script scope" {
New-Variable globalVar -Value 1 -Scope global -Force
{ New-Variable globalVar -Value 2 -Scope script -Force }
$(Get-Variable -Name globalVar).Value | Should Be 1
}
It "Should be able to get an item locally using the local switch" {
{
New-Variable localVar -Value 1 -Scope local -Force
Get-Variable -Name localVar -Scope local
} | Should Not Throw
}
It "Should be able to get a variable created in the global scope when there's one in local scope" {
New-Variable localVar -Value 1 -Scope local -Force
New-Variable localVar -Value 2 -Scope global -Force
$(Get-Variable -Name localVar -Scope global).Value | Should Be 2
}
It "Should be able to get a script variable created using the script switch" {
{
New-Variable scriptVar -Value 1 -Scope script -Force
Get-Variable -Name scriptVar -Scope script
} | Should Not Throw
}
It "Should be able to clear a global script variable that was created using the script scope switch" {
{
New-Variable scriptVar -Value 1 -Scope script -Force
Get-Variable -Name scriptVar -Scope script
} | Should Not Throw
}
}
}
Describe "Get-Variable DRT Unit Tests" -Tags DRT{
It "Get-Variable of not existing variable Name should throw ItemNotFoundException"{
try {
Get-Variable -EA Stop -Name nonexistingVariableName
Throw "Execution OK"
}
catch {
$_.FullyQualifiedErrorId | Should be "VariableNotFound,Microsoft.PowerShell.Commands.GetVariableCommand"
}
}
It "Get-Variable of existing variable Name with include and bogus exclude should work"{
Set-Variable newVar testing
$var1=get-variable -Name newVar -Include newVar -Exclude bogus
$var1.Name|Should Be "newVar"
$var1.Value|Should Be "testing"
}
It "Get-Variable of existing variable Name with Description and Option should work"{
Set-Variable newVar testing -Option ReadOnly -Description "testing description"
$var1=get-variable -Name newVar
$var1.Name|Should Be "newVar"
$var1.Value|Should Be "testing"
$var1.Options|Should Be "ReadOnly"
$var1.Description|Should Be "testing description"
}
It "Get-Variable of existing variable Globbing Name should work"{
Set-Variable abcaVar testing
Set-Variable bcdaVar "another test"
Set-Variable aVarfoo wow
$var1=get-variable -Name *aVar* -Scope local
$var1.Count | Should be 3
$var1[0].Name|Should Be "abcaVar"
$var1[0].Value|Should Be "testing"
$var1[1].Name|Should Be "aVarfoo"
$var1[1].Value|Should Be "wow"
$var1[2].Name|Should Be "bcdaVar"
$var1[2].Value|Should Be "another test"
}
It "Get-Variable of existing private variable Name should throw ItemNotFoundException skip now as bug#818" -Skip:$true{
try {
Set-Variable newVar testing -Option Private
&{Get-Variable -Name newVar}
Throw "Execution OK"
}
catch {
$_.FullyQualifiedErrorId | Should be "VariableNotFound,Microsoft.PowerShell.Commands.GetVariableCommand"
}
}
}
Describe "Get-Variable" {
It "Should be able to call with no parameters without error" {
{ Get-Variable } | Should Not Throw
}
It "Should return environment variables when called with no parameters" {
(Get-Variable).Name -contains "$" | Should Be $true
(Get-Variable).Name -contains "?" | Should Be $true
(Get-Variable).Name -contains "HOST" | Should Be $true
(Get-Variable).Name -contains "PWD" | Should Be $true
(Get-Variable).Name -contains "PID" | Should Be $true
(Get-Variable).Name -contains "^" | Should Be $true
}
It "Should return the value of an object" {
New-Variable -Name tempVar -Value 1
(Get-Variable tempVar).Value | Should Be (1)
}
It "Should be able to call using the gv alias" {
(get-alias gv).Definition | Should be "Get-Variable"
}
It "Should be able to call using the Name switch" {
New-Variable -Name var1 -Value 4
{ Get-Variable -Name var1 } | Should Not Throw
(Get-Variable -Name var1).Value | Should Be 4
Remove-Variable var1
}
It "Should be able to use wildcard characters in the Name field" {
New-Variable -Name var1 -Value 4
New-Variable -Name var2 -Value "test"
(Get-Variable -Name var*).Value[0] | Should be 4
(Get-Variable -Name var*).Value[1] | Should be "test"
Remove-Variable var1
Remove-Variable var2
}
It "Should return only the value if the value switch is used" {
New-Variable -Name var1 -Value 4
Get-Variable -Name var1 -ValueOnly | Should be 4
Remove-Variable var1
}
It "Should pipe string to the name field without the Name field being specified"{
New-Variable -Name var1 -Value 3
("var1" | Get-Variable ).Value | Should Be 3
Remove-Variable var1
}
It "Should be able to include a set of variables to get" {
New-Variable -Name var1 -Value 4
New-Variable -Name var2 -Value 2
$actual = Get-Variable -Include var1, var2
$actual[0].Name | Should Be var1
$actual[1].Name | Should Be var2
$actual[0].Value | Should Be 4
$actual[1].Value | Should Be 2
Remove-Variable var1
Remove-Variable var2
}
It "Should be able to exclude a set of variables to get" {
New-Variable -Name var1 -Value 4
New-Variable -Name var2 -Value 2
New-Variable -Name var3 -Value "test"
$actual = Get-Variable -Exclude var1, var2
$actual.Name -contains "var3" | Should Be $true
}
Context "Scope Tests" {
# This will violate the DRY principle. Tread softly.
It "Should be able to get a global scope variable using the global switch" {
New-Variable globalVar -Value 1 -Scope global -Force
(Get-Variable -Name globalVar -Scope global).Value | Should Be 1
}
It "Should not be able to clear a global scope variable using the local switch" {
New-Variable globalVar -Value 1 -Scope global -Force
Get-Variable -Name globalVar -Scope local -ErrorAction SilentlyContinue | Should Throw
}
It "Should be able to get a global variable when there's one in the script scope" {
New-Variable globalVar -Value 1 -Scope global -Force
{ New-Variable globalVar -Value 2 -Scope script -Force}
(Get-Variable -Name globalVar).Value | Should Be 1
}
It "Should be able to get an item locally using the local switch" {
{
New-Variable localVar -Value 1 -Scope local -Force
Get-Variable -Name localVar -Scope local
} | Should Not Throw
}
It "Should be able to get a variable created in the global scope when there's one in local scope" {
New-Variable localVar -Value 1 -Scope local -Force
New-Variable localVar -Value 2 -Scope global -Force
(Get-Variable -Name localVar -Scope global).Value | Should Be 2
}
It "Should be able to get a script variable created using the script switch" {
{
New-Variable scriptVar -Value 1 -Scope script -Force
Get-Variable -Name scriptVar -Scope script
} | Should Not Throw
}
It "Should be able to clear a global script variable that was created using the script scope switch" {
{
New-Variable scriptVar -Value 1 -Scope script -Force
Get-Variable -Name scriptVar -Scope script
} | Should Not Throw
}
}
}
+99 -25
View File
@@ -1,25 +1,99 @@
Describe "Import-Alias" {
$pesteraliasfile = Join-Path -Path (Join-Path $PSScriptRoot -ChildPath assets) -ChildPath pesteralias.txt
Context "Validate ability to import alias file" {
It "Should be able to import an alias file successfully" {
{ Import-Alias $pesteraliasfile } | Should Not throw
}
It "Should be able to import file via the Import-Alias alias of ipal" {
{ ipal $pesteraliasfile } | Should Not throw
}
It "Should be able to import an alias file and perform imported aliased echo cmd" {
(Import-Alias $pesteraliasfile)
(pesterecho pestertesting) | Should Be "pestertesting"
}
It "Should be able to use ipal alias to import an alias file and perform cmd" {
(ipal $pesteraliasfile)
(pesterecho pestertesting) | Should be "pestertesting"
}
}
}
Describe "Import-Alias DRT Unit Tests" -Tags DRT{
$testAliasDirectory = Join-Path -Path $TestDrive -ChildPath ImportAliasTestDirectory
$testAliases = "TestAliases"
$fulltestpath = Join-Path -Path $testAliasDirectory -ChildPath $testAliases
BeforeEach {
New-Item -Path $testAliasDirectory -ItemType Directory -Force
remove-item alias:abcd* -force
remove-item alias:ijkl* -force
set-alias abcd01 efgh01
set-alias abcd02 efgh02
set-alias abcd03 efgh03
set-alias abcd04 efgh04
set-alias ijkl01 mnop01
set-alias ijkl02 mnop02
set-alias ijkl03 mnop03
set-alias ijkl04 mnop04
}
AfterEach {
Remove-Item -Path $testAliasDirectory -Recurse -Force
}
It "Import-Alias Resolve To Multiple will throw PSInvalidOperationException" {
try {
Import-Alias *
Throw "Execution OK"
}
catch {
$_.FullyQualifiedErrorId | Should be "NotSupported,Microsoft.PowerShell.Commands.ImportAliasCommand"
}
}
It "Import-Alias From Exported Alias File Aliases Already Exist should throw SessionStateException skip now as bug#777" -Skip:$true{
{Export-Alias $fulltestpath abcd*}| Should Not Throw
try {
Import-Alias $fulltestpath
Throw "Execution OK"
}
catch {
$_.FullyQualifiedErrorId | Should be "AliasAlreadyExists,Microsoft.PowerShell.Commands.ImportAliasCommand"
}
}
It "Import-Alias Into Invalid Scope should throw PSArgumentException"{
{Export-Alias $fulltestpath abcd*}| Should Not Throw
try {
Import-Alias $fulltestpath -scope bogus
Throw "Execution OK"
}
catch {
$_.FullyQualifiedErrorId | Should be "Argument,Microsoft.PowerShell.Commands.ImportAliasCommand"
}
}
It "Import-Alias From Exported Alias File Aliases Already Exist using force should not throw"{
{Export-Alias $fulltestpath abcd*}| Should Not Throw
{Import-Alias $fulltestpath -Force}| Should Not Throw
}
}
Describe "Import-Alias" {
$newLine=[Environment]::NewLine
$testAliasDirectory = Join-Path -Path $TestDrive -ChildPath ImportAliasTestDirectory
$testAliases = "pesteralias.txt"
$pesteraliasfile = Join-Path -Path $testAliasDirectory -ChildPath $testAliases
BeforeEach {
New-Item -Path $testAliasDirectory -ItemType Directory -Force
$pesteraliascontent ='# Alias File'+$newLine
$pesteraliascontent+='# Exported by : alex'+$newLine
$pesteraliascontent+='# Date/Time : Thursday, 12 November 2015 21:55:08'+$newLine
$pesteraliascontent+='# Computer : archvm'+$newLine+'"pesterecho","echo","","None"'
$pesteraliascontent > $pesteraliasfile
}
AfterEach {
Remove-Item -Path $testAliasDirectory -Recurse -Force
}
It "Should be able to import an alias file successfully" {
{ Import-Alias $pesteraliasfile } | Should Not throw
}
It "Should be able to import file via the Import-Alias alias of ipal" {
{ ipal $pesteraliasfile } | Should Not throw
}
It "Should be able to import an alias file and perform imported aliased echo cmd" {
(Import-Alias $pesteraliasfile)
(pesterecho pestertesting) | Should Be "pestertesting"
}
It "Should be able to use ipal alias to import an alias file and perform cmd" {
(ipal $pesteraliasfile)
(pesterecho pestertesting) | Should be "pestertesting"
}
}
-16
View File
@@ -35,22 +35,6 @@ Describe "Write-Output" {
}
}
Context "Alias Tests" {
It "Should have the same result between the echo alias and the cmdlet" {
$alias = echo -InputObject $testString
$cmdlet = Write-Output -InputObject $testString
$alias | Should Be $cmdlet
}
It "Should have the same result between the write alias and the cmdlet" {
$alias = write -InputObject $testString
$cmdlet = Write-Output -InputObject $testString
$alias | Should Be $cmdlet
}
}
Context "Enumerate Objects" {
$enumerationObject = @(1,2,3)
It "Should see individual objects when not using the NoEnumerate switch" {