Skip to content

[tests] Keep XASdk restores on approved feeds - #12338

Merged
jonathanpeppers merged 3 commits into
mainfrom
jonathanpeppers-fix-xasdk-network-access
Aug 11, 2026
Merged

[tests] Keep XASdk restores on approved feeds#12338
jonathanpeppers merged 3 commits into
mainfrom
jonathanpeppers-fix-xasdk-network-access

Conversation

@jonathanpeppers

@jonathanpeppers jonathanpeppers commented Aug 10, 2026

Copy link
Copy Markdown
Member

Changes

  • 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

Why templates declare skipRestore

--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.

Validation

  • packed and installed Microsoft.Android.Templates

  • verified all five project templates create without producing obj/project.assets.json or reporting a restore by default

  • passed XASdkTests.DotNetNew for android, androidlib, android-bindinglib, and androidwear

  • verified the wear binlog contains no api.nuget.org or repo1.maven.org references

  • Useful description of why the change is necessary

  • Links to issues fixed

  • Unit tests

Copilot AI lite review requested due to automatic review settings August 10, 2026 17:23

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

This PR adjusts the XASdk template tests so that restores/builds for generated dotnet new projects are constrained to the repository-approved NuGet/Maven feeds, avoiding unintended network access to public endpoints during test runs.

Changes:

  • Adds --no-restore support to DotNetCLI.New() and uses it for the initial template project generation.
  • Copies the repo NuGet.config into the generated project directory before restore/build.
  • Adds a test-scope MSBuild targets file that rewrites blank AndroidMavenLibrary.Repository metadata to use the dotnet-public-maven feed (used by the androidwear template).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetCLI.cs Adds optional --no-restore support for dotnet new in test infrastructure.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs Updates DotNetNew test flow to avoid implicit restores and to enforce repo feed configuration; routes wear builds through a test-scope targets hook.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/dotnet-public-maven.targets Introduces a test-only MSBuild hook to set the Maven repository URL when item metadata is blank.

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

Prevent template creation from restoring implicitly, copy the repository NuGet.config into generated projects, and route blank AndroidMavenLibrary repositories through dotnet-public-maven in test scope.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppers force-pushed the jonathanpeppers-fix-xasdk-network-access branch from 2dcfc15 to da6867a Compare August 10, 2026 17:34
@jonathanpeppers jonathanpeppers added ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). and removed ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). labels Aug 10, 2026
Declare the standard skipRestore symbol and restore post-action in every Android project template, and map it to the dotnet CLI --no-restore option.

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

Copilot-Session: eaf73cba-70d1-47cb-9854-fa4c537c5700
@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Aug 11, 2026
@jonathanpeppers

Copy link
Copy Markdown
Member Author

@dalexsoto review

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Blocking on the new default template restore. It also affects DotNetNewAndroidTest, which invokes the template before its approved nightly package version and feed configuration are applied; its output is outside the checkout, so the repository NuGet.config is not guaranteed to govern that restore. Please preserve the previous no-restore behavior, or suppress restore and explicitly install an approved config at every affected call site.

Keep the skipRestore CLI option without adding restore post-actions, so existing template call sites do not restore before configuring approved feeds.

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

Copilot-Session: eaf73cba-70d1-47cb-9854-fa4c537c5700
@jonathanpeppers

Copy link
Copy Markdown
Member Author

Addressed review 4908596729 in a60f9b8: removed the newly added restore post-actions from all five project templates while retaining the skipRestore/--no-restore mapping. Verified every template still creates without restoring by default and the focused XASdkTests.DotNetNew matrix passes.

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Re-reviewed the current changes. The follow-up removes restore post-actions from all five templates, preserving the previous default no-restore behavior and fixing the DotNetNewAndroidTest timing path. XASdk still installs the repository NuGet configuration before building and routes blank Maven repositories through the approved feed. No blocking issues found.

@jonathanpeppers

Copy link
Copy Markdown
Member Author

Merging, failures are unrelated, being fixed:

       (Restore target) -> 
         /Users/cloudtest/vss/_work/1/a/TestRelease/08-11_18.11.32/temp/DotNetBuildandroid-arm64FalseFalseTrueCoreCLR/Test Me.csproj : error NU1605: Warning As Error: Detected package downgrade: Microsoft.JSInterop from 9.0.0 to 8.0.29. Reference the package directly from the project to select a different version. 
       /Users/cloudtest/vss/_work/1/a/TestRelease/08-11_18.11.32/temp/DotNetBuildandroid-arm64FalseFalseTrueCoreCLR/Test Me.csproj : error NU1605:  Test Me -> Microsoft.AspNetCore.Components.WebView 8.0.30 -> Microsoft.AspNetCore.Components.Web 9.0.0 -> Microsoft.JSInterop (>= 9.0.0) 
       /Users/cloudtest/vss/_work/1/a/TestRelease/08-11_18.11.32/temp/DotNetBuildandroid-arm64FalseFalseTrueCoreCLR/Test Me.csproj : error NU1605:  Test Me -> Microsoft.JSInterop (>= 8.0.0)

    1 Warning(s)
    1 Error(s)

@jonathanpeppers
jonathanpeppers merged commit c09c89a into main Aug 11, 2026
40 of 44 checks passed
@jonathanpeppers
jonathanpeppers deleted the jonathanpeppers-fix-xasdk-network-access branch August 11, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants