Electron.NET: Error compiling a Blazor 'client-side' project on .NET 5

  • Version: Electron.NET Tools 11.5.1
  • .NET version: 5.0.1
  • Target: Win 10, desktop, x64

The error is:

NETSDK1098: Applications published to a single-file are required to use the application host. 
You must either set PublishSingleFile to false or set UseAppHost to true.

Full console text:

Start Electron Desktop Application...
Microsoft Windows [Version 10.0.19042.746]
(c) 2020 Microsoft Corporation. All rights reserved.
C:\...\tests\BlazorApp9>dotnet publish -r win-x64 -c "Debug" --output "C:\...\tests\BlazorApp9\obj\Host\bin" /p:PublishReadyToRun=true /p:PublishSingleFile=true --no-self-contained
Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
  Determining projects to restore...
  All projects are up-to-date for restore.
C:\Program Files\dotnet\sdk\5.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(145,5): error NETSDK1098: Applications published to a single-file are required to use the application host. You must either set PublishSingleFile to false or set UseAppHost to true. [C:\...\tests\BlazorApp9\BlazorApp9\Client\BlazorApp9.Client.csproj]
  BlazorApp9.Shared -> C:\...\tests\BlazorApp9\BlazorApp9\Shared\bin\Debug\net5.0\win-x64\BlazorApp9.Shared.dll
C:\Program Files\dotnet\sdk\5.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(96,5): error NETSDK1099: Publishing to a single-file is only supported for executable applications. [C:\...\tests\BlazorApp9\BlazorApp9\Shared\BlazorApp9.Shared.csproj]
  BlazorApp9.Shared -> C:\...\tests\BlazorApp9\BlazorApp9\Shared\bin\Debug\net5.0\BlazorApp9.Shared.dll
C:\...\tests\BlazorApp9>
Error occurred during dotnet publish: 1

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 30 (3 by maintainers)

Most upvoted comments

Hi Guys, in order to debug, just run from your electronized project in a CMD or powershell: electronize start /PublishSingleFile false Then find your project name using Visual Studio using DEBUG => Attach to process => and find the name of your project, then press ATTACH

alternative: just add the line above here: image And run the app in DEBUG mode using the Electron.NET App profile

Happy debugging As suggestion I pushed this PR #570

you can pass in overrides on the PublishSingleFile when running electronize build.

I believe its of the form like this.

electronize build /target osx /PublishSingleFile false

electronize build /target win /PublishSingleFile false gives me error NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. Please verify you are using a supported runtime identifier, or set the PublishReadyToRun property to false.

Instead, electronize build /target win /PublishSingleFile false /PublishReadyToRun false works.

But, electronize start /PublishSingleFile false /PublishReadyToRun false doesn’t, because of --no-self-contained that generates this error: error NETSDK1102: Optimizing assemblies for size is not supported for the selected publish configuration. Please ensure that you are publishing a self-contained app.

So, it’s usable, but for a definitive result I suggest to modify parameters in case of Blazor, for both start and build. Could be useful add a parameter to set a VS publish profile?

I don’t think so this is not my project, I can’t update the official nuget repository

as a workaround I created a blazor server side (instead of webassembly with backed asp.net) and everything bundled just fine