Skip to content

Conversation

@davidfowl
Copy link
Member

Description

  • Env files aren't check into source control and overwriting them destroys the values.
  • This change makes the env file updates purely additive (non existing new keys), and never overwrites or deleted values.
  • Added tests

Fixes #9124

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
  • Did you add public API?
    • No
  • Does the change make any security assumptions or guarantees?
    • No
  • Does the change require an update in our Aspire docs?
    • No

- Env files aren't check into source control and overwriting them destroys the values.
- This change makes the env file updates purely additive (non existing new keys), and never overwrites or deleted values.
- Added tests
@github-actions github-actions bot added the area-integrations Issues pertaining to Aspire Integrations packages label May 8, 2025

foreach (var line in File.ReadAllLines(path))
{
envFile._lines.Add(line);
Copy link
Member

Choose a reason for hiding this comment

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

Instead of keeping track of all lines, why not just append to the file if there are lines to add?

@davidfowl davidfowl merged commit f4243ac into main May 8, 2025
171 checks passed
@davidfowl davidfowl deleted the davidfowl/compose-env-file branch May 8, 2025 21:07
@github-actions github-actions bot locked and limited conversation to collaborators Jun 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-integrations Issues pertaining to Aspire Integrations packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aspire publish to docker-compose should not destroy .env file

4 participants