Fix dotnet publish bundling appsettings.Local.json#26
Merged
Conversation
appsettings.Local.json is copied to the build output (dotnet build/run, F5 in Visual Studio) whenever it exists, for local dev convenience -- but that same MSBuild rule also applied to dotnet publish, since CopyToPublishDirectory inherits CopyToOutputDirectory's value unless set explicitly. CONTRIBUTING.md's "cutting a release" instructions use plain dotnet publish locally, so anyone building their own release from a checkout with real credentials in appsettings.Local.json would unknowingly bundle them into the distributable output. CI's release.yml was never at risk -- its checkout never has this gitignored file. Fixed by pinning CopyToPublishDirectory to Never on that item. Verified: dotnet publish now excludes appsettings.Local.json from its output, while a plain dotnet build (and F5) still copies it, unchanged. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HGgBp8jugwf4PzZEJKrEL7
…s-local-secrets # Conflicts: # CHANGELOG.md
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.
Summary
appsettings.Local.jsonis copied to the build output (dotnet build/dotnet run, F5 in Visual Studio) whenever it exists, for local dev convenience.dotnet publish, sinceCopyToPublishDirectoryinheritsCopyToOutputDirectory's value unless set explicitly.dotnet publishlocally — so anyone building their own release from a checkout with real credentials inappsettings.Local.jsonwould unknowingly bundle them into the distributable output. CI'srelease.ymlwas never at risk (its checkout never has this.gitignored file), but a local publish was.CopyToPublishDirectorytoNeveron that item.Test plan
dotnet build/dotnet test— clean, 84/84 passingdotnet publish -r win-x64 --self-contained -o <scratch>— confirmed output only hasappsettings.json, noappsettings.Local.jsondotnet build(simulating F5) — confirmedbin/Debug/net10.0/still has bothappsettings.jsonandappsettings.Local.json, unchanged from before this fixCo-Authored-By: Claude Sonnet 5 noreply@anthropic.com
https://claude.ai/code/session_01HGgBp8jugwf4PzZEJKrEL7