dotnet muxer reports JSON syntax error when global.json is saved in UTF8+BOM
Steps to reproduce
- Save global.json in utf8 with byte order mark.
- dotnet build
Expected behavior
dotnet build shows no errors
Actual behavior
A JSON parsing exception occurred: * Line 1, Column 2 Syntax error: Malformed token
Environment data
dotnet --version output:
A JSON parsing exception occurred: * Line 1, Column 2 Syntax error: Malformed token
1.0.0-beta-002171
//cc @piotrpMSFT @davidfowl @victorhurdugaci @pranavkm
This makes build to fail.
dotnet build
A JSON parsing exception occurred: * Line 1, Column 2 Syntax error: Malformed token
Project 1 (.NETStandardApp,Version=v1.5) will be compiled because the CLI changed
Compiling 1 for .NETStandardApp,Version=v1.5
D:\temp\1\A JSON parsing exception occurred: * Line 1, Column 2 Syntax error: Malformed token
Compilation failed.
0 Warning(s)
1 Error(s)
Time elapsed 00:00:05.4565174
@pakrym Why is this blocking given that JSON parsing was working all this while?
Because now its output makes dotnet build to fail
Have you changed the format in which the .json files are saved?
No, it reports false positive for files with BOM
Save global.json in utf8 with byte order mark.
How was this saved earlier when this worked? I am not aware of any JSON parsing changes that would result in this.
Reporting changed in https://github.com/dotnet/cli/commit/1428eb81cfb1e81251b8241d08e5fefd95882153, it started printing line numbers into stderr and dotnet build thinks its csc errors.
Are you suggesting that if trace_error was not executed, the build would have succeeded as that would be strange given that json parsing failed?
global.json is perfectly valid json file, it just has UTF8 BOM encoding which corehost can not process correctly. So yes, build would have succeeded if this error wasn't written to stderr.
I'm not fixing it
This will only make it write to stdout instead stderror
Casablanca does not support BOM. If you think this is blocking for RTM, let us discuss.
I think it blocks RC2, VS saves json files with BOM by default.
With your workaround in place, I dont believe this is blocking for RC2. We can look into what can be done for RTM for Casablanca.
All users would see error message that is not true, how is this not an issue?
And sdk selection feature won't work at all.
Are there other editors that allow you to save JSON without BOM marker? If so, can that not be a workaround until RTM to author the json file? Or, are you suggesting there is a case where VS is used to create a project type that will have .json files with BOM markers?
File->Create project->Core console application creates global.json with BOM
Cc @BillHiebert