[tests] Keep XASdk restores on approved feeds - #12338
Conversation
There was a problem hiding this comment.
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-restoresupport toDotNetCLI.New()and uses it for the initial template project generation. - Copies the repo
NuGet.configinto the generated project directory before restore/build. - Adds a test-scope MSBuild targets file that rewrites blank
AndroidMavenLibrary.Repositorymetadata to use thedotnet-public-mavenfeed (used by theandroidweartemplate).
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>
2dcfc15 to
da6867a
Compare
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
|
@dalexsoto review |
dalexsoto
left a comment
There was a problem hiding this comment.
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
|
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
left a comment
There was a problem hiding this comment.
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.
|
Merging, failures are unrelated, being fixed: |
Changes
skipRestoresymbol in every Android project templateskipRestoreto the user-facing--no-restoreoption through each template'sdotnetcli.host.jsonXASdkTests.DotNetNewfrom restoring generated projects implicitlyNuGet.configinto generated projects before builds restoreAndroidMavenLibraryitems with blank repository metadata throughdotnet-public-mavenin test scopeWhy templates declare
skipRestore--no-restoreis presented as a standarddotnet newoption, but project templates must opt into accepting it by declaring askipRestoreboolean symbol and mapping that symbol to--no-restoreindotnetcli.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
XASdkTestsexplicitly document and enforce that expectation before copying the repositoryNuGet.configinto generated projects.Validation
packed and installed
Microsoft.Android.Templatesverified all five project templates create without producing
obj/project.assets.jsonor reporting a restore by defaultpassed
XASdkTests.DotNetNewforandroid,androidlib,android-bindinglib, andandroidwearverified the wear binlog contains no
api.nuget.orgorrepo1.maven.orgreferencesUseful description of why the change is necessary
Links to issues fixed
Unit tests