Skip to content

Make ATS analyzer packaged in Aspire.Hosting and opt-in#15083

Merged
eerhardt merged 14 commits intorelease/13.2from
fix-15081-optin-ats-analyzer
Mar 12, 2026
Merged

Make ATS analyzer packaged in Aspire.Hosting and opt-in#15083
eerhardt merged 14 commits intorelease/13.2from
fix-15081-optin-ats-analyzer

Conversation

@sebastienros
Copy link
Contributor

@sebastienros sebastienros commented Mar 9, 2026

Description

Integration/Export analyzer (ASPIREEXPORT001-009) — split into own project, opt-in via Aspire.Hosting

  • Splits AspireExportAnalyzer out of Aspire.Hosting.Analyzers into a new Aspire.Hosting.Integration.Analyzers project. The shared Infrastructure
    code (WellKnownTypes, BoundedCacheWithFactory) is linked between both analyzer projects.
  • Packages the integration analyzer into the Aspire.Hosting NuGet package under build/, with a new build/Aspire.Hosting.targets file that
    conditionally loads it.
  • Opt-in via EnableAspireIntegrationAnalyzers MSBuild property (defaults to false). Consumers must explicitly set
    true to enable the export analyzer.

Integration authors don't reference Aspire.Hosting.AppHost, just Aspire.Hosting. So we need to package these analyzers in Aspire.Hosting nuget package.

Also make them opt-in with an MSBuild property. Integration authors will need to reference Aspire.Hosting directly and set EnableAspireIntegrationAnalyzers=true to get the analyzers enabled.

Fixes #15081

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Move the Aspire.Hosting analyzer DLL out of NuGet's auto-loaded analyzers path and gate activation behind an MSBuild property. Enable the property in-repo and add MSBuild tests covering default-off and opt-in behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 9, 2026 23:31
@sebastienros sebastienros requested a review from mitchdenny as a code owner March 9, 2026 23:31
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15083

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15083"

Copy link
Contributor

Copilot AI left a comment

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 changes how the Aspire.Hosting analyzers are distributed and activated for AppHost projects, so they are opt-in by MSBuild property instead of being auto-loaded by NuGet.

Changes:

  • Move Aspire.Hosting.Analyzers.dll out of the NuGet analyzers/dotnet/cs folder into build/ so it no longer auto-loads.
  • Add an EnableAspireHostingAnalyzers MSBuild property (default false in the AppHost targets) and wire up analyzer loading when enabled.
  • Add MSBuild tests verifying analyzers are disabled by default and can be enabled via property.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/Aspire.Hosting.Tests/MSBuildTests.cs Adds tests and build scaffolding to validate default-off and property-enabled analyzer behavior.
src/Aspire.Hosting.AppHost/build/Aspire.Hosting.AppHost.in.targets Introduces EnableAspireHostingAnalyzers default and conditionally adds the analyzer assembly.
src/Aspire.Hosting.AppHost/Aspire.Hosting.AppHost.csproj Changes analyzer packing location from analyzers/dotnet/cs to build/.
playground/Directory.Build.targets Gates in-repo analyzer project reference behind EnableAspireHostingAnalyzers.
Directory.Build.props Enables EnableAspireHostingAnalyzers by default for this repo’s builds.

}

[Fact]
public void AspireHostingAnalyzersAreDisabledByDefault()
Copy link
Member

Choose a reason for hiding this comment

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

Is this enough or do we want a true nuget-based test?

@sebastienros sebastienros requested a review from eerhardt March 9, 2026 23:47
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

🎬 CLI E2E Test Recordings

The following terminal recordings are available for commit d3efc16:

Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
CreateAndDeployToDockerCompose ▶️ View Recording
CreateAndDeployToDockerComposeInteractive ▶️ View Recording
CreateAndPublishToKubernetes ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateEmptyAppHostProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
TypeScriptAppHostWithProjectReferenceIntegration ▶️ View Recording

📹 Recordings uploaded automatically from CI run #23013309605

Use an analyzer assembly existence check instead of RepoRoot to allow opted-in Arcade-based consumers to load the analyzer from the package. Add a regression test covering RepoRoot being set.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
eerhardt and others added 6 commits March 10, 2026 19:06
… in Aspire.Hosting.

Most integration packages don't reference the Aspire.Hosting.AppHost nuget package, only Aspire.Hosting. So we need to include the analyzer there.
Rename the MSBuild property that controls opt-in for the integration
analyzer from EnableAspireExportAnalyzers to EnableAspireIntegrationAnalyzers
to be consistent with the project name (Aspire.Hosting.Integration.Analyzers).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@eerhardt eerhardt changed the title Make ATS analyzer opt-in Make ATS analyzer packaged in Aspire.Hosting and opt-in Mar 11, 2026
@github-actions
Copy link
Contributor

The transient CI rerun workflow re-ran the following jobs from the failed CI run because they matched the retry-safe transient failure rules:

@sebastienros sebastienros added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Mar 11, 2026
Also move the build and analyzer logic into buildTransitive\net8.0 so it works transitively and this package only supports the current TFM, not all.
@eerhardt eerhardt removed the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Mar 11, 2026
@eerhardt
Copy link
Member

@sebastienros - I believe this PR is ready now.

sebastienros and others added 2 commits March 12, 2026 07:43
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor

The transient CI rerun workflow requested reruns for the following jobs after analyzing the failed attempt.
GitHub's job rerun API also reruns dependent jobs, so the retry is being tracked in the rerun attempt.
The job links below point to the failed attempt that matched the retry-safe transient failure rules.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@adamint
Copy link
Member

adamint commented Mar 12, 2026

@sebastienros should we merge?

@sebastienros
Copy link
Contributor Author

@adamint @eerhardt will merge

@eerhardt eerhardt enabled auto-merge (squash) March 12, 2026 16:52
@eerhardt eerhardt merged commit f32863a into release/13.2 Mar 12, 2026
254 checks passed
@eerhardt eerhardt deleted the fix-15081-optin-ats-analyzer branch March 12, 2026 17:22
@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Mar 12, 2026
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.

5 participants