From deb0d90b2f311cc90e16b1932c02981868a6652c Mon Sep 17 00:00:00 2001 From: Vladimir Morozov Date: Fri, 23 Oct 2026 17:28:58 -0700 Subject: [PATCH 1/3] [0.85] Route npm, Yarn, and NuGet restores through PackageFeedProxy Keep ADO-only V8 packages on their mapped feed and preserve publication destinations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .ado/README.md | 35 ++++++++++++------- .ado/build-template.yml | 3 +- .ado/scripts/build.js | 2 +- .ado/templates/auth-npm-feed.yml | 3 +- .ado/templates/prepare-build-env.yml | 30 ++++++++++++++-- .ado/templates/prepare-js-env.yml | 2 +- .ado/templates/react-native-init-windows.yml | 17 ++++++++- .ado/variables/shared.yml | 6 ++-- NuGet.Config | 13 ++++++- vnext/Scripts/EnableInternalWinAppSDKFeed.ps1 | 17 ++++++--- .../NuGetRestoreForceEvaluateAllSolutions.ps1 | 4 +-- 11 files changed, 100 insertions(+), 32 deletions(-) diff --git a/.ado/README.md b/.ado/README.md index 85211d70fe3..2a58081b60d 100644 --- a/.ado/README.md +++ b/.ado/README.md @@ -80,14 +80,23 @@ All repository resources pin `ref: refs/tags/release`. ## Package feed and network isolation ISS agents run under 1ES **Network Isolation**, which blocks egress to public CDNs. -The pipelines source packages only from the `ms/react-native-public` Azure Artifacts -feed and neutralize three background egress attempts that green builds would -otherwise hide: - -- **Feed registry:** `variables/shared.yml` points npm and Yarn at the - `ms/react-native-public` feed (`NPM_CONFIG_REGISTRY` / `YARN_NPM_REGISTRY_SERVER`). - On CI, `templates/auth-npm-feed.yml` mints a managed-identity token and writes it - to `~/.npmrc` and `~/.yarnrc.yml` before any install. +The pipelines use approved package feeds and neutralize three background egress +attempts that green builds would otherwise hide: + +- **NuGet restores:** the root `NuGet.Config` maps NuGet.org dependencies to + `https://packagefeedproxy.microsoft.io/nuget/v3/index.json` anonymously. + Only `ReactNative.V8Jsi.Windows*` and `Microsoft.JavaScript.V8*` use the + `ms/react-native-public` ADO feed, where these V8 packages are published. + CI imports this policy for generated apps/libraries and third-party configs; + CLI-init tests also retain their local feed for freshly built RNW packages. + NuGet 6.0 or later is required to enforce these source mappings. + BinSkim downloads use the same proxy instead of nuget.org. +- **Package registries:** `variables/shared.yml` routes npm/npx and Yarn through + the anonymous PackageFeedProxy (`NPM_CONFIG_REGISTRY` / + `YARN_NPM_REGISTRY_SERVER`) in both PR and Continuous validation. + `templates/auth-npm-feed.yml` keeps the managed-identity token scoped to direct + Azure Artifacts requests in `~/.npmrc` and passes it to the Verdaccio uplink; + Yarn does not send the token to the proxy. - **Verdaccio (CLI init tests):** `verdaccio/generate-config.js` emits the config at runtime, so the uplink targets the feed (with the CI token when present) while local packages still publish offline. The former static `config.yaml` was removed. @@ -100,10 +109,12 @@ otherwise hide: reapplies the same policy per job as an interim belt until the updated image ships; it can be dropped once a rebuilt image is confirmed clean. -Public PR builds read this feed **anonymously**, so they can only restore versions -an authenticated identity has already saved. A scheduled feed warm-up maintained on -`main` re-pulls the latest patch of every npm/NuGet line already in the feed to keep -those anonymous restores working. +Public PR Verdaccio requests to the Azure Artifacts feed remain **anonymous** and +can only restore versions an authenticated identity has already saved. The +scheduled feed warm-up maintained on `main` keeps that feed populated. +PackageFeedProxy restores do not depend on that warm-up. Publishing and +authenticated feed maintenance keep their existing endpoints; NuGet defaults +shipped in generated apps/libraries are unchanged. ## SDL and Component Governance diff --git a/.ado/build-template.yml b/.ado/build-template.yml index 1b8db0a7e8c..119a460bca6 100644 --- a/.ado/build-template.yml +++ b/.ado/build-template.yml @@ -164,7 +164,7 @@ extends: version: '24.x' displayName: Use Node.js 24.x - # CI is network-isolated; authenticate to the package feed before any npm/Yarn use. + # CI is network-isolated; acquire the feed token used by the Verdaccio uplink. - ${{ if eq(parameters.buildEnvironment, 'Continuous') }}: - template: .ado/templates/auth-npm-feed.yml@self @@ -551,4 +551,3 @@ extends: parameters: buildEnvironment: ${{ parameters.buildEnvironment }} AgentPool: ${{ parameters.AgentPool }} - diff --git a/.ado/scripts/build.js b/.ado/scripts/build.js index db46551eba9..780e78b868f 100644 --- a/.ado/scripts/build.js +++ b/.ado/scripts/build.js @@ -16,7 +16,7 @@ const sourcesPath = path.resolve(__dirname, "..", ".."); const binskimPackageName = "Microsoft.CodeAnalysis.BinSkim"; const binskimVersion = "4.4.9"; -const binskimNuGetSource = "https://api.nuget.org/v3/index.json"; +const binskimNuGetSource = "https://packagefeedproxy.microsoft.io/nuget/v3/index.json"; const options = { help: { type: "boolean", default: false }, diff --git a/.ado/templates/auth-npm-feed.yml b/.ado/templates/auth-npm-feed.yml index fcb841c459c..8a79d1cab36 100644 --- a/.ado/templates/auth-npm-feed.yml +++ b/.ado/templates/auth-npm-feed.yml @@ -1,4 +1,4 @@ -# Authenticates npm and Yarn 4 to the ms/react-native-public feed with the build's managed identity. +# Acquires a managed-identity token for direct npm requests and the Verdaccio feed uplink. steps: - task: AzureCLI@2 displayName: Authenticate to the package feed @@ -13,4 +13,3 @@ steps: Write-Host "##vso[task.setvariable variable=RNW_NPM_FEED_TOKEN;issecret=true]$token" $reg = '//pkgs.dev.azure.com/ms/react-native/_packaging/react-native-public/npm/registry/' Set-Content -Path (Join-Path $env:USERPROFILE '.npmrc') -Encoding ascii -Value "${reg}:_authToken=$token" - Set-Content -Path (Join-Path $env:USERPROFILE '.yarnrc.yml') -Encoding ascii -Value @('npmAlwaysAuth: true', "npmAuthToken: $token") diff --git a/.ado/templates/prepare-build-env.yml b/.ado/templates/prepare-build-env.yml index 9b8ed04796e..e0da72be878 100644 --- a/.ado/templates/prepare-build-env.yml +++ b/.ado/templates/prepare-build-env.yml @@ -44,11 +44,37 @@ steps: Get-Process -Name BackgroundDownload -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue displayName: Disable VS Installer background download - # The commit tag in the nuspec requires that we use at least nuget 5.8 (because things break with nuget versions before and Vs 16.8 or later) + # NuGet 6.0 or later is required to enforce package source mappings. - task: NuGetToolInstaller@1 displayName: Set NuGet version inputs: - versionSpec: ">=5.8.0" + versionSpec: ">=6.0.0" + + # Third-party configs must retain the repository's sources and mappings under network isolation. + - pwsh: | + [xml] $repoConfig = Get-Content -LiteralPath '$(Build.SourcesDirectory)\NuGet.Config' + $root = Join-Path '$(Build.SourcesDirectory)' 'node_modules' + $globs = @((Join-Path $root '*\windows\NuGet.Config'), (Join-Path $root '@*\*\windows\NuGet.Config')) + $configs = Get-ChildItem -Path $globs -File -ErrorAction SilentlyContinue | + Where-Object { Select-String -Path $_.FullName -Pattern 'api\.nuget\.org' -Quiet -ErrorAction SilentlyContinue } + if (-not $configs) { + Write-Host 'No non-compliant node_modules NuGet.Config files found.' + return + } + foreach ($file in $configs) { + [xml] $config = Get-Content -LiteralPath $file.FullName + if (-not $config.configuration.packageSources) { continue } + foreach ($name in @('packageSources', 'packageSourceMapping')) { + $existing = $config.configuration.SelectSingleNode($name) + if ($existing) { + [void] $config.configuration.RemoveChild($existing) + } + [void] $config.configuration.AppendChild($config.ImportNode($repoConfig.configuration.SelectSingleNode($name), $true)) + } + $config.Save($file.FullName) + Write-Host "Rewrote $($file.FullName) to use the approved NuGet source mappings." + } + displayName: Enforce compliant NuGet feed in node_modules - template: set-appx-platforms.yml parameters: diff --git a/.ado/templates/prepare-js-env.yml b/.ado/templates/prepare-js-env.yml index 0fc69c11a15..2643a5061b0 100644 --- a/.ado/templates/prepare-js-env.yml +++ b/.ado/templates/prepare-js-env.yml @@ -23,7 +23,7 @@ steps: displayName: Ensure npm directory for npx commands condition: eq(variables['Agent.OS'], 'Windows_NT') - # CI is network-isolated; authenticate to the package feed before install. + # CI is network-isolated; acquire the feed token used by the Verdaccio uplink. - ${{ if eq(parameters.buildEnvironment, 'Continuous') }}: - template: auth-npm-feed.yml diff --git a/.ado/templates/react-native-init-windows.yml b/.ado/templates/react-native-init-windows.yml index 57310bae8a0..6bdfa927502 100644 --- a/.ado/templates/react-native-init-windows.yml +++ b/.ado/templates/react-native-init-windows.yml @@ -110,9 +110,12 @@ steps: $configPaths += 'example\NuGet.config' } + [xml] $repoConfig = Get-Content -LiteralPath '$(Build.SourcesDirectory)\NuGet.Config' $sources = [ordered]@{ TestFeed = '$(System.DefaultWorkingDirectory)\NugetTestFeed' - 'react-native' = 'https://pkgs.dev.azure.com/ms/react-native/_packaging/react-native-public/nuget/v3/index.json' + } + foreach ($source in $repoConfig.configuration.packageSources.add) { + $sources[$source.key] = $source.value } foreach ($configPath in $configPaths) { @@ -131,6 +134,18 @@ steps: $element.SetAttribute('value', $source.Value) [void] $packageSources.AppendChild($element) } + $existingMapping = $config.configuration.packageSourceMapping + if ($existingMapping) { + [void] $config.configuration.RemoveChild($existingMapping) + } + $mapping = $config.ImportNode($repoConfig.configuration.packageSourceMapping, $true) + $localSource = $config.CreateElement('packageSource') + $localSource.SetAttribute('key', 'TestFeed') + $pattern = $config.CreateElement('package') + $pattern.SetAttribute('pattern', '*') + [void] $localSource.AppendChild($pattern) + [void] $mapping.AppendChild($localSource) + [void] $config.configuration.AppendChild($mapping) $config.Save((Resolve-Path -LiteralPath $configPath)) Write-Host "Updated $configPath" } diff --git a/.ado/variables/shared.yml b/.ado/variables/shared.yml index 19af99d617c..72187a00d12 100644 --- a/.ado/variables/shared.yml +++ b/.ado/variables/shared.yml @@ -6,9 +6,9 @@ variables: NPM_CONFIG_YES: false NPM_CONFIG_CACHE: $(Agent.TempDirectory)/.npmCache - # Route npm/Yarn through the ms/react-native-public feed (npmjs upstream) on isolated agents - NPM_CONFIG_REGISTRY: https://pkgs.dev.azure.com/ms/react-native/_packaging/react-native-public/npm/registry/ - YARN_NPM_REGISTRY_SERVER: https://pkgs.dev.azure.com/ms/react-native/_packaging/react-native-public/npm/registry/ + # Route npm and Yarn through the anonymous proxy so validation does not require feed authentication. + NPM_CONFIG_REGISTRY: https://packagefeedproxy.microsoft.io/npm/ + YARN_NPM_REGISTRY_SERVER: https://packagefeedproxy.microsoft.io/npm/ # Stop React Native DevTools from fetching its standalone shell binary via DotSlash from a # Facebook CDN on dev-server start, which is blocked under network isolation. The 'dev' diff --git a/NuGet.Config b/NuGet.Config index 2b5dab1ab81..2ab8025878b 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -6,7 +6,8 @@ - + + @@ -14,4 +15,14 @@ --> + + + + + + + + + + diff --git a/vnext/Scripts/EnableInternalWinAppSDKFeed.ps1 b/vnext/Scripts/EnableInternalWinAppSDKFeed.ps1 index e65f4dcfdc7..4f188de3ee9 100644 --- a/vnext/Scripts/EnableInternalWinAppSDKFeed.ps1 +++ b/vnext/Scripts/EnableInternalWinAppSDKFeed.ps1 @@ -9,11 +9,18 @@ Set-Location -Path $RepoRoot try { [xml] $nugetConfig = Get-Content "NuGet.Config" - $newFeed = $nugetConfig.configuration.packageSources.add.clone() - $newFeed.key = "Project.Reunion.nuget.internal"; - $newFeed.value = "https://microsoft.pkgs.visualstudio.com/ProjectReunion/_packaging/Project.Reunion.nuget.internal/nuget/v3/index.json"; - $nugetConfig.configuration.packageSources.AppendChild($newFeed) - $nugetConfig.Save("NuGet.Config") + $feedKey = "Project.Reunion.nuget.internal" + $newFeed = $nugetConfig.CreateElement("add") + $newFeed.SetAttribute("key", $feedKey) + $newFeed.SetAttribute("value", "https://microsoft.pkgs.visualstudio.com/ProjectReunion/_packaging/Project.Reunion.nuget.internal/nuget/v3/index.json") + [void] $nugetConfig.configuration.packageSources.AppendChild($newFeed) + $mapping = $nugetConfig.CreateElement("packageSource") + $mapping.SetAttribute("key", $feedKey) + $pattern = $nugetConfig.CreateElement("package") + $pattern.SetAttribute("pattern", "*") + [void] $mapping.AppendChild($pattern) + [void] $nugetConfig.configuration.packageSourceMapping.AppendChild($mapping) + $nugetConfig.Save("$RepoRoot\NuGet.Config") } finally { diff --git a/vnext/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 b/vnext/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 index b66e7008a14..665ae96c4de 100644 --- a/vnext/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 +++ b/vnext/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 @@ -19,8 +19,8 @@ function Restore-Solution([string] $solution, [string[]] $extraArgs) { try { # Some node_modules packages ship a NuGet.Config that re-adds the public nuget.org feed. That - # breaks the repo's single-ADO-feed compliance and trips corporate network blocks on api.nuget.org. - # Strip any nuget.org source so restore only uses the repo's ADO feed. + # bypasses the approved source policy and trips corporate network blocks on api.nuget.org. + # Strip any nuget.org source so restore uses the approved sources and mappings in the root NuGet.Config. Get-ChildItem -File -Recurse -Path $RepoRoot -Filter NuGet.Config -ErrorAction SilentlyContinue | Where-Object { $_.FullName -match '\\node_modules\\' } | ForEach-Object { $configPath = $_.FullName From 609db78849f66ff5ae9e6baa674714207912141b Mon Sep 17 00:00:00 2001 From: Vladimir Morozov Date: Fri, 23 Oct 2026 17:31:50 -0700 Subject: [PATCH 2/3] [0.85] Add package-feed migration change file Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- ...ative-windows-9c991519-fc65-4a2d-b61e-466a628c8115.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/react-native-windows-9c991519-fc65-4a2d-b61e-466a628c8115.json diff --git a/change/react-native-windows-9c991519-fc65-4a2d-b61e-466a628c8115.json b/change/react-native-windows-9c991519-fc65-4a2d-b61e-466a628c8115.json new file mode 100644 index 00000000000..0711514f23d --- /dev/null +++ b/change/react-native-windows-9c991519-fc65-4a2d-b61e-466a628c8115.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "Route repository and CI package restores through PackageFeedProxy", + "packageName": "react-native-windows", + "email": "vmorozov@microsoft.com", + "dependentChangeType": "patch" +} From 7c1afdd0f49c5a69adf8f01a5013fcb1c09e2686 Mon Sep 17 00:00:00 2001 From: Vladimir Morozov Date: Fri, 23 Oct 2026 18:10:18 -0700 Subject: [PATCH 3/3] [0.85] Address Copilot: clarify internal SDK feed opt-in Direct local internal SDK testing through the helper that adds both the NuGet source and its package mapping. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- NuGet.Config | 6 ++---- vnext/PropertySheets/WinUI.props | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index 2ab8025878b..4e66565749b 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -10,10 +10,8 @@ - - + diff --git a/vnext/PropertySheets/WinUI.props b/vnext/PropertySheets/WinUI.props index 779de8426f4..893663c5ede 100644 --- a/vnext/PropertySheets/WinUI.props +++ b/vnext/PropertySheets/WinUI.props @@ -4,7 +4,8 @@ 2.0.0-experimental3