Skip to content

file-based apps: dotnet add file.cs package <package> changes encoding of file.csΒ #52054

@johnkors

Description

@johnkors

Describe the bug

The SDK changes encoding of file-based app files when adding packages.

To Reproduce

1 - Create a a file.cs (UTF-8 encoded)
2 - Add a shebang : #!/usr/bin/env dotnet run and chmod +x file.cs
3- Run it: ./file.cs
4 - Add any package dotnet add file.cs AnyNugetPackageIdHere => file.cs is converted to UTF-8 with BOM
5 - Running ./file.cs again after the package is added results in failure:

> ./file.cs
./file.cs: line 1: #!/usr/bin/env: No such file or directory

Further technical details

.NET 10 SDK, 1.0.100

Metadata

Metadata

Assignees

Labels

Area-run-fileItems related to the "dotnet run <file>" effortuntriagedRequest triage from a team member

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions