dotnet / dotnet/aspnetcore

razor class library build failed because staticwebassets.build.json was 0Bytes

Open
#59,059 0 comments 0 reactions 0 assignees View on GitHub
area-mvc
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

i just had a weird issue on a coworker's pc for a razor class library project: the obj\Debug\net9.0\staticwebassets.build.json file was 0bytes and msbuild was very unhappy, throwing a json-parse-error (without telling us which file was the problem - i had to use the structured log viewer to find out)

We ended up deleting the obj/debug folder, but that feels like too much guesswork - a somewhat better error would have helped.

i don't know if this was the first time that solution got built in .net9 in debug mode - i know that a previous release build was successful.

### Expected Behavior

either msbuild should complain about that file being 0 bytes
or the file should be filled correctly, in the first place
or the loading of that file should be tolerant to empty files

### Steps To Reproduce

i have no idea why the generation of that file ended up with it being empty, and after we renaming the obj/debug folder, the issue didn't reappear...

i could provide a binlog of the failed compilation, though.

### Exceptions (if any)

C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(614,5): JsonException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
bei System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
bei System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
bei System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Utf8JsonReader& reader, ReadStack& state)
bei System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo`1 jsonTypeInfo, Nullable`1 actualByteCount)
bei Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAssetsManifest.FromJsonBytes(Byte[] jsonBytes)
bei Microsoft.AspNetCore.StaticWebAssets.Tasks.GenerateStaticWebAssetsManifest.PersistManifest(StaticWebAssetsManifest manifest)
bei Microsoft.AspNetCore.StaticWebAssets.Tasks.GenerateStaticWebAssetsManifest.Execute()
JsonReaderException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. LineNumber: 0 | BytePositionInLine: 0.
bei System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
bei System.Text.Json.Utf8JsonReader.Read()
bei System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
[D:\DevTools\Projects\DotNet\CODie\CustomerApp\CODieClientApp.Shared.Pages\CODieClientApp.Shared.Pages.csproj]

### .NET Version

9.0.100

### Anything else?

VS 2022 17.12.0

if there's any more info i could provide, i'd be glad to ask my coworker.
thanks a lot :-)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.