mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-03 21:25:13 +00:00
Error compiling a Blazor 'client-side' project on .NET 5 #625
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Nodiink on GitHub (Jan 27, 2021).
Originally assigned to: @GregorBiswanger on GitHub.
The error is:
Full console text:
@danielhunex commented on GitHub (Jan 27, 2021):
I am seeing this error and couldn't find a workaround
@danatcofo commented on GitHub (Jan 28, 2021):
you can pass in overrides on the PublishSingleFile when running electronize build.
I believe its of the form like this.
@Nodiink commented on GitHub (Feb 8, 2021):
electronize build /target win /PublishSingleFile falsegives 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 falseworks.
But,
electronize start /PublishSingleFile false /PublishReadyToRun falsedoesn't, because of
--no-self-containedthat 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
startandbuild.Could be useful add a parameter to set a VS publish profile?
@danatcofo commented on GitHub (Feb 10, 2021):
I've got a PR in #531 to expose all the other compile time properties
/propertyvalues to the electronize command. Does this solve your issue?@revbones-dev commented on GitHub (Mar 3, 2021):
This pr does not fix the issue when dealing with Blazor wasm projects debugging via Visual Studio (that use the second project for hosting via ASP.NET Core). To recreate the issue, you can create a new Blazor webassembly project, select ASP.NET Core hosted in the options when creating the new project and in the new solution there will be 3 project (Client, Server, Shared). Set the Server project up normally using ElectronNet.Api and electronize init/start. Running it you'll see the issue.
If I remember correctly the publishreadytorun and publishsinglefile both need to be false in this case and I'm not sure where to set that so that when the debugging is started via Visual Studio that they would get passed. If there is a way to set that, then the pr might work.
@djordjedjukic commented on GitHub (Mar 23, 2021):
I encountered the same issue.
If I understood correctly there is no workaround for starting application without generating executable file?
@k-schneider commented on GitHub (Apr 7, 2021):
Has anyone been able to get the "start" command to work? Is there some combination of flags that can be used as a workaround?
@matzefriedrich commented on GitHub (May 2, 2021):
As a workaround, I had in mind building the Blazor WebAssembly app independently and just including the published outputs with the electronized server app. Would that be possible?
@mohaaron commented on GitHub (May 26, 2021):
Hi all, I just decided to try testing blazor in electron and see this same problem.
@gpgpublickey commented on GitHub (Jun 3, 2021):
Hi Guys, in order to debug, just run from your electronized project in a CMD or powershell:
electronize start /PublishSingleFile falseThen 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:
And run the app in DEBUG mode using the Electron.NET App profile
Happy debugging
As suggestion I pushed this PR #570
@mohaaron commented on GitHub (Jun 4, 2021):
@cristiangiagante I still get this error when following your directions.
In PowerShell I'm executing this command. electronize start /PublishSingleFile false
error NETSDK1102: Optimizing assemblies for size is not supported for the selected publish configuration. Please ensure that you are publishing a self-contained app.
@gpgpublickey commented on GitHub (Jun 4, 2021):
What is your issue when you try to run it normally? pls share your results
@mohaaron commented on GitHub (Jun 4, 2021):
Either way I run the start command I get the same error as noted in my previous comment. I've tried running start from the command line as well as creating the debug profile as you describe. I can add a screenshot of the error in the console window if that would help.

@gpgpublickey commented on GitHub (Jun 4, 2021):
Let start using a stable release, update your project to target Net5 instead of net6 preview
@mohaaron commented on GitHub (Jun 4, 2021):
Here is the same error again using the stable version of VS and Net5.
@mhamri commented on GitHub (Jun 4, 2021):
I'm facing the same issue, just created a blazor web assembly with asp.net backed and added the elctronNet and facing the same issue
@gpgpublickey commented on GitHub (Jun 4, 2021):
ok, I will take a look later but seems to be you are currently using the sdk/6.0.100-preview
@mohaaron commented on GitHub (Jun 4, 2021):
Oh, I see what you're saying now. I switched from using the VS2019 Preview to the most recent stable version of VS. How do I get it to use the Net5 SDK?
This line here might be part of the problem.
dotnet publish -r win-x64 -c "Debug" --output "BlazorElectronizedSln\obj\Host\bin" /p:PublishReadyToRun=false /p:PublishSingleFile=false --no-self-contained
@mhamri commented on GitHub (Jun 4, 2021):
@cristiangiagante I am using sdk 5.0, I can create a new repo so you can try it out
@mohaaron commented on GitHub (Jun 4, 2021):
I'll figure out how to make mine use SDK 5.0. Maybe that will help me.
@mhamri commented on GitHub (Jun 4, 2021):
https://github.com/mhamri/ElectronNet-blazor-bug
I have v5.0.2 sdk installed on my laptop
@gpgpublickey commented on GitHub (Jun 5, 2021):
Based on the StartElectronCommand class from electronnet
30941df39c/ElectronNET.CLI/Commands/BuildCommand.cs (L119)It should not be using --no-self-contained in the build process, do you have the last version of electronnet?
@mhamri commented on GitHub (Jun 5, 2021):
i just installed everything yesterday, so it should be whatever available. this is what I have available
and this is dotnet
could you make my repo to work?
@mhamri commented on GitHub (Jun 12, 2021):
as a workaround I created a blazor server side (instead of webassembly with backed asp.net) and everything bundled just fine
@gpgpublickey commented on GitHub (Jun 12, 2021):
Sorry I totally forgot this, I checked your repo, I was not able to do it work but I know how to do it. You need to create your own NuGet package based on a fork of electronnet and replace the --no-self-contained in the build commands class.
@mhamri commented on GitHub (Jun 12, 2021):
but do you fix it for later version?
@gpgpublickey commented on GitHub (Jun 13, 2021):
I don't think so this is not my project, I can't update the official nuget repository
@mhamri commented on GitHub (Jun 13, 2021):
oh, thankx for the help anyway
@dealproc commented on GitHub (Apr 15, 2022):
I'm unsure if this'll help anyone... but it seems as-if you execute your blazor app using the following command, it fires as you'd expect it to:
electronize start .\source\Your.Host\Your.Host.csproj /PublishSingleFile false /PublishReadyToRun falseFor reference, I'm running this in my solution root folder, and I have all my "source" and "test" projects in dedicated folders.
@GregorBiswanger commented on GitHub (Mar 28, 2023):
🎉🚀 New Electron.NET version 23.6.1 released 🚀🎉
With native Electron 23 and .NET 6 support. Your problem should be fixed here. If you continue to have the problem, please let us know. Please note the correct updating of your API & CLI. Info in the README. Have fun!
@progmars commented on GitHub (Nov 23, 2024):
Somehow I have the same problem with a brand new .net8 Blazor app that has Client assembly. Fresh install of Electron.NET CLI and
<PackageReference Include="ElectronNET.API" Version="23.6.2" />So, in launchSettings.json
it tries to publish with
/p:PublishReadyToRun=true /p:PublishSingleFile=true --no-self-containedand fails withApplications published to a single-file are required to use the application host. You must either set PublishSingleFile to false or set UseAppHost to true.it tries to publish with
/p:PublishReadyToRun=true /p:PublishSingleFile=false --no-self-containedand fails withOptimizing assemblies for size is not supported for the selected publish configuration. Please ensure that you are publishing a self-contained app.it fails to pack the client project with
error WASM0005: Unable to resolve WebAssembly runtime pack version.What am I still missing here?