Skip to content

Commit 5b5168d

Browse files
adityapatwardhanTravisEz13
authored andcommitted
Revert "Pull PSReadLine from PSGallery" (#5986)
This reverts commit beffdcf.
1 parent 7dcd4c8 commit 5b5168d

59 files changed

Lines changed: 17523 additions & 57 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

PowerShell-Win.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Management.Infras
2121
EndProject
2222
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.PowerShell.Commands.Diagnostics", "src\Microsoft.PowerShell.Commands.Diagnostics\Microsoft.PowerShell.Commands.Diagnostics.csproj", "{439A24FC-8E0A-48B6-8227-44C297311F49}"
2323
EndProject
24+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.PowerShell.PSReadLine", "src\Microsoft.PowerShell.PSReadLine\Microsoft.PowerShell.PSReadLine.csproj", "{07BFD271-8992-4F34-9091-6CFC3E224A24}"
2425
EndProject
2526
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.WSMan.Management", "src\Microsoft.WSMan.Management\Microsoft.WSMan.Management.csproj", "{8F63D134-E413-4181-936D-D82F3F5F1D85}"
2627
EndProject

build.psm1

Lines changed: 92 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,9 @@ Fix steps:
523523

524524
# handle Restore
525525
if ($Restore -or -not (Test-Path "$($Options.Top)/obj/project.assets.json")) {
526-
$srcProjectDirs = @($Options.Top, "$PSScriptRoot/src/TypeCatalogGen", "$PSScriptRoot/src/ResGen", "$PSScriptRoot/src/Modules/PSGalleryModules.csproj")
526+
log "Run dotnet restore"
527+
528+
$srcProjectDirs = @($Options.Top, "$PSScriptRoot/src/TypeCatalogGen", "$PSScriptRoot/src/ResGen")
527529
$testProjectDirs = Get-ChildItem "$PSScriptRoot/test/*.csproj" -Recurse | ForEach-Object { [System.IO.Path]::GetDirectoryName($_) }
528530

529531
$RestoreArguments = @("--verbosity")
@@ -533,11 +535,7 @@ Fix steps:
533535
$RestoreArguments += "quiet"
534536
}
535537

536-
($srcProjectDirs + $testProjectDirs) | ForEach-Object {
537-
log "Run dotnet restore $_ $RestoreArguments"
538-
539-
Start-NativeExecution { dotnet restore $_ $RestoreArguments }
540-
}
538+
($srcProjectDirs + $testProjectDirs) | ForEach-Object { Start-NativeExecution { dotnet restore $_ $RestoreArguments } }
541539
}
542540

543541
# handle ResGen
@@ -650,11 +648,17 @@ function Restore-PSModuleToBuild
650648
$CI
651649
)
652650

651+
$ProgressPreference = "SilentlyContinue"
653652
log "Restore PowerShell modules to $publishPath"
654653

655654
$modulesDir = Join-Path -Path $publishPath -ChildPath "Modules"
656655

657-
Copy-PSGalleryModules -Destination $modulesDir
656+
# Restore modules from powershellgallery feed
657+
Restore-PSModule -Destination $modulesDir -Name @(
658+
# PowerShellGet depends on PackageManagement module, so PackageManagement module will be installed with the PowerShellGet module.
659+
'PowerShellGet'
660+
'Microsoft.PowerShell.Archive'
661+
) -SourceLocation "https://www.powershellgallery.com/api/v2/"
658662

659663
if($CI.IsPresent)
660664
{
@@ -673,7 +677,6 @@ function Restore-PSPester
673677

674678
Restore-GitModule -Destination $Destination -Uri 'https://github.com/PowerShell/psl-pester' -Name Pester -CommitSha '1f546b6aaa0893e215e940a14f57c96f56f7eff1'
675679
}
676-
677680
function Compress-TestContent {
678681
[CmdletBinding()]
679682
param(
@@ -2372,6 +2375,7 @@ function Start-CrossGen {
23722375
"Microsoft.PowerShell.Security.dll",
23732376
"Microsoft.PowerShell.CoreCLR.Eventing.dll",
23742377
"Microsoft.PowerShell.ConsoleHost.dll",
2378+
"Microsoft.PowerShell.PSReadLine.dll",
23752379
"System.Management.Automation.dll"
23762380
)
23772381

@@ -2480,56 +2484,102 @@ function Restore-GitModule
24802484
}
24812485

24822486
# Install PowerShell modules such as PackageManagement, PowerShellGet
2483-
function Copy-PSGalleryModules
2487+
function Restore-PSModule
24842488
{
24852489
[CmdletBinding()]
24862490
param(
24872491
[Parameter(Mandatory=$true)]
24882492
[ValidateNotNullOrEmpty()]
2489-
[string]$Destination
2493+
[string[]]$Name,
2494+
2495+
[Parameter(Mandatory=$true)]
2496+
[ValidateNotNullOrEmpty()]
2497+
[string]$Destination,
2498+
2499+
[string]$SourceLocation="https://powershell.myget.org/F/powershellmodule/api/v2/",
2500+
2501+
[string]$RequiredVersion
24902502
)
24912503

2492-
if (!$Destination.EndsWith("Modules")) {
2493-
throw "Installing to an unexpected location"
2494-
}
2504+
$needRegister = $true
2505+
$RepositoryName = "mygetpsmodule"
24952506

2496-
$cache = dotnet nuget locals global-packages -l
2497-
if ($cache -match "info : global-packages: (.*)") {
2498-
$nugetCache = $matches[1]
2499-
}
2500-
else {
2501-
throw "Can't find nuget global cache"
2507+
# Check if the PackageManagement works in the base-oS or PowerShellCore
2508+
$null = Get-PackageProvider -Name NuGet -ForceBootstrap -Verbose:$VerbosePreference
2509+
$null = Get-PackageProvider -Name PowerShellGet -Verbose:$VerbosePreference
2510+
2511+
# Get the existing registered PowerShellGet repositories
2512+
$psrepos = PowerShellGet\Get-PSRepository
2513+
2514+
foreach ($repo in $psrepos)
2515+
{
2516+
if(($repo.SourceLocation -eq $SourceLocation) -or ($repo.SourceLocation.TrimEnd("/") -eq $SourceLocation.TrimEnd("/")))
2517+
{
2518+
# found a registered repository that matches the source location
2519+
$needRegister = $false
2520+
$RepositoryName = $repo.Name
2521+
break
2522+
}
25022523
}
25032524

2504-
$psGalleryProj = [xml](Get-Content -Raw $PSScriptRoot\src\Modules\PSGalleryModules.csproj)
2525+
if($needRegister)
2526+
{
2527+
$regVar = PowerShellGet\Get-PSRepository -Name $RepositoryName -ErrorAction SilentlyContinue
2528+
if($regVar)
2529+
{
2530+
PowerShellGet\UnRegister-PSRepository -Name $RepositoryName
2531+
}
25052532

2506-
foreach ($m in $psGalleryProj.Project.ItemGroup.PackageReference) {
2507-
$name = $m.Include
2508-
$version = $m.Version
2509-
log "Name='$Name', Version='$version', Destination='$Destination'"
2533+
log "Registering PSRepository with name: $RepositoryName and sourcelocation: $SourceLocation"
2534+
PowerShellGet\Register-PSRepository -Name $RepositoryName -SourceLocation $SourceLocation -ErrorVariable ev -verbose
2535+
if($ev)
2536+
{
2537+
throw ("Failed to register repository '{0}'" -f $RepositoryName)
2538+
}
25102539

2511-
# Remove the build revision from the src (nuget drops it).
2512-
$srcVer = if ($version -match "(\d+.\d+.\d+).\d+") {
2513-
$matches[1]
2514-
} else {
2515-
$version
2540+
$regVar = PowerShellGet\Get-PSRepository -Name $RepositoryName
2541+
if(-not $regVar)
2542+
{
2543+
throw ("'{0}' is not registered" -f $RepositoryName)
25162544
}
2517-
#
2518-
# Remove semantic version in the destination directory
2519-
$destVer = if ($version -match "(\d+.\d+.\d+)-.+") {
2520-
$matches[1]
2521-
} else {
2522-
$version
2545+
}
2546+
2547+
log ("Name='{0}', Destination='{1}', Repository='{2}'" -f ($Name -join ','), $Destination, $RepositoryName)
2548+
2549+
# do not output progress
2550+
$ProgressPreference = "SilentlyContinue"
2551+
$Name | ForEach-Object {
2552+
2553+
$command = @{
2554+
Name=$_
2555+
Path = $Destination
2556+
Repository =$RepositoryName
2557+
}
2558+
2559+
if($RequiredVersion)
2560+
{
2561+
$command.Add("RequiredVersion", $RequiredVersion)
25232562
}
25242563

2525-
# Nuget seems to always use lowercase in the cache
2526-
$src = "$nugetCache/$($name.ToLower())/$srcVer"
2527-
$dest = "$Destination/$name/$destVer"
2564+
# pull down the module
2565+
log "running save-module $_"
2566+
PowerShellGet\Save-Module @command -Force
2567+
2568+
# Remove PSGetModuleInfo.xml file
2569+
Find-Module -Name $_ -Repository $RepositoryName -IncludeDependencies | ForEach-Object {
2570+
Remove-Item -Path $Destination\$($_.Name)\*\PSGetModuleInfo.xml -Force
2571+
}
2572+
}
25282573

2529-
Remove-Item -Force -ErrorAction Ignore -Recurse "$Destination/$name"
2530-
New-Item -Path $dest -ItemType Directory -Force -ErrorAction Stop > $null
2531-
$dontCopy = '*.nupkg', '*.nupkg.sha512', '*.nuspec', 'System.Runtime.InteropServices.RuntimeInformation.dll'
2532-
Copy-Item -Exclude $dontCopy -Recurse $src/* $dest
2574+
# Clean up
2575+
if($needRegister)
2576+
{
2577+
$regVar = PowerShellGet\Get-PSRepository -Name $RepositoryName -ErrorAction SilentlyContinue
2578+
if($regVar)
2579+
{
2580+
log "Unregistering PSRepository with name: $RepositoryName"
2581+
PowerShellGet\UnRegister-PSRepository -Name $RepositoryName
2582+
}
25332583
}
25342584
}
25352585

docs/building/internals.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ We are calling `dotnet` tool build for `$Top` directory
1616
### Dummy dependencies
1717

1818
We use dummy dependencies between projects to leverage `dotnet` build functionality.
19-
For example, `src\powershell-win-core\powershell-win-core.csproj` has dependency on `Microsoft.PowerShell.Commands.Diagnostics.csproj`,
19+
For example, `src\powershell-win-core\powershell-win-core.csproj` has dependency on `Microsoft.PowerShell.PSReadLine`,
2020
but in reality, there is no build dependency.
2121

2222
Dummy dependencies allows us to build just `$Top` folder, instead of building several folders.

docs/testing-guidelines/CodeCoverageAnalysis.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ The following table shows the status for the above commit, dated 06/18/2017
1919
| Microsoft.PowerShell.CoreCLR.AssemblyLoadContext | 97.65% |
2020
| Microsoft.PowerShell.CoreCLR.Eventing | 29.91% |
2121
| Microsoft.PowerShell.LocalAccounts | 86.35% |
22+
| Microsoft.PowerShell.PSReadLine | 10.18% |
2223
| Microsoft.PowerShell.Security | 44.44% |
2324
| Microsoft.WSMan.Management | 4.91% |
2425
| System.Management.Automation | 50.42% |
@@ -51,6 +52,10 @@ The following table shows the status for the above commit, dated 06/18/2017
5152

5253
- [ ] Add tests for ETW events. [#4156](https://github.com/PowerShell/PowerShell/issues/4156)
5354

55+
### Microsoft.PowerShell.PSReadLine
56+
57+
- [ ] We need tests from PSReadline repo or ignore coverage data for this module. (This will be filtered out.)
58+
5459
### Microsoft.PowerShell.Security
5560

5661
- [ ] Add tests for *-Acl cmdlets. [4157] (https://github.com/PowerShell/PowerShell/issues/4157)

nuget.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
66
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
77
<add key="powershell-core" value="https://powershell.myget.org/F/powershell-core/api/v3/index.json" />
8-
<add key="PSGallery" value="https://www.powershellgallery.com/api/v2/" />
98
</packageSources>
109
</configuration>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/********************************************************************++
2+
Copyright (c) Microsoft Corporation. All rights reserved.
3+
--********************************************************************/
4+
5+
using System.Reflection;
6+
using System.Runtime.InteropServices;
7+
8+
// General Information about an assembly is controlled through the following
9+
// set of attributes. Change these attribute values to modify the information
10+
// associated with an assembly.
11+
[assembly: AssemblyTrademark("")]
12+
13+
// Setting ComVisible to false makes the types in this assembly not visible
14+
// to COM components. If you need to access a type in this assembly from
15+
// COM, set the ComVisible attribute to true on that type.
16+
[assembly: ComVisible(false)]
17+
18+
// The following GUID is for the ID of the typelib if this project is exposed to COM
19+
[assembly: Guid("36053fb0-0bd0-4a1c-951c-b2ec109deca3")]

0 commit comments

Comments
 (0)