@@ -13,7 +13,7 @@ $Initialized = $false
1313
1414function IsInbox { $PSHOME.EndsWith (' \WindowsPowerShell\v1.0' , [System.StringComparison ]::OrdinalIgnoreCase) }
1515function IsWindows { $PSVariable = Get-Variable - Name IsWindows - ErrorAction Ignore; return (-not $PSVariable -or $PSVariable.Value ) }
16- function IsCoreCLR { $PSVariable = Get-Variable - Name IsCoreCLR - ErrorAction Ignore; return ( $PSVariable -and $PSVariable .Value ) }
16+ function IsCoreCLR { $PSVersionTable .ContainsKey ( ' PSEdition ' ) -and $PSVersionTable .PSEdition -eq ' Core ' }
1717
1818# endregion
1919
@@ -23,22 +23,26 @@ if(IsInbox)
2323{
2424 $script :ProgramFilesPSPath = Microsoft.PowerShell.Management\Join-Path - Path $env: ProgramFiles - ChildPath " WindowsPowerShell"
2525}
26- else
26+ elseif (IsCoreCLR){
27+ if (IsWindows) {
28+ $script :ProgramFilesPSPath = Microsoft.PowerShell.Management\Join-Path - Path $env: ProgramFiles - ChildPath ' PowerShell'
29+ }
30+ else {
31+ $script :ProgramFilesPSPath = Split-Path - Path ([System.Management.Automation.Platform ]::SelectProductNameForDirectory(' SHARED_MODULES' )) - Parent
32+ }
33+ }
34+
35+ try
36+ {
37+ $script :MyDocumentsFolderPath = [Environment ]::GetFolderPath(" MyDocuments" )
38+ }
39+ catch
2740{
28- $script :ProgramFilesPSPath = $PSHome
41+ $script :MyDocumentsFolderPath = $null
2942}
3043
3144if (IsInbox)
3245{
33- try
34- {
35- $script :MyDocumentsFolderPath = [Environment ]::GetFolderPath(" MyDocuments" )
36- }
37- catch
38- {
39- $script :MyDocumentsFolderPath = $null
40- }
41-
4246 $script :MyDocumentsPSPath = if ($script :MyDocumentsFolderPath )
4347 {
4448 Microsoft.PowerShell.Management\Join-Path - Path $script :MyDocumentsFolderPath - ChildPath " WindowsPowerShell"
@@ -48,13 +52,22 @@ if(IsInbox)
4852 Microsoft.PowerShell.Management\Join-Path - Path $env: USERPROFILE - ChildPath " Documents\WindowsPowerShell"
4953 }
5054}
51- elseif (IsWindows)
52- {
53- $script :MyDocumentsPSPath = Microsoft.PowerShell.Management\Join-Path - Path $HOME - ChildPath ' Documents\PowerShell'
54- }
55- else
56- {
57- $script :MyDocumentsPSPath = Microsoft.PowerShell.Management\Join-Path - Path $HOME - ChildPath ' .local/share/powershell'
55+ elseif (IsCoreCLR) {
56+ if (IsWindows)
57+ {
58+ $script :MyDocumentsPSPath = if ($script :MyDocumentsFolderPath )
59+ {
60+ Microsoft.PowerShell.Management\Join-Path - Path $script :MyDocumentsFolderPath - ChildPath ' PowerShell'
61+ }
62+ else
63+ {
64+ Microsoft.PowerShell.Management\Join-Path - Path $HOME - ChildPath " Documents\PowerShell"
65+ }
66+ }
67+ else
68+ {
69+ $script :MyDocumentsPSPath = Split-Path - Path ([System.Management.Automation.Platform ]::SelectProductNameForDirectory(' USER_MODULES' )) - Parent
70+ }
5871}
5972
6073$script :ProgramFilesModulesPath = Microsoft.PowerShell.Management\Join-Path - Path $script :ProgramFilesPSPath - ChildPath ' Modules'
@@ -143,7 +156,8 @@ Describe "PowerShellGet - Module tests (Admin)" -tags @('Feature', 'RequireAdmin
143156 Remove-InstalledModules
144157 }
145158
146- It " Should install a module correctly to the required location with default AllUsers scope" {
159+ # # Marked as 'Pending' on Linux for now because the test requires root privilege but we cannot do it now in our Travis CI Linux build
160+ It " Should install a module correctly to the required location with default AllUsers scope" - Pending:$IsLinux {
147161 Install-Module - Name $ContosoServer - Repository $RepositoryName
148162 $installedModuleInfo = Get-InstalledModule - Name $ContosoServer
149163
@@ -212,7 +226,8 @@ Describe "PowerShellGet - Script tests (Admin)" -tags @('Feature', 'RequireAdmin
212226 Remove-InstalledScripts
213227 }
214228
215- It " Should install a script correctly to the required location with default AllUsers scope" {
229+ # # Marked as 'Pending' on Linux for now because the test requires root privilege but we cannot do it now in our Travis CI Linux build
230+ It " Should install a script correctly to the required location with default AllUsers scope" - Pending:$IsLinux {
216231 Install-Script - Name $FabrikamServerScript - Repository $RepositoryName - NoPathUpdate
217232 $installedScriptInfo = Get-InstalledScript - Name $FabrikamServerScript
218233
0 commit comments