2018-02-13 18:23:53 +01:00
|
|
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
# Licensed under the MIT License.
|
|
|
|
|
|
|
|
# no progress output during these tests
|
2017-01-10 23:42:27 +01:00
|
|
|
$ProgressPreference = "SilentlyContinue"
|
|
|
|
|
|
|
|
$RepositoryName = 'INTGallery'
|
2018-09-24 23:58:13 +02:00
|
|
|
$SourceLocation = 'https://www.poshtestgallery.com'
|
2016-08-27 01:58:22 +02:00
|
|
|
$RegisteredINTRepo = $false
|
|
|
|
$ContosoServer = 'ContosoServer'
|
|
|
|
$FabrikamServerScript = 'Fabrikam-ServerScript'
|
Move powershell to .NET Core 2.0 (#3556)
This change moves powershell to .NET Core 2.0. Major changes are:
1. PowerShell assemblies are now targeting `netcoreapp2.0`. We are using `microsoft.netcore.app-2.0.0-preview1-001913-00`, which is from dotnet-core build 4/4/17. We cannot target `netstandard2.0` because the packages `System.Reflection.Emit` and `System.Reflection.Emit.Lightweight`, which are needed for powershell class, cannot be referenced when targeting `netstandard2.0`.
2. Refactor code to remove most CLR stub types and extension types.
3. Update build scripts to enable CI builds. The `-cache` section is specified to depend on `appveyor.yml`, so the cache will be invalidated if `appveyor.yml` is changed.
4. Ship `netcoreapp` reference assemblies with powershell to fix the issues in `Add-Type` (#2764). By default `Add-Type` will reference all those reference assemblies when compiling C# code. If `-ReferenceAssembly` is specified, then we search reference assemblies first, then the framework runtime assemblies, and lastly the loaded assemblies (possibly a third-party one that was already loaded).
5. `dotnet publish` generates executable on Unix platforms, but doesn't set "x" permission and thus it cannot execute. Currently, the "x" permission is set in the build script, `dotnet/cli` issue [#6286](https://github.com/dotnet/cli/issues/6286) is tracking this.
6. Replace the use of some APIs with the ones that take `SecureString`.
7. osx.10.12 is required to update to `netcoreapp2.0` because `dotnet-cli` 2.0.0-preview only works on osx.10.12.
8. Add dependency to `System.ValueTuple` to work around a ambiguous type identity issue in coreclr. The issue is tracked by `dotnet/corefx` [#17797](https://github.com/dotnet/corefx/issues/17797). When moving to newer version of `netcoreapp2.0`, we need to verify if this dependency is still needed.
2017-04-17 20:52:38 +02:00
|
|
|
$Initialized = $false
|
|
|
|
|
2016-08-27 01:58:22 +02:00
|
|
|
#region Utility functions
|
|
|
|
|
|
|
|
function IsInbox { $PSHOME.EndsWith('\WindowsPowerShell\v1.0', [System.StringComparison]::OrdinalIgnoreCase) }
|
|
|
|
function IsWindows { $PSVariable = Get-Variable -Name IsWindows -ErrorAction Ignore; return (-not $PSVariable -or $PSVariable.Value) }
|
2017-12-07 17:59:31 +01:00
|
|
|
function IsCoreCLR { $PSVersionTable.ContainsKey('PSEdition') -and $PSVersionTable.PSEdition -eq 'Core' }
|
2016-08-27 01:58:22 +02:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Install locations for modules and scripts
|
|
|
|
|
|
|
|
if(IsInbox)
|
|
|
|
{
|
|
|
|
$script:ProgramFilesPSPath = Microsoft.PowerShell.Management\Join-Path -Path $env:ProgramFiles -ChildPath "WindowsPowerShell"
|
|
|
|
}
|
2019-03-05 20:55:20 +01:00
|
|
|
elseif(IsCoreCLR) {
|
2017-12-07 17:59:31 +01:00
|
|
|
if(IsWindows) {
|
|
|
|
$script:ProgramFilesPSPath = Microsoft.PowerShell.Management\Join-Path -Path $env:ProgramFiles -ChildPath 'PowerShell'
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$script:ProgramFilesPSPath = Split-Path -Path ([System.Management.Automation.Platform]::SelectProductNameForDirectory('SHARED_MODULES')) -Parent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
$script:MyDocumentsFolderPath = [Environment]::GetFolderPath("MyDocuments")
|
|
|
|
}
|
|
|
|
catch
|
2016-08-27 01:58:22 +02:00
|
|
|
{
|
2017-12-07 17:59:31 +01:00
|
|
|
$script:MyDocumentsFolderPath = $null
|
2016-08-27 01:58:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(IsInbox)
|
|
|
|
{
|
|
|
|
$script:MyDocumentsPSPath = if($script:MyDocumentsFolderPath)
|
|
|
|
{
|
|
|
|
Microsoft.PowerShell.Management\Join-Path -Path $script:MyDocumentsFolderPath -ChildPath "WindowsPowerShell"
|
2017-01-16 22:31:14 +01:00
|
|
|
}
|
2016-08-27 01:58:22 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Microsoft.PowerShell.Management\Join-Path -Path $env:USERPROFILE -ChildPath "Documents\WindowsPowerShell"
|
|
|
|
}
|
|
|
|
}
|
2017-12-07 17:59:31 +01:00
|
|
|
elseif(IsCoreCLR) {
|
|
|
|
if(IsWindows)
|
|
|
|
{
|
|
|
|
$script:MyDocumentsPSPath = if($script:MyDocumentsFolderPath)
|
|
|
|
{
|
|
|
|
Microsoft.PowerShell.Management\Join-Path -Path $script:MyDocumentsFolderPath -ChildPath 'PowerShell'
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Microsoft.PowerShell.Management\Join-Path -Path $HOME -ChildPath "Documents\PowerShell"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$script:MyDocumentsPSPath = Split-Path -Path ([System.Management.Automation.Platform]::SelectProductNameForDirectory('USER_MODULES')) -Parent
|
|
|
|
}
|
2016-08-27 01:58:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$script:ProgramFilesModulesPath = Microsoft.PowerShell.Management\Join-Path -Path $script:ProgramFilesPSPath -ChildPath 'Modules'
|
|
|
|
$script:MyDocumentsModulesPath = Microsoft.PowerShell.Management\Join-Path -Path $script:MyDocumentsPSPath -ChildPath 'Modules'
|
|
|
|
|
|
|
|
$script:ProgramFilesScriptsPath = Microsoft.PowerShell.Management\Join-Path -Path $script:ProgramFilesPSPath -ChildPath 'Scripts'
|
|
|
|
$script:MyDocumentsScriptsPath = Microsoft.PowerShell.Management\Join-Path -Path $script:MyDocumentsPSPath -ChildPath 'Scripts'
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Register a test repository
|
|
|
|
|
Move powershell to .NET Core 2.0 (#3556)
This change moves powershell to .NET Core 2.0. Major changes are:
1. PowerShell assemblies are now targeting `netcoreapp2.0`. We are using `microsoft.netcore.app-2.0.0-preview1-001913-00`, which is from dotnet-core build 4/4/17. We cannot target `netstandard2.0` because the packages `System.Reflection.Emit` and `System.Reflection.Emit.Lightweight`, which are needed for powershell class, cannot be referenced when targeting `netstandard2.0`.
2. Refactor code to remove most CLR stub types and extension types.
3. Update build scripts to enable CI builds. The `-cache` section is specified to depend on `appveyor.yml`, so the cache will be invalidated if `appveyor.yml` is changed.
4. Ship `netcoreapp` reference assemblies with powershell to fix the issues in `Add-Type` (#2764). By default `Add-Type` will reference all those reference assemblies when compiling C# code. If `-ReferenceAssembly` is specified, then we search reference assemblies first, then the framework runtime assemblies, and lastly the loaded assemblies (possibly a third-party one that was already loaded).
5. `dotnet publish` generates executable on Unix platforms, but doesn't set "x" permission and thus it cannot execute. Currently, the "x" permission is set in the build script, `dotnet/cli` issue [#6286](https://github.com/dotnet/cli/issues/6286) is tracking this.
6. Replace the use of some APIs with the ones that take `SecureString`.
7. osx.10.12 is required to update to `netcoreapp2.0` because `dotnet-cli` 2.0.0-preview only works on osx.10.12.
8. Add dependency to `System.ValueTuple` to work around a ambiguous type identity issue in coreclr. The issue is tracked by `dotnet/corefx` [#17797](https://github.com/dotnet/corefx/issues/17797). When moving to newer version of `netcoreapp2.0`, we need to verify if this dependency is still needed.
2017-04-17 20:52:38 +02:00
|
|
|
function Initialize
|
2016-08-27 01:58:22 +02:00
|
|
|
{
|
2017-06-06 02:37:48 +02:00
|
|
|
# Cleaned up commands whose output to console by deleting or piping to Out-Null
|
|
|
|
Import-Module PackageManagement
|
|
|
|
Get-PackageProvider -ListAvailable | Out-Null
|
Move powershell to .NET Core 2.0 (#3556)
This change moves powershell to .NET Core 2.0. Major changes are:
1. PowerShell assemblies are now targeting `netcoreapp2.0`. We are using `microsoft.netcore.app-2.0.0-preview1-001913-00`, which is from dotnet-core build 4/4/17. We cannot target `netstandard2.0` because the packages `System.Reflection.Emit` and `System.Reflection.Emit.Lightweight`, which are needed for powershell class, cannot be referenced when targeting `netstandard2.0`.
2. Refactor code to remove most CLR stub types and extension types.
3. Update build scripts to enable CI builds. The `-cache` section is specified to depend on `appveyor.yml`, so the cache will be invalidated if `appveyor.yml` is changed.
4. Ship `netcoreapp` reference assemblies with powershell to fix the issues in `Add-Type` (#2764). By default `Add-Type` will reference all those reference assemblies when compiling C# code. If `-ReferenceAssembly` is specified, then we search reference assemblies first, then the framework runtime assemblies, and lastly the loaded assemblies (possibly a third-party one that was already loaded).
5. `dotnet publish` generates executable on Unix platforms, but doesn't set "x" permission and thus it cannot execute. Currently, the "x" permission is set in the build script, `dotnet/cli` issue [#6286](https://github.com/dotnet/cli/issues/6286) is tracking this.
6. Replace the use of some APIs with the ones that take `SecureString`.
7. osx.10.12 is required to update to `netcoreapp2.0` because `dotnet-cli` 2.0.0-preview only works on osx.10.12.
8. Add dependency to `System.ValueTuple` to work around a ambiguous type identity issue in coreclr. The issue is tracked by `dotnet/corefx` [#17797](https://github.com/dotnet/corefx/issues/17797). When moving to newer version of `netcoreapp2.0`, we need to verify if this dependency is still needed.
2017-04-17 20:52:38 +02:00
|
|
|
|
|
|
|
$repo = Get-PSRepository -ErrorAction SilentlyContinue |
|
|
|
|
Where-Object {$_.SourceLocation.StartsWith($SourceLocation, [System.StringComparison]::OrdinalIgnoreCase)}
|
|
|
|
if($repo)
|
|
|
|
{
|
|
|
|
$script:RepositoryName = $repo.Name
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Register-PSRepository -Name $RepositoryName -SourceLocation $SourceLocation -InstallationPolicy Trusted
|
|
|
|
$script:RegisteredINTRepo = $true
|
|
|
|
}
|
2016-08-27 01:58:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2016-09-14 02:45:38 +02:00
|
|
|
function Remove-InstalledModules
|
|
|
|
{
|
2017-08-10 22:33:25 +02:00
|
|
|
Get-InstalledModule -Name $ContosoServer -AllVersions -ErrorAction SilentlyContinue | PowerShellGet\Uninstall-Module -Force
|
2016-09-14 02:45:38 +02:00
|
|
|
}
|
|
|
|
|
2016-09-09 21:34:10 +02:00
|
|
|
Describe "PowerShellGet - Module tests" -tags "Feature" {
|
2016-08-27 01:58:22 +02:00
|
|
|
|
Move powershell to .NET Core 2.0 (#3556)
This change moves powershell to .NET Core 2.0. Major changes are:
1. PowerShell assemblies are now targeting `netcoreapp2.0`. We are using `microsoft.netcore.app-2.0.0-preview1-001913-00`, which is from dotnet-core build 4/4/17. We cannot target `netstandard2.0` because the packages `System.Reflection.Emit` and `System.Reflection.Emit.Lightweight`, which are needed for powershell class, cannot be referenced when targeting `netstandard2.0`.
2. Refactor code to remove most CLR stub types and extension types.
3. Update build scripts to enable CI builds. The `-cache` section is specified to depend on `appveyor.yml`, so the cache will be invalidated if `appveyor.yml` is changed.
4. Ship `netcoreapp` reference assemblies with powershell to fix the issues in `Add-Type` (#2764). By default `Add-Type` will reference all those reference assemblies when compiling C# code. If `-ReferenceAssembly` is specified, then we search reference assemblies first, then the framework runtime assemblies, and lastly the loaded assemblies (possibly a third-party one that was already loaded).
5. `dotnet publish` generates executable on Unix platforms, but doesn't set "x" permission and thus it cannot execute. Currently, the "x" permission is set in the build script, `dotnet/cli` issue [#6286](https://github.com/dotnet/cli/issues/6286) is tracking this.
6. Replace the use of some APIs with the ones that take `SecureString`.
7. osx.10.12 is required to update to `netcoreapp2.0` because `dotnet-cli` 2.0.0-preview only works on osx.10.12.
8. Add dependency to `System.ValueTuple` to work around a ambiguous type identity issue in coreclr. The issue is tracked by `dotnet/corefx` [#17797](https://github.com/dotnet/corefx/issues/17797). When moving to newer version of `netcoreapp2.0`, we need to verify if this dependency is still needed.
2017-04-17 20:52:38 +02:00
|
|
|
BeforeAll {
|
|
|
|
if ($script:Initialized -eq $false) {
|
|
|
|
Initialize
|
|
|
|
$script:Initialized = $true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-27 01:58:22 +02:00
|
|
|
BeforeEach {
|
2016-09-14 02:45:38 +02:00
|
|
|
Remove-InstalledModules
|
2016-08-27 01:58:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should find a module correctly" {
|
|
|
|
$psgetModuleInfo = Find-Module -Name $ContosoServer -Repository $RepositoryName
|
2018-03-30 07:22:26 +02:00
|
|
|
$psgetModuleInfo.Name | Should -Be $ContosoServer
|
|
|
|
$psgetModuleInfo.Repository | Should -Be $RepositoryName
|
2016-08-27 01:58:22 +02:00
|
|
|
}
|
|
|
|
|
2018-09-24 23:58:13 +02:00
|
|
|
It "Should install a module correctly to the required location with default CurrentUser scope" {
|
|
|
|
Install-Module -Name $ContosoServer -Repository $RepositoryName
|
2016-08-27 01:58:22 +02:00
|
|
|
$installedModuleInfo = Get-InstalledModule -Name $ContosoServer
|
|
|
|
|
2018-03-30 07:22:26 +02:00
|
|
|
$installedModuleInfo | Should -Not -BeNullOrEmpty
|
|
|
|
$installedModuleInfo.Name | Should -Be $ContosoServer
|
|
|
|
$installedModuleInfo.InstalledLocation.StartsWith($script:MyDocumentsModulesPath, [System.StringComparison]::OrdinalIgnoreCase) | Should -BeTrue
|
2016-08-27 01:58:22 +02:00
|
|
|
|
|
|
|
$module = Get-Module $ContosoServer -ListAvailable
|
2018-03-30 07:22:26 +02:00
|
|
|
$module.Name | Should -Be $ContosoServer
|
|
|
|
$module.ModuleBase | Should -Be $installedModuleInfo.InstalledLocation
|
2016-08-27 01:58:22 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 02:45:38 +02:00
|
|
|
AfterAll {
|
|
|
|
Remove-InstalledModules
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-05 20:55:20 +01:00
|
|
|
Describe "PowerShellGet - Module tests (Admin)" -Tags @('Feature', 'RequireAdminOnWindows', 'RequireSudoOnUnix') {
|
2016-09-14 02:45:38 +02:00
|
|
|
|
Move powershell to .NET Core 2.0 (#3556)
This change moves powershell to .NET Core 2.0. Major changes are:
1. PowerShell assemblies are now targeting `netcoreapp2.0`. We are using `microsoft.netcore.app-2.0.0-preview1-001913-00`, which is from dotnet-core build 4/4/17. We cannot target `netstandard2.0` because the packages `System.Reflection.Emit` and `System.Reflection.Emit.Lightweight`, which are needed for powershell class, cannot be referenced when targeting `netstandard2.0`.
2. Refactor code to remove most CLR stub types and extension types.
3. Update build scripts to enable CI builds. The `-cache` section is specified to depend on `appveyor.yml`, so the cache will be invalidated if `appveyor.yml` is changed.
4. Ship `netcoreapp` reference assemblies with powershell to fix the issues in `Add-Type` (#2764). By default `Add-Type` will reference all those reference assemblies when compiling C# code. If `-ReferenceAssembly` is specified, then we search reference assemblies first, then the framework runtime assemblies, and lastly the loaded assemblies (possibly a third-party one that was already loaded).
5. `dotnet publish` generates executable on Unix platforms, but doesn't set "x" permission and thus it cannot execute. Currently, the "x" permission is set in the build script, `dotnet/cli` issue [#6286](https://github.com/dotnet/cli/issues/6286) is tracking this.
6. Replace the use of some APIs with the ones that take `SecureString`.
7. osx.10.12 is required to update to `netcoreapp2.0` because `dotnet-cli` 2.0.0-preview only works on osx.10.12.
8. Add dependency to `System.ValueTuple` to work around a ambiguous type identity issue in coreclr. The issue is tracked by `dotnet/corefx` [#17797](https://github.com/dotnet/corefx/issues/17797). When moving to newer version of `netcoreapp2.0`, we need to verify if this dependency is still needed.
2017-04-17 20:52:38 +02:00
|
|
|
BeforeAll {
|
|
|
|
if ($script:Initialized -eq $false) {
|
|
|
|
Initialize
|
|
|
|
$script:Initialized = $true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-14 02:45:38 +02:00
|
|
|
BeforeEach {
|
|
|
|
Remove-InstalledModules
|
|
|
|
}
|
|
|
|
|
2019-03-05 20:55:20 +01:00
|
|
|
It "Should install a module correctly to the required location with AllUsers scope" {
|
2018-09-24 23:58:13 +02:00
|
|
|
Install-Module -Name $ContosoServer -Repository $RepositoryName -Scope AllUsers
|
2016-08-27 01:58:22 +02:00
|
|
|
$installedModuleInfo = Get-InstalledModule -Name $ContosoServer
|
|
|
|
|
2018-03-30 07:22:26 +02:00
|
|
|
$installedModuleInfo | Should -Not -BeNullOrEmpty
|
|
|
|
$installedModuleInfo.Name | Should -Be $ContosoServer
|
|
|
|
$installedModuleInfo.InstalledLocation.StartsWith($script:programFilesModulesPath, [System.StringComparison]::OrdinalIgnoreCase) | Should -BeTrue
|
2016-08-27 01:58:22 +02:00
|
|
|
|
|
|
|
$module = Get-Module $ContosoServer -ListAvailable
|
2018-03-30 07:22:26 +02:00
|
|
|
$module.Name | Should -Be $ContosoServer
|
|
|
|
$module.ModuleBase | Should -Be $installedModuleInfo.InstalledLocation
|
2016-08-27 01:58:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
AfterAll {
|
2016-09-14 02:45:38 +02:00
|
|
|
Remove-InstalledModules
|
2016-08-27 01:58:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-14 02:45:38 +02:00
|
|
|
function Remove-InstalledScripts
|
|
|
|
{
|
|
|
|
Get-InstalledScript -Name $FabrikamServerScript -ErrorAction SilentlyContinue | Uninstall-Script -Force
|
|
|
|
}
|
|
|
|
|
2016-09-09 21:34:10 +02:00
|
|
|
Describe "PowerShellGet - Script tests" -tags "Feature" {
|
2016-08-27 01:58:22 +02:00
|
|
|
|
Move powershell to .NET Core 2.0 (#3556)
This change moves powershell to .NET Core 2.0. Major changes are:
1. PowerShell assemblies are now targeting `netcoreapp2.0`. We are using `microsoft.netcore.app-2.0.0-preview1-001913-00`, which is from dotnet-core build 4/4/17. We cannot target `netstandard2.0` because the packages `System.Reflection.Emit` and `System.Reflection.Emit.Lightweight`, which are needed for powershell class, cannot be referenced when targeting `netstandard2.0`.
2. Refactor code to remove most CLR stub types and extension types.
3. Update build scripts to enable CI builds. The `-cache` section is specified to depend on `appveyor.yml`, so the cache will be invalidated if `appveyor.yml` is changed.
4. Ship `netcoreapp` reference assemblies with powershell to fix the issues in `Add-Type` (#2764). By default `Add-Type` will reference all those reference assemblies when compiling C# code. If `-ReferenceAssembly` is specified, then we search reference assemblies first, then the framework runtime assemblies, and lastly the loaded assemblies (possibly a third-party one that was already loaded).
5. `dotnet publish` generates executable on Unix platforms, but doesn't set "x" permission and thus it cannot execute. Currently, the "x" permission is set in the build script, `dotnet/cli` issue [#6286](https://github.com/dotnet/cli/issues/6286) is tracking this.
6. Replace the use of some APIs with the ones that take `SecureString`.
7. osx.10.12 is required to update to `netcoreapp2.0` because `dotnet-cli` 2.0.0-preview only works on osx.10.12.
8. Add dependency to `System.ValueTuple` to work around a ambiguous type identity issue in coreclr. The issue is tracked by `dotnet/corefx` [#17797](https://github.com/dotnet/corefx/issues/17797). When moving to newer version of `netcoreapp2.0`, we need to verify if this dependency is still needed.
2017-04-17 20:52:38 +02:00
|
|
|
BeforeAll {
|
|
|
|
if ($script:Initialized -eq $false) {
|
|
|
|
Initialize
|
|
|
|
$script:Initialized = $true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-27 01:58:22 +02:00
|
|
|
BeforeEach {
|
2016-09-14 02:45:38 +02:00
|
|
|
Remove-InstalledScripts
|
2016-08-27 01:58:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should find a script correctly" {
|
|
|
|
$psgetScriptInfo = Find-Script -Name $FabrikamServerScript -Repository $RepositoryName
|
2018-03-30 07:22:26 +02:00
|
|
|
$psgetScriptInfo.Name | Should -Be $FabrikamServerScript
|
|
|
|
$psgetScriptInfo.Repository | Should -Be $RepositoryName
|
2016-08-27 01:58:22 +02:00
|
|
|
}
|
|
|
|
|
2018-09-24 23:58:13 +02:00
|
|
|
It "Should install a script correctly to the required location with default CurrentUser scope" {
|
|
|
|
Install-Script -Name $FabrikamServerScript -Repository $RepositoryName -NoPathUpdate
|
2016-08-27 01:58:22 +02:00
|
|
|
$installedScriptInfo = Get-InstalledScript -Name $FabrikamServerScript
|
|
|
|
|
2018-03-30 07:22:26 +02:00
|
|
|
$installedScriptInfo | Should -Not -BeNullOrEmpty
|
|
|
|
$installedScriptInfo.Name | Should -Be $FabrikamServerScript
|
|
|
|
$installedScriptInfo.InstalledLocation.StartsWith($script:MyDocumentsScriptsPath, [System.StringComparison]::OrdinalIgnoreCase) | Should -BeTrue
|
2016-08-27 01:58:22 +02:00
|
|
|
}
|
|
|
|
|
2016-09-14 02:45:38 +02:00
|
|
|
AfterAll {
|
|
|
|
Remove-InstalledScripts
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-05 20:55:20 +01:00
|
|
|
Describe "PowerShellGet - Script tests (Admin)" -Tags @('Feature', 'RequireAdminOnWindows', 'RequireSudoOnUnix') {
|
2016-09-14 02:45:38 +02:00
|
|
|
|
Move powershell to .NET Core 2.0 (#3556)
This change moves powershell to .NET Core 2.0. Major changes are:
1. PowerShell assemblies are now targeting `netcoreapp2.0`. We are using `microsoft.netcore.app-2.0.0-preview1-001913-00`, which is from dotnet-core build 4/4/17. We cannot target `netstandard2.0` because the packages `System.Reflection.Emit` and `System.Reflection.Emit.Lightweight`, which are needed for powershell class, cannot be referenced when targeting `netstandard2.0`.
2. Refactor code to remove most CLR stub types and extension types.
3. Update build scripts to enable CI builds. The `-cache` section is specified to depend on `appveyor.yml`, so the cache will be invalidated if `appveyor.yml` is changed.
4. Ship `netcoreapp` reference assemblies with powershell to fix the issues in `Add-Type` (#2764). By default `Add-Type` will reference all those reference assemblies when compiling C# code. If `-ReferenceAssembly` is specified, then we search reference assemblies first, then the framework runtime assemblies, and lastly the loaded assemblies (possibly a third-party one that was already loaded).
5. `dotnet publish` generates executable on Unix platforms, but doesn't set "x" permission and thus it cannot execute. Currently, the "x" permission is set in the build script, `dotnet/cli` issue [#6286](https://github.com/dotnet/cli/issues/6286) is tracking this.
6. Replace the use of some APIs with the ones that take `SecureString`.
7. osx.10.12 is required to update to `netcoreapp2.0` because `dotnet-cli` 2.0.0-preview only works on osx.10.12.
8. Add dependency to `System.ValueTuple` to work around a ambiguous type identity issue in coreclr. The issue is tracked by `dotnet/corefx` [#17797](https://github.com/dotnet/corefx/issues/17797). When moving to newer version of `netcoreapp2.0`, we need to verify if this dependency is still needed.
2017-04-17 20:52:38 +02:00
|
|
|
BeforeAll {
|
|
|
|
if ($script:Initialized -eq $false) {
|
|
|
|
Initialize
|
|
|
|
$script:Initialized = $true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-14 02:45:38 +02:00
|
|
|
BeforeEach {
|
|
|
|
Remove-InstalledScripts
|
|
|
|
}
|
|
|
|
|
2019-03-05 20:55:20 +01:00
|
|
|
It "Should install a script correctly to the required location with AllUsers scope" {
|
2018-09-24 23:58:13 +02:00
|
|
|
Install-Script -Name $FabrikamServerScript -Repository $RepositoryName -NoPathUpdate -Scope AllUsers
|
2016-08-27 01:58:22 +02:00
|
|
|
$installedScriptInfo = Get-InstalledScript -Name $FabrikamServerScript
|
|
|
|
|
2018-03-30 07:22:26 +02:00
|
|
|
$installedScriptInfo | Should -Not -BeNullOrEmpty
|
|
|
|
$installedScriptInfo.Name | Should -Be $FabrikamServerScript
|
|
|
|
$installedScriptInfo.InstalledLocation.StartsWith($script:ProgramFilesScriptsPath, [System.StringComparison]::OrdinalIgnoreCase) | Should -BeTrue
|
2016-08-27 01:58:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
AfterAll {
|
2016-09-14 02:45:38 +02:00
|
|
|
Remove-InstalledScripts
|
2016-08-27 01:58:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-10 22:33:25 +02:00
|
|
|
Describe 'PowerShellGet Type tests' -tags @('CI') {
|
|
|
|
BeforeAll {
|
|
|
|
Import-Module PowerShellGet -Force
|
|
|
|
}
|
|
|
|
|
|
|
|
It 'Ensure PowerShellGet Types are available' {
|
|
|
|
$PowerShellGetNamespace = 'Microsoft.PowerShell.Commands.PowerShellGet'
|
|
|
|
$PowerShellGetTypeDetails = @{
|
|
|
|
InternalWebProxy = @('GetProxy', 'IsBypassed')
|
|
|
|
}
|
|
|
|
|
|
|
|
if((IsWindows)) {
|
|
|
|
$PowerShellGetTypeDetails['CERT_CHAIN_POLICY_PARA'] = @('cbSize','dwFlags','pvExtraPolicyPara')
|
|
|
|
$PowerShellGetTypeDetails['CERT_CHAIN_POLICY_STATUS'] = @('cbSize','dwError','lChainIndex','lElementIndex','pvExtraPolicyStatus')
|
|
|
|
$PowerShellGetTypeDetails['InternalSafeHandleZeroOrMinusOneIsInvalid'] = @('IsInvalid')
|
|
|
|
$PowerShellGetTypeDetails['InternalSafeX509ChainHandle'] = @('CertFreeCertificateChain','ReleaseHandle','InvalidHandle')
|
|
|
|
$PowerShellGetTypeDetails['Win32Helpers'] = @('CertVerifyCertificateChainPolicy', 'CertDuplicateCertificateChain', 'IsMicrosoftCertificate')
|
|
|
|
}
|
|
|
|
|
|
|
|
if('Microsoft.PowerShell.Telemetry.Internal.TelemetryAPI' -as [Type]) {
|
|
|
|
$PowerShellGetTypeDetails['Telemetry'] = @('TraceMessageArtifactsNotFound', 'TraceMessageNonPSGalleryRegistration')
|
|
|
|
}
|
|
|
|
|
|
|
|
$PowerShellGetTypeDetails.GetEnumerator() | ForEach-Object {
|
|
|
|
$ClassName = $_.Name
|
|
|
|
$Type = "$PowerShellGetNamespace.$ClassName" -as [Type]
|
2018-03-30 07:22:26 +02:00
|
|
|
$Type | Select-Object -ExpandProperty Name | Should -Be $ClassName
|
|
|
|
$_.Value | ForEach-Object { $Type.DeclaredMembers.Name -contains $_ | Should -BeTrue }
|
2017-08-10 22:33:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-27 01:58:22 +02:00
|
|
|
if($RegisteredINTRepo)
|
|
|
|
{
|
|
|
|
Get-PSRepository -Name $RepositoryName -ErrorAction SilentlyContinue | Unregister-PSRepository
|
|
|
|
}
|