mirror of
https://github.com/PowerShell/PowerShell.git
synced 2024-11-23 01:34:19 +08:00
Make Microsoft feeds the default (#24098)
This commit is contained in:
parent
5eb9ae43f5
commit
8a8f2d4b23
3
.gitignore
vendored
3
.gitignore
vendored
@ -101,3 +101,6 @@ StartupProfileData-NonInteractive
|
||||
|
||||
# Ignore logfiles
|
||||
logfile/*
|
||||
|
||||
# Ignore nuget.config because it is dynamically generated
|
||||
nuget.config
|
||||
|
@ -5,7 +5,10 @@ steps:
|
||||
- pwsh: |
|
||||
$configPath = "${env:NugetConfigDir}/nuget.config"
|
||||
Import-Module ${{ parameters.repoRoot }}/build.psm1 -Force
|
||||
New-NugetConfigFile -NugetFeedUrl $(PowerShellCore_PublicPackages) -UserName $(AzDevopsFeedUserNameKVPAT) -ClearTextPAT $(mscodehubPackageReadPat) -FeedName AzDevOpsFeed -Destination "${env:NugetConfigDir}"
|
||||
|
||||
$powerShellPublicPackages = [NugetPackageSource] @{Url = '$(PowerShellCore_PublicPackages)'; Name= 'AzDevOpsFeed'}
|
||||
|
||||
New-NugetConfigFile -NugetPackageSource $powerShellPublicPackages -UserName $(AzDevopsFeedUserNameKVPAT) -ClearTextPAT $(mscodehubPackageReadPat) -Destination "${env:NugetConfigDir}"
|
||||
if(-not (Test-Path $configPath))
|
||||
{
|
||||
throw "nuget.config is not created"
|
||||
@ -20,8 +23,11 @@ steps:
|
||||
- pwsh: |
|
||||
$configPath = "${env:NugetConfigDir}/nuget.config"
|
||||
Import-Module ${{ parameters.repoRoot }}/build.psm1 -Force
|
||||
New-NugetConfigFile -NugetFeedUrl $(PowerShellCore_PublicPackages) -UserName $(AzDevopsFeedUserNameKVPAT) -ClearTextPAT $(mscodehubPackageReadPat) -FeedName AzDevOpsFeed -Destination "${env:NugetConfigDir}"
|
||||
if(-not (Test-Path $configPath))
|
||||
|
||||
$powerShellPublicPackages = [NugetPackageSource] @{Url = '$(PowerShellCore_PublicPackages)'; Name= 'AzDevOpsFeed'}
|
||||
|
||||
New-NugetConfigFile -NugetPackageSource $powerShellPublicPackages -UserName $(AzDevopsFeedUserNameKVPAT) -ClearTextPAT $(mscodehubPackageReadPat) -Destination "${env:NugetConfigDir}"
|
||||
if (-not (Test-Path $configPath))
|
||||
{
|
||||
throw "nuget.config is not created"
|
||||
}
|
||||
|
@ -50,6 +50,13 @@ jobs:
|
||||
|
||||
- template: /tools/releaseBuild/azureDevOps/templates/insert-nuget-config-azfeed.yml
|
||||
|
||||
- pwsh: |
|
||||
Import-Module .\tools\ci.psm1
|
||||
Switch-PSNugetConfig -Source Public
|
||||
displayName: Switch to public feeds
|
||||
condition: succeeded()
|
||||
workingDirectory: $(repoPath)
|
||||
|
||||
- pwsh: |
|
||||
Import-Module .\tools\ci.psm1
|
||||
Invoke-CIInstall -SkipUser
|
||||
|
88
build.psm1
88
build.psm1
@ -307,6 +307,9 @@ function Start-PSBuild {
|
||||
# it's useful for development, to do a quick changes in the engine
|
||||
[switch]$SMAOnly,
|
||||
|
||||
# Use nuget.org instead of the PowerShell specific feed
|
||||
[switch]$UseNuGetOrg,
|
||||
|
||||
# These runtimes must match those in project.json
|
||||
# We do not use ValidateScript since we want tab completion
|
||||
# If this parameter is not provided it will get determined automatically.
|
||||
@ -362,6 +365,12 @@ function Start-PSBuild {
|
||||
}
|
||||
}
|
||||
|
||||
if ($UseNuGetOrg) {
|
||||
Switch-PSNugetConfig -Source Public
|
||||
} else {
|
||||
Write-Verbose -Message "Using default feeds which are Microsoft, use `-UseNuGetOrg` to switch to Public feeds" -Verbose
|
||||
}
|
||||
|
||||
function Stop-DevPowerShell {
|
||||
Get-Process pwsh* |
|
||||
Where-Object {
|
||||
@ -718,6 +727,29 @@ Fix steps:
|
||||
}
|
||||
}
|
||||
|
||||
function Switch-PSNugetConfig {
|
||||
param(
|
||||
[ValidateSet('Public', 'Private')]
|
||||
[string] $Source = 'Public'
|
||||
)
|
||||
|
||||
if ( $Source -eq 'Public') {
|
||||
$dotnetSdk = [NugetPackageSource] @{Url = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v2'; Name = 'dotnet' }
|
||||
$gallery = [NugetPackageSource] @{Url = 'https://www.powershellgallery.com/api/v2/'; Name = 'psgallery' }
|
||||
$nugetorg = [NugetPackageSource] @{Url = 'https://api.nuget.org/v3/index.json'; Name = 'nuget.org' }
|
||||
|
||||
New-NugetConfigFile -NugetPackageSource $nugetorg, $dotnetSdk -Destination "$PSScriptRoot/"
|
||||
New-NugetConfigFile -NugetPackageSource $gallery -Destination "$PSScriptRoot/src/Modules/"
|
||||
} elseif ( $Source -eq 'Private') {
|
||||
$powerShellPackages = [NugetPackageSource] @{Url = 'https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/nuget/v3/index.json'; Name = 'powershell' }
|
||||
|
||||
New-NugetConfigFile -NugetPackageSource $powerShellPackages -Destination "$PSScriptRoot/"
|
||||
New-NugetConfigFile -NugetPackageSource $powerShellPackages -Destination "$PSScriptRoot/src/Modules/"
|
||||
} else {
|
||||
throw "Unknown source: $Source"
|
||||
}
|
||||
}
|
||||
|
||||
function Test-ShouldGenerateExperimentalFeatures
|
||||
{
|
||||
param(
|
||||
@ -1284,9 +1316,14 @@ function Start-PSPester {
|
||||
[Parameter(ParameterSetName='Wait', Mandatory=$true,
|
||||
HelpMessage='Wait for the debugger to attach to PowerShell before Pester starts. Debug builds only!')]
|
||||
[switch]$Wait,
|
||||
[switch]$SkipTestToolBuild
|
||||
[switch]$SkipTestToolBuild,
|
||||
[switch]$UseNuGetOrg
|
||||
)
|
||||
|
||||
if ($UseNuGetOrg) {
|
||||
Switch-PSNugetConfig -Source Public
|
||||
}
|
||||
|
||||
if (-not (Get-Module -ListAvailable -Name $Pester -ErrorAction SilentlyContinue | Where-Object { $_.Version -ge "4.2" } ))
|
||||
{
|
||||
Restore-PSPester
|
||||
@ -3394,36 +3431,67 @@ function New-TestPackage
|
||||
[System.IO.Compression.ZipFile]::CreateFromDirectory($packageRoot, $packagePath)
|
||||
}
|
||||
|
||||
function New-NugetConfigFile
|
||||
{
|
||||
class NugetPackageSource {
|
||||
[string] $Url
|
||||
[string] $Name
|
||||
}
|
||||
|
||||
function New-NugetConfigFile {
|
||||
param(
|
||||
[Parameter(Mandatory=$true)] [string] $NugetFeedUrl,
|
||||
[Parameter(Mandatory=$true)] [string] $FeedName,
|
||||
[Parameter(Mandatory=$true)] [string] $UserName,
|
||||
[Parameter(Mandatory=$true)] [string] $ClearTextPAT,
|
||||
[Parameter(Mandatory=$true)] [string] $Destination
|
||||
[Parameter(Mandatory = $true, ParameterSetName ='user')]
|
||||
[Parameter(Mandatory = $true, ParameterSetName ='nouser')]
|
||||
[NugetPackageSource[]] $NugetPackageSource,
|
||||
|
||||
[Parameter(Mandatory = $true)] [string] $Destination,
|
||||
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'user')]
|
||||
[string] $UserName,
|
||||
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'user')]
|
||||
[string] $ClearTextPAT
|
||||
)
|
||||
|
||||
$nugetConfigTemplate = @'
|
||||
$nugetConfigHeaderTemplate = @'
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<clear />
|
||||
'@
|
||||
|
||||
$nugetPackageSourceTemplate = @'
|
||||
<add key="[FEEDNAME]" value="[FEED]" />
|
||||
'@
|
||||
$nugetPackageSourceFooterTemplate = @'
|
||||
</packageSources>
|
||||
<disabledPackageSources>
|
||||
<clear />
|
||||
</disabledPackageSources>
|
||||
'@
|
||||
$nugetCredentialsTemplate = @'
|
||||
<packageSourceCredentials>
|
||||
<[FEEDNAME]>
|
||||
<add key="Username" value="[USERNAME]" />
|
||||
<add key="ClearTextPassword" value="[PASSWORD]" />
|
||||
</[FEEDNAME]>
|
||||
</packageSourceCredentials>
|
||||
'@
|
||||
$nugetConfigFooterTemplate = @'
|
||||
</configuration>
|
||||
'@
|
||||
$content = $nugetConfigHeaderTemplate
|
||||
|
||||
$content = $nugetConfigTemplate.Replace('[FEED]', $NugetFeedUrl).Replace('[FEEDNAME]', $FeedName).Replace('[USERNAME]', $UserName).Replace('[PASSWORD]', $ClearTextPAT)
|
||||
[NugetPackageSource]$source = $null
|
||||
foreach ($source in $NugetPackageSource) {
|
||||
$content += $nugetPackageSourceTemplate.Replace('[FEED]', $source.Url).Replace('[FEEDNAME]', $source.Name)
|
||||
}
|
||||
|
||||
$content += $nugetPackageSourceFooterTemplate
|
||||
|
||||
if ($UserName -or $ClearTextPAT) {
|
||||
$content += $nugetCredentialsTemplate.Replace('[USERNAME]', $UserName).Replace('[PASSWORD]', $ClearTextPAT)
|
||||
}
|
||||
|
||||
$content += $nugetConfigFooterTemplate
|
||||
|
||||
Set-Content -Path (Join-Path $Destination 'nuget.config') -Value $content -Force
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ The build module works on a best-effort basis for other distributions.
|
||||
|
||||
Using Git requires it to be set up correctly;
|
||||
refer to the [Working with the PowerShell Repository](../git/README.md),
|
||||
[README](../../README.md), and [Contributing Guidelines](../../.github/CONTRIBUTING.md).
|
||||
[Readme](../../README.md), and [Contributing Guidelines](../../.github/CONTRIBUTING.md).
|
||||
|
||||
**This guide assumes that you have recursively cloned the PowerShell repository and `cd`ed into it.**
|
||||
|
||||
@ -63,7 +63,7 @@ If you have followed the toolchain setup section above, you should have PowerShe
|
||||
|
||||
```powershell
|
||||
Import-Module ./build.psm1
|
||||
Start-PSBuild
|
||||
Start-PSBuild -UseNuGetOrg
|
||||
```
|
||||
|
||||
Congratulations! If everything went right, PowerShell is now built.
|
||||
@ -72,4 +72,4 @@ The `Start-PSBuild` script will output the location of the executable:
|
||||
`./src/powershell-unix/bin/Debug/net6.0/linux-x64/publish/pwsh`.
|
||||
|
||||
You should now be running the PowerShell Core that you just built, if you run the above executable.
|
||||
You can run our cross-platform Pester tests with `Start-PSPester`, and our xUnit tests with `Start-PSxUnit`.
|
||||
You can run our cross-platform Pester tests with `Start-PSPester -UseNuGetOrg`, and our xUnit tests with `Start-PSxUnit`.
|
||||
|
@ -34,6 +34,6 @@ We cannot do this for you in the build module due to #[847][].
|
||||
|
||||
## Build using our module
|
||||
|
||||
Start a PowerShell session by running `pwsh`, and then use `Start-PSBuild` from the module.
|
||||
Start a PowerShell session by running `pwsh`, and then use `Start-PSBuild -UseNuGetOrg` from the module.
|
||||
|
||||
After building, PowerShell will be at `./src/powershell-unix/bin/Debug/net6.0/osx-x64/publish/pwsh`.
|
||||
|
@ -11,7 +11,7 @@ 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
|
||||
[Readme](../../README.md) and
|
||||
[Contributing Guidelines](../../.github/CONTRIBUTING.md).
|
||||
|
||||
This guide assumes that you have recursively cloned the PowerShell repository and `cd`ed into it.
|
||||
@ -56,7 +56,7 @@ We maintain a [PowerShell module](../../build.psm1) with the function `Start-PSB
|
||||
|
||||
```powershell
|
||||
Import-Module ./build.psm1
|
||||
Start-PSBuild -Clean -PSModuleRestore
|
||||
Start-PSBuild -Clean -PSModuleRestore -UseNuGetOrg
|
||||
```
|
||||
|
||||
Congratulations! If everything went right, PowerShell is now built and executable as `./src/powershell-win-core/bin/Debug/net6.0/win7-x64/publish/pwsh.exe`.
|
||||
@ -77,7 +77,7 @@ You can run our cross-platform Pester tests with `Start-PSPester`.
|
||||
|
||||
```powershell
|
||||
Import-Module ./build.psm1
|
||||
Start-PSPester
|
||||
Start-PSPester -UseNuGetOrg
|
||||
```
|
||||
|
||||
## Building in Visual Studio
|
||||
|
@ -2,8 +2,7 @@
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<clear />
|
||||
<add key="dotnet" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v2" />
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||
<add key="powershell" value="https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/nuget/v3/index.json" />
|
||||
</packageSources>
|
||||
<disabledPackageSources>
|
||||
<clear />
|
||||
|
@ -2,7 +2,7 @@
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<clear />
|
||||
<add key="PSGallery" value="https://www.powershellgallery.com/api/v2/" />
|
||||
<add key="powershell" value="https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/nuget/v3/index.json" />
|
||||
</packageSources>
|
||||
<disabledPackageSources>
|
||||
<clear />
|
||||
|
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<clear />
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<clear />
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||
<add key="benchmark-dotnet-prerelease" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/benchmark-dotnet-prerelease/nuget/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<clear />
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
<disabledPackageSources>
|
||||
<clear />
|
||||
</disabledPackageSources>
|
||||
</configuration>
|
@ -105,7 +105,7 @@ function Invoke-CIBuild
|
||||
Start-PSBuild -Configuration 'CodeCoverage' -PSModuleRestore -CI -ReleaseTag $releaseTag
|
||||
}
|
||||
|
||||
Start-PSBuild -PSModuleRestore -Configuration 'Release' -CI -ReleaseTag $releaseTag
|
||||
Start-PSBuild -PSModuleRestore -Configuration 'Release' -CI -ReleaseTag $releaseTag -UseNuGetOrg
|
||||
Save-PSOptions
|
||||
|
||||
$options = (Get-PSOptions)
|
||||
@ -128,6 +128,10 @@ function Invoke-CIInstall
|
||||
[switch]
|
||||
$SkipUser
|
||||
)
|
||||
|
||||
# Switch to public sources in CI
|
||||
Switch-PSNugetConfig -Source Public
|
||||
|
||||
# Make sure we have all the tags
|
||||
Sync-PSTags -AddRemoteIfMissing
|
||||
|
||||
@ -480,6 +484,9 @@ function Invoke-CIFinish
|
||||
[string[]] $Stage = ('Build','Package')
|
||||
)
|
||||
|
||||
# Switch to public sources in CI
|
||||
Switch-PSNugetConfig -Source Public
|
||||
|
||||
if ($PSEdition -eq 'Core' -and ($IsLinux -or $IsMacOS) -and $Stage -contains 'Build') {
|
||||
return New-LinuxPackage
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user