I do not know what was happening suddenly I cannot publish my Blazor application. This is the error:
dotnet publish
/usr/local/share/dotnet/dotnet publish "/Users/alvinstefanus/Documents/Projects/MyApp/MyApp/MyApp/Server/MyApp.Server.csproj" --configuration "Release" --output "bin/Release/net6.0/publish"
MSBuild version 17.3.1 2badb37d1 for .NET
Determining projects to restore...
/Users/alvinstefanus/Documents/Projects/MyApp/MyApp/MyApp/Server/MyApp.Server.csproj : warning NU1701: Package 'BouncyCastle 1.8.9' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net6.0'. This package may not be fully compatible with your project.
/Users/alvinstefanus/Documents/Projects/MyApp/MyApp/MyApp/Server/MyApp.Server.csproj : warning NU1701: Package 'PayPal 1.9.1' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net6.0'. This package may not be fully compatible with your project.
All projects are up-to-date for restore.
/Users/alvinstefanus/Documents/Projects/MyApp/MyApp/MyApp/Server/MyApp.Server.csproj : warning NU1701: Package 'BouncyCastle 1.8.9' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net6.0'. This package may not be fully compatible with your project.
/Users/alvinstefanus/Documents/Projects/MyApp/MyApp/MyApp/Server/MyApp.Server.csproj : warning NU1701: Package 'PayPal 1.9.1' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net6.0'. This package may not be fully compatible with your project.
MyApp.Shared -> /Users/alvinstefanus/Documents/Projects/MyApp/MyApp/MyApp/Shared/bin/Release/net6.0/MyApp.Shared.dll
MyApp.Client -> /Users/alvinstefanus/Documents/Projects/MyApp/MyApp/MyApp/Client/bin/Release/net6.0/MyApp.Client.dll
MyApp.Client (Blazor output) -> /Users/alvinstefanus/Documents/Projects/MyApp/MyApp/MyApp/Client/bin/Release/net6.0/wwwroot
MyApp.Server -> /Users/alvinstefanus/Documents/Projects/MyApp/MyApp/MyApp/Server/bin/Release/net6.0/MyApp.Server.dll
Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
Compressing Blazor WebAssembly publish artifacts. This may take a while...
/usr/local/share/dotnet/sdk/6.0.401/Sdks/Microsoft.NET.Sdk.BlazorWebAssembly/targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets(614,5): error MSB6006: "/usr/local/share/dotnet" exited with code 1. [/Users/alvinstefanus/Documents/Projects/MyApp/MyApp/MyApp/Client/MyApp.Client.csproj]
The application was terminated by a signal: SIGHUP
If I remember I was deleting the "bin" and "obj" folder from Client and Server project several times, and this happens.
If I disable the "BlazorCompression", then it works fine:
<BlazorEnableCompression>false</BlazorEnableCompression>
But I do not want to disable the compression because my initial app loading will be large and slow.
How can I fix this?
I am using Visual Studio Mac 2022 with .Net 6
Detailed Error
After I use "dotnet publish -c Release -v detailed"
This is the detailed error I got:
....
-o
/Users/alvinstefanus/Documents/Projects/MyApp/MyApp/MyApp/Client/obj/Release/net6.0/compress/Mtw9rFsN.br
-s
/Users/alvinstefanus/Documents/Projects/MyApp/MyApp/MyApp/Client/obj/Release/net6.0/blazor.publish.boot.json
-o
/Users/alvinstefanus/Documents/Projects/MyApp/MyApp/MyApp/Client/obj/Release/net6.0/compress/S6lnNxRh.br
Unrecognized command or argument 'copy.json'.
Description:
Usage:
Microsoft.NET.Sdk.BlazorWebAssembly.Tool brotli [options]
Options:
-c <Fastest|NoCompression|Optimal|SmallestSize> System.IO.Compression.CompressionLevel for the Brotli compression algorithm. [default: Optimal]
-s <s> A list of files to compress.
-o <o> The filenames to output the compressed file to.
-?, -h, --help Show help and usage information
2:12>/usr/local/share/dotnet/sdk/6.0.401/Sdks/Microsoft.NET.Sdk.BlazorWebAssembly/targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets(614,5): error MSB6006: "/usr/local/share/dotnet" exited with code 1. [/Users/alvinstefanus/Documents/Projects/MyApp/MyApp/MyApp/Client/MyApp.Client.csproj]
Done executing task "BrotliCompress" -- FAILED.
2:12>Done building target "_BlazorCompressPublishFiles" in project "MyApp.Client.csproj" -- FAILED.
2:12>Done Building Project "/Users/alvinstefanus/Documents/Projects/MyApp/MyApp/MyApp/Client/MyApp.Client.csproj" (ComputeFilesToPublish;GetCurrentProjectPublishStaticWebAssetItems target(s)) -- FAILED.
1:7>Done executing task "MSBuild" -- FAILED.
1:7>Done building target "ComputeReferencedProjectsPublishAssets" in project "MyApp.Server.csproj" -- FAILED.
1:7>Done Building Project "/Users/alvinstefanus/Documents/Projects/MyApp/MyApp/MyApp/Server/MyApp.Server.csproj" (Publish target(s)) -- FAILED.
Build FAILED.
There is a problem when compressing with Brotli.
Unrecognized command or argument 'copy.json'.
How do I fix this?
CodePudding user response:
So after I traced the problem, I tried to find copy.json
, apparently, this was a silly mistake I made. I have a backup file for the appsetting.json
called appsetting.copy.json
. This causes the issue. The compressor does not know how to deal with .copy.json
file.
After I deleted it, it works perfectly.