Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 23, 2025

Summary

This PR replaces the runtime download of dotnet-install.sh and dotnet-install.ps1 scripts with embedded resources within the Aspire CLI assembly. This eliminates network dependencies during SDK installation and improves reliability. It also adds automation to keep the embedded scripts up-to-date.

Problem

Previously, DotNetSdkInstaller downloaded installation scripts from https://dot.net/v1/ at runtime using HttpClient. This approach had several drawbacks:

  • Network dependency: Failed in offline or restricted environments
  • Download latency: Added delay to SDK installation process
  • External dependency: Required external web service availability
  • Version coupling: Scripts weren't versioned with the CLI binary

Solution

The official Microsoft dotnet-install scripts are now embedded as resources within the Aspire CLI assembly:

  1. Added embedded resources: Both dotnet-install.sh (64KB) and dotnet-install.ps1 (70KB) are included in src/Aspire.Cli/Resources/
  2. Replaced download logic: HttpClient.GetStringAsync() replaced with Assembly.GetManifestResourceStream()
  3. Updated configuration: Modified Aspire.Cli.csproj to include scripts as <EmbeddedResource> items
  4. Added test coverage: New test verifies embedded scripts are accessible and contain valid content
  5. Added automation: Created GitHub Action workflow (.github/workflows/update-dotnet-install-scripts.yml) that automatically downloads the latest scripts daily and creates a PR to update them

Benefits

  • No network dependency - works offline and in air-gapped environments
  • Faster - eliminates download time from SDK installation
  • More reliable - removes network failure points
  • Version control - scripts are versioned alongside CLI binary
  • Simpler - fewer dependencies and error conditions
  • Automated updates - daily workflow ensures scripts stay current

Testing

All existing tests pass (27/27 DotNetSdkInstallerTests), and a new test verifies the embedded resources are properly accessible. Manual verification confirms scripts extract correctly and maintain their functionality in both Debug and Release builds.

The implementation is minimal and maintains backward compatibility - installation behavior remains identical from a user perspective.

Original prompt

Currently the DotNetSdkInstaller downloads the dotnet-install.sh and dotnet-install.ps1 scripts from the web. We want to switch over to having these files as embedded resources within the Aspire CLI. Implement this change and remove the logic to download those scripts in the first place.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- Add dotnet-install.sh and dotnet-install.ps1 as embedded resources
- Update DotNetSdkInstaller to extract scripts from embedded resources instead of downloading
- Remove HttpClient download logic
- Add test to verify embedded scripts are accessible

Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
Copilot AI changed the title [WIP] Embed dotnet-install scripts in Aspire CLI Embed dotnet-install scripts as resources in Aspire CLI Oct 23, 2025
Copilot AI requested a review from mitchdenny October 23, 2025 03:10
Copilot finished work on behalf of mitchdenny October 23, 2025 03:10
@davidfowl
Copy link
Member

@copilot create a github action that downloads these scripts from:

https://dot.net/v1/dotnet-install.sh
https://dot.net/v1/dotnet-install.ps1

and sends a pull request to update these files. See https://github.com/dotnet/aspire/blob/main/.github/workflows/update-github-models.yml for inspiration (though it should be simpler)

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 23, 2025

@copilot create a github action that downloads these scripts from:

https://dot.net/v1/dotnet-install.sh
...

Created the workflow in commit fc4d219. It runs weekly on Mondays at 06:00 UTC and can also be triggered manually via workflow_dispatch. The workflow downloads both scripts from https://dot.net/v1/ and creates/updates a PR with the updated files.

Copilot AI requested a review from davidfowl October 23, 2025 03:28
Copilot finished work on behalf of davidfowl October 23, 2025 03:28
@davidfowl
Copy link
Member

@copilot run the workflow daily not weekly.

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 23, 2025

@copilot run the workflow daily not weekly.

Updated to run daily in commit d7a1eb3. The workflow now runs every day at 06:00 UTC.

Copilot finished work on behalf of davidfowl October 23, 2025 03:37
}

[Fact]
public void EmbeddedScripts_AreAccessible()
Copy link
Member

Choose a reason for hiding this comment

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

We can use verify for this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current test validates that the embedded scripts are accessible and contain expected markers. Using Verify would snapshot the entire script content (60KB+), which changes daily via the auto-update workflow. Should I verify just specific parts (like the first few lines), or did you have a different approach in mind?

Copilot AI requested a review from davidfowl October 23, 2025 03:45
Copilot finished work on behalf of davidfowl October 23, 2025 03:45
@github-actions
Copy link
Contributor

🚀 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 -- 12296

Or

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

1 similar comment
@github-actions
Copy link
Contributor

🚀 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 -- 12296

Or

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

@davidfowl
Copy link
Member

@copilot quarantine GetAppHostsCommand_WithMultipleProjects_ReturnsSuccessWithAllCandidates

Copy link
Contributor Author

Copilot AI commented Oct 23, 2025

@copilot quarantine GetAppHostsCommand_WithMultipleProjects_ReturnsSuccessWithAllCandidates

I need an issue URL to quarantine this test. Could you provide the GitHub issue URL for tracking this flaky test?

Copilot finished work on behalf of davidfowl October 23, 2025 04:58
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Resources\dotnet-install.sh" />
Copy link
Member

Choose a reason for hiding this comment

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

@eerhardt bloat 😄

Copy link
Member

Choose a reason for hiding this comment

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

Probably lighter than the alternative!

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.

3 participants