Skip to content

[release/10.0.1xx] Backport remaining CFSClean fixes - #12396

Open
jonathanpeppers wants to merge 5 commits into
release/10.0.1xxfrom
jonathanpeppers-backport-cfsclean-fixes
Open

[release/10.0.1xx] Backport remaining CFSClean fixes#12396
jonathanpeppers wants to merge 5 commits into
release/10.0.1xxfrom
jonathanpeppers-backport-cfsclean-fixes

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Summary

Backports the remaining non-Maven/Gradle CFSClean fixes from main to release/10.0.1xx, with release-specific conflict resolution that preserves files removed or consolidated on the release branch.

Maven/Gradle backports #12199 (466da4a84) and #12368 (adffb38fd) are intentionally excluded because they are being handled separately.

Original changes

Validation

  • Confirmed the merge-base is exactly origin/release/10.0.1xx and the PR range contains exactly five backport commits.
  • git diff --check origin/release/10.0.1xx...HEAD
  • Parsed all 4 changed Azure Pipelines YAML files and all 8 changed template JSON files.
  • dotnet build src\Microsoft.Android.Templates\Microsoft.Android.Templates.csproj -c Debug -p:RunningOnCI=true -v:minimal -nodeReuse:false
  • Attempted the targeted Xamarin.Android.Build.Tests build; repository preparation was blocked after all three approved-feed runtime-pack restore attempts timed out.

jonathanpeppers and others added 5 commits August 14, 2026 14:49
CFSClean reports network-isolation warnings when tests and CI tooling resolve packages directly from public NuGet endpoints. Route those package downloads through the existing dnceng `dotnet-public` Azure Artifacts feed and rely on the repository `NuGet.config` for generated test projects and the API-docs tool installation.

Direct `.nupkg` test downloads now use the feed's V3 package base address, while obsolete `ExtraNuGetConfigSources` public overrides are removed. No fallback to nuget.org is retained.

`Xamarin.Google.Android.InstallReferrer` 1.1.2.6 is not currently mirrored to `dotnet-public`; `InstallAndRunTests.GradleFBProj` will require that package to be mirrored.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Internal [build 14925232](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=14925232) reported CFSClean violations during **Create MAUI template**. The pipeline needs to suppress three independent .NET network paths:

1. `DOTNET_CLI_WORKLOAD_UPDATE_NOTIFY_DISABLE=true` prevents background workload advertising-manifest updates.
2. `DOTNET_SDK_VULNERABILITY_CHECK_DISABLE=true` prevents the .NET CLI's separate background SDK release/vulnerability/EOL metadata refresh. The SDK invokes this refresh from restoring commands such as `dotnet build` and `dotnet restore`.
3. `NuGetAudit=false` disables NuGet restore's package-advisory lookup. This is a distinct MSBuild property and does not replace the SDK-level variable.

The immediate MAUI violation came from `dotnet new maui`, which runs a restore post-action by default. That restore had no project-specific `NuGet.config`, so it contacted public NuGet and workload advertising-manifest hosts. Passing `--no-restore` creates the template without running that post-action.

This does not remove the intended MAUI restore/build. The following Debug and Release build steps remain unchanged and explicitly pass `--configfile $(Build.SourcesDirectory)/maui/NuGet.config`, keeping package acquisition on the configured sources. Disabling these metadata checks also does not disable package hash/signature validation; it prevents external metadata lookups in network-isolated jobs.

- Retain `DOTNET_SDK_VULNERABILITY_CHECK_DISABLE=true` and add `NuGetAudit=false` alongside it in shared pipeline variables and the internal override.
- Add `--no-restore` to MAUI template creation in the main, public, and internal pipeline definitions.

- Parsed all changed YAML files successfully.
- Ran `git diff --check`.
- Verified every MAUI template-creation variant uses `--no-restore`.
- Verified all three isolation controls remain present where expected.
- Verified `dotnet new --no-restore` creates a project without producing a restore assets file.
- Confirmed the separate SDK behavior in [`RestoringCommand`](https://github.com/dotnet/sdk/blob/8795d0128cf1efbb900edd5cfbd8e9789be10653/src/Cli/dotnet/Commands/Restore/RestoringCommand.cs) and [`SdkReleaseMetadataCache`](https://github.com/dotnet/sdk/blob/8795d0128cf1efbb900edd5cfbd8e9789be10653/src/Cli/dotnet/SdkVulnerability/SdkReleaseMetadataCache.cs).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- declare the standard `skipRestore` symbol in every Android project template
- map `skipRestore` to the user-facing `--no-restore` option through each template's `dotnetcli.host.json`
- prevent `XASdkTests.DotNetNew` from restoring generated projects implicitly
- copy the repository `NuGet.config` into generated projects before builds restore
- route `AndroidMavenLibrary` items with blank repository metadata through `dotnet-public-maven` in test scope

`--no-restore` is presented as a standard `dotnet new` option, but project templates must opt into accepting it by declaring a `skipRestore` boolean symbol and mapping that symbol to `--no-restore` in `dotnetcli.host.json`. This follows the symbol/mapping convention used by the .NET SDK and .NET MAUI templates.

The Android templates intentionally do not add a restore post-action. They therefore preserve their existing default behavior and avoid restoring before test call sites configure approved package versions and feeds. The new option lets `XASdkTests` explicitly document and enforce that expectation before copying the repository `NuGet.config` into generated projects.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Depends on #12336.

The Windows template smoke project is generated under `$(Build.StagingDirectory)`, outside the repository `NuGet.config` hierarchy. Its implicit build restore therefore falls back to the agent's machine NuGet configuration and may access unapproved package feeds.

- Pass `RestoreConfigFile=$(System.DefaultWorkingDirectory)\NuGet.config` to the template build.
- Quote the template creation and build staging paths using Windows path syntax.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
`CodeBehindTests` passed a file path to `CopyNuGetConfig`, which expects a directory and appends `NuGet.config`. This placed the repository configuration in a nested path, so generated projects could miss it and contact external package feeds. Pass the temporary project root instead.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers

Copy link
Copy Markdown
Member Author

/azp run

Copilot AI lite review requested due to automatic review settings August 14, 2026 20:29
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@jonathanpeppers

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
1 pipeline(s) were filtered out due to trigger conditions.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Backport of remaining CFSClean-related changes from main to release/10.0.1xx, focusing on keeping NuGet/Maven access on approved mirrors/feeds and preventing implicit restores from contacting public endpoints in CI and test scenarios.

Changes:

  • Remove direct nuget.org usage in tests/pipelines and switch package downloads to dotnet-public feed URLs.
  • Add --no-restore flows and template support (skipRestore + dotnetcli.host.json mapping) to prevent implicit restore network access.
  • Fix NuGet.config placement/copying in test scenarios and add a small MSBuild target override for Maven repository metadata in test scope.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs Removes explicit api.nuget.org override to rely on repo-approved feeds.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetCLI.cs Adds noRestore option for dotnet new invocation in tests.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs Uses dotnet new --no-restore, copies repo NuGet.config, and applies Maven repo override for wear template builds.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/FilterAssembliesTests.cs Downloads .nupkg directly from dotnet-public flat container and adds a lowercase URL test.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/dotnet-public-maven.targets Adds a test-only target to default empty AndroidMavenLibrary.Repository metadata to dotnet-public-maven.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/CodeBehindTests.cs Fixes CopyNuGetConfig call to pass a directory rather than a file path.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs Removes explicit api.nuget.org override to rely on repo-approved feeds.
src/Microsoft.Android.Templates/androidlib/.template.config/template.json Adds skipRestore symbol so --no-restore can be wired through.
src/Microsoft.Android.Templates/androidlib/.template.config/dotnetcli.host.json Maps skipRestore to --no-restore for dotnet new.
src/Microsoft.Android.Templates/android/.template.config/template.json Adds skipRestore symbol so --no-restore can be wired through.
src/Microsoft.Android.Templates/android/.template.config/dotnetcli.host.json Maps skipRestore to --no-restore for dotnet new.
src/Microsoft.Android.Templates/android-wear/.template.config/template.json Adds skipRestore symbol so --no-restore can be wired through.
src/Microsoft.Android.Templates/android-wear/.template.config/dotnetcli.host.json Maps skipRestore to --no-restore for dotnet new.
src/Microsoft.Android.Templates/android-bindinglib/.template.config/template.json Adds skipRestore symbol so --no-restore can be wired through.
src/Microsoft.Android.Templates/android-bindinglib/.template.config/dotnetcli.host.json Maps skipRestore to --no-restore for dotnet new.
build-tools/automation/yaml-templates/variables.yaml Adds CI variables to disable workload update notify, SDK vulnerability check, and NuGet audit.
build-tools/automation/yaml-templates/build-windows.yaml Quotes staging paths and forces restore to use repo NuGet.config during template smoke build.
build-tools/automation/azure-pipelines.yaml Adds --no-restore to MAUI template creation step.
build-tools/automation/azure-pipelines-apidocs.yaml Removes --add-source https://api.nuget.org/v3/index.json from boots tool install.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

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