【问题标题】:Error on Build: JsonException: '0x00' is an invalid start of a value构建错误:JsonException:'0x00' 是值的无效开始
【发布时间】:2022-03-04 23:50:52
【问题描述】:

在 VS 2022 中使用 .NET FW 6。当我尝试构建我的项目时,我遇到了这个错误......

JsonException: '0x00' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
   at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](ReadOnlySpan`1 utf8Json, JsonSerializerOptions options)
   at Microsoft.AspNetCore.Razor.Tasks.StaticWebAssetsManifest.FromJsonBytes(Byte[] jsonBytes)
   at Microsoft.AspNetCore.Razor.Tasks.GenerateStaticWebAssetsManifest.PersistManifest(StaticWebAssetsManifest manifest)
   at Microsoft.AspNetCore.Razor.Tasks.GenerateStaticWebAssetsManifest.Execute()
JsonReaderException: '0x00' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.
   at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
   at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
   at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)
   at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
   at System.Text.Json.Utf8JsonReader.Read()
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
    Website C:\Program Files\dotnet\sdk\6.0.200\Sdks\Microsoft.NET.Sdk.Razor\targets\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets    411 

文件 Microsoft.NET.Sdk.Razor.StaticWebAssets.targets 的第 411 行是这个....的顶行。

    <GenerateStaticWebAssetsManifest
  Source="$(PackageId)"
  BasePath="$(StaticWebAssetBasePath)"
  Mode="$(StaticWebAssetProjectMode)"
  ManifestType="Build"
  ReferencedProjectsConfigurations="@(StaticWebAssetProjectConfiguration)"
  DiscoveryPatterns="@(StaticWebAssetDiscoveryPattern)"
  Assets="@(StaticWebAsset)"
  ManifestPath="$(StaticWebAssetBuildManifestPath)">
  </GenerateStaticWebAssetsManifest>

我尝试重新安装 VS,最新的稳定版 .NET 6 FW,尝试清除 nuget 缓存并执行“dotnet restore”,按此...NuGet.targets error : '.', hexadecimal value 0x00, is an invalid character after upgrade to .Net Core 2.1.1

我也在网上努力搜索,但找不到答案。你有什么主意吗?谢谢!

【问题讨论】:

  • 你有空的json文件吗

标签: c# .net .net-6.0


【解决方案1】:

解决方案:我不得不重新安装 GIT。这次我选择了“按原样结帐,提交 Unix 风格的行尾”选项,它起作用了! Windows 一定一直在用 LF 进行一些转换,它弄乱了构建。希望这对其他人有帮助!

【讨论】:

  • JFYI 通常你不需要重新安装 git 来改变这个设置。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-06-17
  • 2022-01-26
  • 2018-12-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-12
相关资源
最近更新 更多