question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue
  • 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

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
gpgpublickeycommented, Jun 3, 2021

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

2reactions
Nodiinkcommented, Feb 8, 2021

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

blazor (Server Side, .Net 5) razor compile error in 16.7 ...
I created a new Blazor (Server Side) project (.Net 5) and tried to compile, it failed to build with the following error:
Read more >
Cannot Migrate Blazor App to .Net 5 Due to System. ...
Seemed simple enough, so I changed the Client Blazor project to this and tried to compile. That gives me this error: Project BlazorMovies.Client...
Read more >
Handle errors in ASP.NET Core Blazor apps
This article describes how Blazor manages unhandled exceptions and how to develop apps that detect and handle errors.
Read more >
blazor template can't build on cli
Hello dotnet new build blazor creates project. ... .blazor.build\0.7.0\targets\RazorCompilation.targets(184,5): Error: rzc generate exited ...
Read more >
How to Build and Secure Web Applications with Blazor
Learn how to build client-side Web apps using Blazor and how to secure them with Auth0 authentication and authorization features.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found