-
Notifications
You must be signed in to change notification settings - Fork 180
feat: replace azure-prepare Aspire detection sequence with a script #2576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tmeschter
wants to merge
8
commits into
microsoft:main
Choose a base branch
from
tmeschter:260605-Issue2949
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f631c05
feat: replace azure-prepare Aspire detection sequence with a script
tmeschter c4c63a6
test: verify detect-aspire script runs in azure-prepare aspire-brownf…
tmeschter 399550b
fix: address PR #2576 review feedback for detect-aspire scripts
tmeschter ba5a599
Merge remote-tracking branch 'upstream/main' into 260605-Issue2949
tmeschter e7d4e29
Merge remote-tracking branch 'upstream/main' into 260605-Issue2949
tmeschter 41f3ea2
docs: encourage use of the detect-aspire detection scripts
tmeschter 54839bc
refac: split detect-aspire into presence and gather-info scripts
tmeschter 44b9473
Further changes
tmeschter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
plugin/skills/azure-prepare/references/scripts/detect-aspire.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| <# | ||
| .SYNOPSIS | ||
| Presence check: determines whether a workspace is a .NET Aspire application. | ||
| Use this at detection/routing points where you only need a yes/no answer. | ||
| To gather the deeper deployment facts (ExcludeFromManifest, Azure Functions, | ||
| secret storage, AppHost source dir), use gather-aspire-info.ps1 instead. | ||
|
|
||
| .DESCRIPTION | ||
| Runs the minimal deterministic presence sequence: | ||
| 1. Find the AppHost project (*.AppHost.csproj) | ||
| 2. Confirm Aspire.Hosting or Aspire.AppHost.Sdk package references | ||
|
|
||
| Output: key=value lines (isAspire, appHostPath) followed by a short | ||
| human-readable summary. | ||
|
|
||
| .PARAMETER WorkspaceRoot | ||
| Workspace root directory to scan. Defaults to the current directory. | ||
|
|
||
| .EXAMPLE | ||
| ./detect-aspire.ps1 | ||
| Scan the current directory. | ||
|
|
||
| .EXAMPLE | ||
| ./detect-aspire.ps1 -WorkspaceRoot ./src/MyApp | ||
| Scan a specific workspace root. | ||
| #> | ||
|
|
||
| param( | ||
| [string]$WorkspaceRoot = "." | ||
| ) | ||
|
|
||
| $ErrorActionPreference = 'Stop' | ||
|
|
||
| if (-not (Test-Path -LiteralPath $WorkspaceRoot -PathType Container)) { | ||
| Write-Error "workspace root '$WorkspaceRoot' is not a directory" | ||
| exit 1 | ||
| } | ||
|
|
||
| # Defaults (emitted when the workspace is not an Aspire app) | ||
| $isAspire = $false | ||
| $appHostPath = "" | ||
|
|
||
| # Step 1: Find the AppHost project (sorted for deterministic selection) | ||
| $appHostProject = @(Get-ChildItem -LiteralPath $WorkspaceRoot -Recurse -Filter "*.AppHost.csproj" -File -ErrorAction SilentlyContinue | | ||
| Sort-Object FullName) | Select-Object -First 1 | ||
|
|
||
| # Step 2: Confirm Aspire package references anywhere in the workspace | ||
| $hasAspirePackage = $false | ||
| $csprojFiles = Get-ChildItem -LiteralPath $WorkspaceRoot -Recurse -Filter "*.csproj" -File -ErrorAction SilentlyContinue | ||
| if ($csprojFiles) { | ||
| if ($csprojFiles | Select-String -Pattern "Aspire\.Hosting|Aspire\.AppHost\.Sdk" -List -ErrorAction SilentlyContinue) { | ||
| $hasAspirePackage = $true | ||
| } | ||
| } | ||
|
|
||
| if ($appHostProject -or $hasAspirePackage) { | ||
| $isAspire = $true | ||
| } | ||
|
|
||
| if ($appHostProject) { | ||
| # Emit a workspace-relative, forward-slash path (matches the bash output contract) | ||
| Push-Location -LiteralPath $WorkspaceRoot | ||
| try { | ||
| $appHostPath = (Resolve-Path -LiteralPath $appHostProject.FullName -Relative) -replace '\\', '/' | ||
| } finally { | ||
| Pop-Location | ||
| } | ||
| } | ||
|
|
||
| function ConvertTo-Lower([bool]$value) { | ||
| if ($value) { "true" } else { "false" } | ||
| } | ||
|
|
||
| # Machine-readable result | ||
| Write-Output "isAspire=$(ConvertTo-Lower $isAspire)" | ||
| Write-Output "appHostPath=$appHostPath" | ||
|
|
||
| # Human-readable summary | ||
| Write-Output "" | ||
| Write-Output "Summary:" | ||
| if (-not $isAspire) { | ||
| Write-Output "- No .NET Aspire app detected in '$WorkspaceRoot' (no *.AppHost.csproj or Aspire.Hosting / Aspire.AppHost.Sdk package reference)." | ||
| exit 0 | ||
|
tmeschter marked this conversation as resolved.
|
||
| } | ||
|
|
||
| if ($appHostPath) { | ||
| Write-Output "- .NET Aspire app detected. AppHost project: $appHostPath" | ||
| } else { | ||
| Write-Output "- Aspire.Hosting / Aspire.AppHost.Sdk package reference found, but no *.AppHost.csproj was located." | ||
| } | ||
| Write-Output "- Run gather-aspire-info.ps1 to gather other essential deployment information." | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.