Unify GetLaunchSettings implementations between Aspire.Hosting and Aspire.Hosting.Testing#15828
Draft
Unify GetLaunchSettings implementations between Aspire.Hosting and Aspire.Hosting.Testing#15828
GetLaunchSettings implementations between Aspire.Hosting and Aspire.Hosting.Testing#15828Conversation
…pire.Hosting.Testing Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/ff3fd7f9-715f-4cb8-af61-04cba3fc0081 Co-authored-by: radical <1472+radical@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor GetLaunchSettings implementations in Aspire.Hosting
Unify Apr 3, 2026
GetLaunchSettings implementations between Aspire.Hosting and Aspire.Hosting.Testing
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15828Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15828" |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The launch settings file-reading logic was duplicated between
LaunchProfileExtensions(inAspire.Hosting) andDistributedApplicationFactory(inAspire.Hosting.Testing). This extracts the shared logic into a newLaunchSettingsReaderclass in the shared sources folder.Changes
New
src/Shared/LaunchProfiles/LaunchSettingsReader.cs— shared internal static class with:GetLaunchSettingsFromDirectory(string? directoryPath, string resourceIdentifier)— builds theProperties/launchSettings.jsonpath and reads itReadLaunchSettingsFile(string filePath, string resourceIdentifier)— deserializes JSON, throwsDistributedApplicationExceptionwith a descriptive message on parse failureLaunchProfileExtensions.cs— replaces inline stream-open +JsonSerializer.Deserialize+JsonExceptioncatch block withLaunchSettingsReader.ReadLaunchSettingsFile(...). All existing special-case logic (file-based apps,.run.jsonfallback) is preserved.DistributedApplicationFactory.cs— replaces ~20 lines of duplicated path-building and file-reading inGetLaunchSettings(string?)with a single call toLaunchSettingsReader.GetLaunchSettingsFromDirectory(...).Aspire.Hosting.Testing.csproj— adds explicit<Compile>include for the new shared file.Aspire.HostingandAspire.Hosting.Azure.Functionspick it up automatically via their existing$(SharedDir)LaunchProfiles\*.cswildcard.Error message strings are preserved exactly, maintaining backward compatibility with existing tests.
Checklist
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
dnceng.pkgs.visualstudio.com/usr/share/dotnet/dotnet dotnet build src/Aspire.Hosting/Aspire.Hosting.csproj -p:TreatWarningsAsErrors=false(dns block)/usr/share/dotnet/dotnet dotnet build src/Aspire.Hosting.Testing/Aspire.Hosting.Testing.csproj -p:TreatWarningsAsErrors=false(dns block)/usr/share/dotnet/dotnet dotnet build src/Aspire.Hosting.Azure.Functions/Aspire.Hosting.Azure.Functions.csproj -p:TreatWarningsAsErrors=false(dns block)If you need me to access, download, or install something from one of these locations, you can either: