Repository navigation
Replace OneGet assemblies with these generated by OneGet.org #2711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
66f922b
f850d56
a2efa9a
5229570
0ec62d2
e3706e8
8265a45
7160295
de331a8
391a787
69e1ed3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,6 +63,7 @@ function Start-PSBuild { | |
| [switch]$ResGen, | ||
| [switch]$TypeGen, | ||
| [switch]$Clean, | ||
| [switch]$PSModuleRestore, | ||
|
|
||
| # this switch will re-build only System.Management.Automation.dll | ||
| # it's useful for development, to do a quick changes in the engine | ||
|
|
@@ -397,6 +398,16 @@ cmd.exe /C cd /d "$location" "&" "$($vcVarsPath)\vcvarsall.bat" "$NativeHostArch | |
| } finally { | ||
| Pop-Location | ||
| } | ||
|
|
||
| if($PSModuleRestore) | ||
| { | ||
| # downloading the PackageManagement module | ||
| # $Options.Output is pointing to something like "...\src\powershell-win-core\bin\Debug\netcoreapp1.0\win10-x64\publish\powershell.exe", | ||
| # so we need to get its parent directory | ||
| $publishPath = Split-Path $Options.Output -Parent | ||
| log "Restore PowerShell modules to $publishPath" | ||
| Restore-PSModule -Name @('PackageManagement','PowerShellGet') -Destination (Join-Path -Path $publishPath -ChildPath "Modules") | ||
| } | ||
| } | ||
|
|
||
| function Compress-TestContent { | ||
|
|
@@ -993,10 +1004,11 @@ function Start-PSBootstrap { | |
| $Deps += "openssl" | ||
|
|
||
| # Install dependencies | ||
| Start-NativeExecution { brew install $Deps } | ||
| # ignore exitcode, because they may be already installed | ||
| Start-NativeExecution { brew install $Deps } -IgnoreExitcode | ||
|
|
||
| # Install patched version of curl | ||
| Start-NativeExecution { brew install curl --with-openssl } | ||
| Start-NativeExecution { brew install curl --with-openssl } -IgnoreExitcode | ||
| } | ||
|
|
||
| # Install [fpm](https://github.com/jordansissel/fpm) and [ronn](https://github.com/rtomayko/ronn) | ||
|
|
@@ -2104,15 +2116,15 @@ function script:Convert-PSObjectToHashtable { | |
|
|
||
| # this function wraps native command Execution | ||
| # for more information, read https://mnaoumov.wordpress.com/2015/01/11/execution-of-external-commands-in-powershell-done-right/ | ||
| function script:Start-NativeExecution([scriptblock]$sb) | ||
| function script:Start-NativeExecution([scriptblock]$sb, [switch]$IgnoreExitcode) | ||
| { | ||
| $backupEAP = $script:ErrorActionPreference | ||
| $script:ErrorActionPreference = "Continue" | ||
| try { | ||
| & $sb | ||
| # note, if $sb doesn't have a native invocation, $LASTEXITCODE will | ||
| # point to the obsolete value | ||
| if ($LASTEXITCODE -ne 0) { | ||
| if ($LASTEXITCODE -ne 0 -and -not $IgnoreExitcode) { | ||
| throw "Execution of {$sb} failed with exit code $LASTEXITCODE" | ||
| } | ||
| } finally { | ||
|
|
@@ -2477,7 +2489,6 @@ function Start-CrossGen { | |
| "Microsoft.PowerShell.CoreCLR.AssemblyLoadContext.dll", | ||
| "Microsoft.PowerShell.CoreCLR.Eventing.dll", | ||
| "Microsoft.PowerShell.ConsoleHost.dll", | ||
| "Microsoft.PowerShell.PackageManagement.dll", | ||
| "Microsoft.PowerShell.PSReadLine.dll", | ||
| "System.Management.Automation.dll" | ||
| ) | ||
|
|
@@ -2538,6 +2549,99 @@ function Clear-PSRepo | |
| } | ||
| } | ||
|
|
||
| # Install PowerShell modules such as PackageManagement, PowerShellGet | ||
| function Restore-PSModule | ||
| { | ||
| [CmdletBinding()] | ||
| param( | ||
| [Parameter(Mandatory=$true)] | ||
| [ValidateNotNullOrEmpty()] | ||
| [string[]]$Name, | ||
|
|
||
| [Parameter(Mandatory=$true)] | ||
| [ValidateNotNullOrEmpty()] | ||
| [string]$Destination, | ||
|
|
||
| [string]$SourceLocation="https://powershell.myget.org/F/powershellmodule/api/v2/", | ||
|
|
||
| [string]$RequiredVersion | ||
| ) | ||
|
|
||
| $needRegister = $true | ||
| $RepositoryName = "mygetpsmodule" | ||
|
|
||
| # Check if the PackageManagement works in the base-oS or PowerShellCore | ||
| Get-PackageProvider -Name NuGet -ForceBootstrap -Verbose:$VerbosePreference | ||
| Get-PackageProvider -Name PowerShellGet -Verbose:$VerbosePreference | ||
|
|
||
| # Get the existing registered PowerShellGet repositories | ||
| $psrepos = PowerShellGet\Get-PSRepository | ||
|
|
||
| foreach ($repo in $psrepos) | ||
| { | ||
| if(($repo.SourceLocation -eq $SourceLocation) -or ($repo.SourceLocation.TrimEnd("/") -eq $SourceLocation.TrimEnd("/"))) | ||
| { | ||
| # found a registered repository that matches the source location | ||
| $needRegister = $false | ||
| $RepositoryName = $repo.Name | ||
| break | ||
| } | ||
| } | ||
|
|
||
| if($needRegister) | ||
| { | ||
| $regVar = PowerShellGet\Get-PSRepository -Name $RepositoryName -ErrorAction SilentlyContinue | ||
| if($regVar) | ||
| { | ||
| PowerShellGet\UnRegister-PSRepository -Name $RepositoryName | ||
| } | ||
|
|
||
| log "Registering PSRepository with name: $RepositoryName and sourcelocation: $SourceLocation" | ||
| PowerShellGet\Register-PSRepository -Name $RepositoryName -SourceLocation $SourceLocation -ErrorVariable ev -verbose | ||
| if($ev) | ||
| { | ||
| throw ("Failed to register repository '{0}'" -f $RepositoryName) | ||
| } | ||
|
|
||
| $regVar = PowerShellGet\Get-PSRepository -Name $RepositoryName | ||
| if(-not $regVar) | ||
| { | ||
| throw ("'{0}' is not registered" -f $RepositoryName) | ||
| } | ||
| } | ||
|
|
||
| log ("Name='{0}', Destination='{1}', Repository='{2}'" -f $Name, $Destination, $RepositoryName) | ||
|
|
||
| $Name | ForEach-Object { | ||
|
|
||
| $command = @{ | ||
| Name=$_ | ||
| Path = $Destination | ||
| Repository =$RepositoryName | ||
| } | ||
|
|
||
| if($RequiredVersion) | ||
| { | ||
| $command.Add("RequiredVersion", $RequiredVersion) | ||
| } | ||
|
|
||
| # pull down the module | ||
| log "running save-module $Name" | ||
| PowerShellGet\Save-Module @command -Force -Verbose | ||
| } | ||
|
|
||
| # Clean up | ||
| if($needRegister) | ||
| { | ||
| $regVar = PowerShellGet\Get-PSRepository -Name $RepositoryName -ErrorAction SilentlyContinue | ||
| if($regVar) | ||
| { | ||
| log "Unregistering PSRepository with name: $RepositoryName" | ||
| PowerShellGet\UnRegister-PSRepository -Name $RepositoryName | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can be simplified with below
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
| } | ||
|
|
||
|
|
||
| $script:RESX_TEMPLATE = @' | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
|
|
||
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not needed as we are registering only if we there is no existing repo with the same source location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the repository exists, $needRegister is false. This code won't get executed.
Only the case when the same repo exists but is pointing to some other source location.
In reply to: 88761457 [](ancestors = 88761457)