-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Description
dotnet tool commands (install, update, uninstall) perform an invasive rewrite of the dotnet-tools.json manifest that disregards original file formatting and encoding.
Issues
- Trailing Newline Stripping: Commands always strip the trailing newline. This causes "dirty diffs" in automated updates (Dependabot/Renovate) and breaks linting/EditorConfig rules requiring a final newline.
- BOM Removal: Files saved as UTF-8 with BOM are rewritten as UTF-8 without BOM.
- UTF-16 Crash: The CLI crashes with
Json parsing error: '0xFF' is an invalid start of a valuewhen reading UTF-16 LE manifests becauseToolManifestEditor.csusesJsonDocument.Parseon a raw stream.
Technical Detail
The implementation in src/Cli/dotnet/ToolManifest/ToolManifestEditor.cs uses a strict "Read into Model -> Write from Model" pattern without capturing file metadata.
DeserializeLocalToolsManifestusesJsonDocument.Parse(jsonStream)which lacks encoding detection.ToJsonusesUtf8JsonWriterwhich does not append a final newline.File.WriteAllTextis called without preserving the original encoding.
Expected Behavior
The SDK should detect and preserve the existing file's encoding and trailing whitespace.
Reactions are currently unavailable