Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Nov 5, 2025

Backport of #12656 to release/13.0

/cc @captainsafia @copilot

Customer Impact

  • Fixes Docker Compose publisher overwriting .env values during publish; now only adds missing keys and preserves existing values.
  • Ensures prepare step intentionally regenerates the environment-specific .env.{EnvironmentName} file (e.g., .env.Production/.env.Staging) and logs that it’s being overwritten.

Testing

  • Added unit tests and snapshot updates for EnvFile behavior and prepare step overwrite scenarios; verified key preservation on publish.

Risk

  • Low: Changes are isolated to EnvFile handling and Docker Compose prepare/publish paths, with added logging and tests to guard behavior.

Regression?

  • Yes, this fixes a regression from 9.5.

Copilot AI and others added 6 commits November 5, 2025 16:33
When SaveKeysOnly is called, it now checks if keys already exist on disk with non-empty values and preserves those values instead of overwriting them. This ensures that user modifications to .env files are not lost during subsequent publish operations.

Co-authored-by: captainsafia <[email protected]>
- Store path on Load as private field
- Remove path parameter from Save/SaveKeysOnly methods
- Use existing values in Entries instead of reloading from disk
- Change _entries to internal Entries property
- Update PrepareAsync to initialize its own EnvFile
- Update all test usages to call Save() without path parameter

Co-authored-by: captainsafia <[email protected]>
- Add ILogger parameter to EnvFile.Load() and constructor
- Log at Information level when saving with values overwrites existing file
- Fix trailing whitespace on line 134
- Update callers to pass logger from context
- All tests pass

Co-authored-by: captainsafia <[email protected]>
- Add EnvFile.Create() method to create new env file without loading existing content
- Update PrepareAsync to use Create() instead of Load() to avoid loading old entries
- Add PrepareStep_OverwritesExistingEnvFileAndLogsWarning test
- Add PrepareStep_OverwritesExistingEnvFileWithCustomEnvironmentName test
- Both tests verify file is overwritten and log message is emitted
- All 60 tests pass

Co-authored-by: captainsafia <[email protected]>
- Remove SharedEnvFile property from DockerComposeEnvironmentResource
- Remove SharedEnvFile usage from DockerComposePublishingContext
- EnvFile is now loaded fresh on each publish operation
- All 60 tests pass

Co-authored-by: captainsafia <[email protected]>
@github-actions
Copy link
Contributor Author

github-actions bot commented Nov 5, 2025

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

Or

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

@captainsafia captainsafia merged commit ea3b1f6 into release/13.0 Nov 5, 2025
296 checks passed
@captainsafia captainsafia deleted the backport/pr-12656-to-release/13.0 branch November 5, 2025 17:24
@github-actions github-actions bot locked and limited conversation to collaborators Dec 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants