Electron.NET
Electron.NET copied to clipboard
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
I am seeing this error and couldn't find a workaround
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
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've got a PR in #531 to expose all the other compile time properties /property
values to the electronize command. Does this solve your issue?
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.
I encountered the same issue. If I understood correctly there is no workaround for starting application without generating executable file?
Has anyone been able to get the "start" command to work? Is there some combination of flags that can be used as a workaround?
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?
Hi all, I just decided to try testing blazor in electron and see this same problem.
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:
And run the app in DEBUG mode using the Electron.NET App profile
Happy debugging As suggestion I pushed this PR #570
@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.
What is your issue when you try to run it normally? pls share your results
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.
Let start using a stable release, update your project to target Net5 instead of net6 preview
Here is the same error again using the stable version of VS and Net5.
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
ok, I will take a look later but seems to be you are currently using the sdk/6.0.100-preview
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
@cristiangiagante I am using sdk 5.0, I can create a new repo so you can try it out
I'll figure out how to make mine use SDK 5.0. Maybe that will help me.
https://github.com/mhamri/ElectronNet-blazor-bug
I have v5.0.2 sdk installed on my laptop
Based on the StartElectronCommand class from electronnet https://github.com/ElectronNET/Electron.NET/blob/30941df39c49f82720011c2444f4af4cbd7b8569/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?
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?
as a workaround I created a blazor server side (instead of webassembly with backed asp.net) and everything bundled just fine
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.
but do you fix it for later version?
I don't think so this is not my project, I can't update the official nuget repository
oh, thankx for the help anyway
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 false
For reference, I'm running this in my solution root folder, and I have all my "source" and "test" projects in dedicated folders.
🎉🚀 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!