Skip to content

Add opt-in isolated source-index tool restore - #16822

Closed
davidfowl wants to merge 1 commit into
mainfrom
davidfowl/source-index-isolate-nuget-config
Closed

davidfowl wants to merge 1 commit into
mainfrom
davidfowl/source-index-isolate-nuget-config

Conversation

@davidfowl

@davidfowl davidfowl commented May 15, 2026 •

Copy link
Copy Markdown
Member

1ES Network Isolation reported dotnet.exe probing api.nuget.org during the source-index stage1 tool install step. The existing dotnet tool install --source <dnceng feed> commands add the approved feed, but still allow NuGet to inherit machine/user package sources.

Summary

This adds an opt-in source-index parameter, sourceIndexUseIsolatedNuGetConfig, defaulting to false so existing consumers keep the current restore behavior.

When the parameter is set to true, the source-index stage1 publish template builds an isolated temporary nuget.config under $(Agent.TempDirectory)/.source-index before installing source-index tools. The opt-in path:

  • Creates the source-index root and tools directory.
  • Runs dotnet new nugetconfig --force using the stage1 SDK installed under $(Agent.TempDirectory)/dotnet.
  • Removes the generated NuGet.org source from that temp config.
  • Adds only the approved source-index feed from sourceIndexPackageSource.
  • Installs BinLogToSln and UploadIndexStage1 with --configfile <temp nuget.config> and the existing temp tool path.

The step still runs from $(Agent.TempDirectory) so it avoids the repo global.json, and native dotnet calls follow the existing Arcade YAML pattern of checking $LASTEXITCODE and failing with Write-Error / exit 1.

Usage

Consumers can opt in through source-index parameters, for example:

sourceIndexParams:
  sourceIndexUseIsolatedNuGetConfig: true

The lower-level source-index job/step templates also accept sourceIndexUseIsolatedNuGetConfig: true directly.

Validation

  • Parsed the changed YAML successfully.
  • Parsed the embedded PowerShell successfully.
  • Exercised the opt-in config generation, NuGet.org source removal, and source-index source addition flow locally. The final config contained only <clear /> plus the dnceng source-index feed.

The source-index stage1 tool install step currently runs
'dotnet tool install ... --source <dnceng feed>'. NuGet's --source
flag only adds a feed; the machine/user-level NuGet configuration is
still inherited, so dotnet can probe api.nuget.org. 1ES Network
Isolation flags this as an outbound connection warning during Aspire's
CI runs (definitionId 1602).

Add a sourceIndexUseIsolatedNuGetConfig parameter, defaulting to false,
so existing source-index consumers keep the current restore behavior.
When the parameter is set to true, the download step builds an isolated
nuget.config under $(Agent.TempDirectory)/.source-index:

  1. Create the .source-index and tools directories.
  2. Run 'dotnet new nugetconfig --force --output <sourceIndexRoot>'.
     The emitted template contains <clear/> in <packageSources>,
     so machine/user sources are not inherited.
  3. Remove the generated NuGet.org package source using
     'dotnet nuget remove source ... --configfile <temp nuget.config>'.
  4. Add only the approved 'source-index' feed via
     'dotnet nuget add source ... --configfile <temp nuget.config>'.
  5. 'dotnet tool install --configfile <temp nuget.config>' for
     both BinLogToSln and UploadIndexStage1.

The step still runs from $(Agent.TempDirectory) so the repo's
global.json is not used. Native dotnet calls follow the existing
Arcade YAML pattern of checking $LASTEXITCODE and failing the step
with Write-Error/exit 1.

Co-authored-by: Copilot <[email protected]>
@davidfowl
davidfowl force-pushed the davidfowl/source-index-isolate-nuget-config branch from c3d23b8 to f23d432 Compare May 15, 2026 04:09
@davidfowl davidfowl changed the title Isolate source-index tool restore sources Add opt-in isolated source-index tool restore May 15, 2026
@akoeplinger

Copy link
Copy Markdown
Member

@davidfowl this is not the right fix. The behavior you/Copilot talk about is the case for --add-source but not for --source which is what arcade main uses since #16278.

I assume it got confused because you use arcade 10.0 in aspire which was missing this fix, I opened the backport in #16850

@davidfowl

Copy link
Copy Markdown
Member Author

Yea I assumed that. As long as it gets fixed I'm good closing this

@davidfowl davidfowl closed this May 19, 2026
@akoeplinger
akoeplinger deleted the davidfowl/source-index-isolate-nuget-config branch May 20, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants