Unable to Publish Project #1031

Closed
opened 2026-01-29 16:55:48 +00:00 by claunia · 13 comments
Owner

Originally created by @AeonSake on GitHub (Dec 6, 2025).

Whenever I try to publish an ASP.NET project following the provided steps in the wiki, the build fails with the following exception when running the electron-builder:

ENOENT: no such file or directory, stat '<path_to_solution>\BlazorApp1\BlazorApp1\obj\Release\net10.0\win-x64\PubTmp\Out\node_modules\electron-host-hook'  failedTask=build stackTrace=Error: ENOENT: no such file or directory, stat '<path_to_solution>\BlazorApp1\BlazorApp1\obj\Release\net10.0\win-x64\PubTmp\Out\node_modules\electron-host-hook'
  • NuGet Version: 0.2.0
  • Electron Version: 30.4.0 (not specified in .csproj)
  • Electron Builder Version: 26.0.12 (not specified in .csproj)
  • Framework: net10.0
  • Target: win-x64 (specified via publish profile)
  • IDE: Visual Studio 2026 18.0.1

Steps to Reproduce:

  1. Create a new Blazor Web App, targeting net10.0
  2. Add ElectronNET.Core and ElectronNET.Core.AspNet version 0.2.0 as NuGet packages
  3. Add builder.UseElectron(args, ElectronAppReady); to the builder call and the following method for creating the window:
private static async Task ElectronAppReady()
{
    var browserWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions {Show = false});
    browserWindow.OnReadyToShow += () => browserWindow.Show();
}
  1. Create a publish profile under Properties/PublishProfile (in this case as win-x64.pubxml) with the following content:
<?xml version="1.0" encoding="utf-8"?>
<Project>
  <PropertyGroup>
    <Configuration>Release</Configuration>
    <Platform>Any CPU</Platform>
    <PublishDir>publish\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\</PublishDir>
    <PublishProtocol>FileSystem</PublishProtocol>
    <TargetFramework>net10.0</TargetFramework>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <SelfContained>true</SelfContained>
    <PublishSingleFile>false</PublishSingleFile>
  </PropertyGroup>
</Project>
  1. Publish the project using the Visual Studio interface

I also tried specifying a specific Electron and electron-builder version in the .csproj file without success. Normal debug/release builds and running it succeed without issues. I tried following the provided wiki pages as close as possible. If I'm doing something wrong, please correct me.

Please note, that this happened in a newly created blank project. I initially ran into this same issue when reworking a more complex project (several package and project dependencies) to use this package. It might be a related issue but publishing that more complex project also DELETED ALL SOURCE FILES within that project directory. Luckily, I had all relevant changes committed or staged.

Originally created by @AeonSake on GitHub (Dec 6, 2025). Whenever I try to publish an ASP.NET project following the provided steps in the wiki, the build fails with the following exception when running the electron-builder: ``` ENOENT: no such file or directory, stat '<path_to_solution>\BlazorApp1\BlazorApp1\obj\Release\net10.0\win-x64\PubTmp\Out\node_modules\electron-host-hook' failedTask=build stackTrace=Error: ENOENT: no such file or directory, stat '<path_to_solution>\BlazorApp1\BlazorApp1\obj\Release\net10.0\win-x64\PubTmp\Out\node_modules\electron-host-hook' ``` * **NuGet Version**: 0.2.0 * **Electron Version**: 30.4.0 (not specified in `.csproj`) * **Electron Builder Version**: 26.0.12 (not specified in `.csproj`) * **Framework**: net10.0 * **Target**: win-x64 (specified via publish profile) * **IDE**: Visual Studio 2026 18.0.1 Steps to Reproduce: 1. Create a new Blazor Web App, targeting `net10.0` 2. Add `ElectronNET.Core` and `ElectronNET.Core.AspNet` version 0.2.0 as NuGet packages 3. Add `builder.UseElectron(args, ElectronAppReady);` to the builder call and the following method for creating the window: ```cs private static async Task ElectronAppReady() { var browserWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions {Show = false}); browserWindow.OnReadyToShow += () => browserWindow.Show(); } ``` 4. Create a publish profile under `Properties/PublishProfile` (in this case as `win-x64.pubxml`) with the following content: ```xml <?xml version="1.0" encoding="utf-8"?> <Project> <PropertyGroup> <Configuration>Release</Configuration> <Platform>Any CPU</Platform> <PublishDir>publish\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\</PublishDir> <PublishProtocol>FileSystem</PublishProtocol> <TargetFramework>net10.0</TargetFramework> <RuntimeIdentifier>win-x64</RuntimeIdentifier> <SelfContained>true</SelfContained> <PublishSingleFile>false</PublishSingleFile> </PropertyGroup> </Project> ``` 5. Publish the project using the Visual Studio interface I also tried specifying a specific Electron and electron-builder version in the `.csproj` file without success. Normal debug/release builds and running it succeed without issues. I tried following the provided wiki pages as close as possible. If I'm doing something wrong, please correct me. Please note, that this happened in a newly created blank project. I initially ran into this same issue when reworking a more complex project (several package and project dependencies) to use this package. It might be a related issue but publishing that more complex project also **DELETED ALL SOURCE FILES** within that project directory. Luckily, I had all relevant changes committed or staged.
claunia added the bug label 2026-01-29 16:55:48 +00:00
Author
Owner

@FlorianRappl commented on GitHub (Dec 7, 2025):

Try the latest preview version of 0.3.0.

@FlorianRappl commented on GitHub (Dec 7, 2025): Try the latest preview version of 0.3.0.
Author
Owner

@AeonSake commented on GitHub (Dec 7, 2025):

Tried with 0.3.0-pre.314 which now also deletes the entire project directory content on publish. Seems like I must have used a pre-release package in the more complex project too.
The error now is:

<path_to_user>\.nuget\packages\electronnet.core\0.3.0-pre.314\build\ElectronNET.LateImport.targets(397,5): Error MSB3030: Could not copy the file "obj\Release\net10.0\win-x64\.electron\package.json" because it was not found.
@AeonSake commented on GitHub (Dec 7, 2025): Tried with `0.3.0-pre.314` which now also deletes the entire project directory content on publish. Seems like I must have used a pre-release package in the more complex project too. The error now is: ``` <path_to_user>\.nuget\packages\electronnet.core\0.3.0-pre.314\build\ElectronNET.LateImport.targets(397,5): Error MSB3030: Could not copy the file "obj\Release\net10.0\win-x64\.electron\package.json" because it was not found. ```
Author
Owner

@softworkz commented on GitHub (Dec 7, 2025):

@AeonSake - Please take a look at this: https://github.com/ElectronNET/Electron.NET/issues/946 and make sure that your project fulfills all those (not yet implemented) conditions.

@softworkz commented on GitHub (Dec 7, 2025): @AeonSake - Please take a look at this: https://github.com/ElectronNET/Electron.NET/issues/946 and make sure that your project fulfills all those (not yet implemented) conditions.
Author
Owner

@AeonSake commented on GitHub (Dec 7, 2025):

@softworkz both projects fulfill all those checks; this also happens in a brand new blank project.

@AeonSake commented on GitHub (Dec 7, 2025): @softworkz both projects fulfill all those checks; this also happens in a brand new blank project.
Author
Owner

@softworkz commented on GitHub (Dec 7, 2025):

Can you provide a sample project? (also in-private, if you prefer)

@softworkz commented on GitHub (Dec 7, 2025): Can you provide a sample project? (also in-private, if you prefer)
Author
Owner

@AeonSake commented on GitHub (Dec 7, 2025):

Sure; here is a default Blazor Web App for net10.0 (including the default sample pages). I only added the packages, builder calls, and the publish profile from above.
If you use any 0.3.0 version, the project directory will be wiped. If you use 0.2.0 it will result in the error from above.

BlazorApp1.zip

@AeonSake commented on GitHub (Dec 7, 2025): Sure; here is a default Blazor Web App for net10.0 (including the default sample pages). I only added the packages, builder calls, and the publish profile from above. If you use any 0.3.0 version, the project directory will be wiped. If you use 0.2.0 it will result in the error from above. [BlazorApp1.zip](https://github.com/user-attachments/files/24014791/BlazorApp1.zip)
Author
Owner

@softworkz commented on GitHub (Dec 7, 2025):

@AeonSake

I have

  • unzipped your project
  • opened in Visual Studio 2022
  • Created a git repo (to detect any deletions)
  • Rebuild solution
  • Start debug

There were no deletions and it's working fine:

Image
@softworkz commented on GitHub (Dec 7, 2025): @AeonSake I have - unzipped your project - opened in Visual Studio 2022 - Created a git repo (to detect any deletions) - Rebuild solution - Start debug There were no deletions and it's working fine: <img width="1918" height="1149" alt="Image" src="https://github.com/user-attachments/assets/4b2f2e0d-5b47-46fe-a80f-365c1c145fac" />
Author
Owner

@softworkz commented on GitHub (Dec 7, 2025):

Ah sorry - you said "on publish". I see it now.

The reason why this happens is that you are using the wrong publish profile (copied from somewhere else?)

When you use the publish wizard to publish the project, everything will be working fine.

Example:

<?xml version="1.0" encoding="utf-8"?>
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
<Project>
  <PropertyGroup>
    <DeleteExistingFiles>true</DeleteExistingFiles>
    <ExcludeApp_Data>false</ExcludeApp_Data>
    <LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <PublishProvider>FileSystem</PublishProvider>
    <PublishUrl>publish\Release\net10.0\win-x64\</PublishUrl>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <_TargetId>Folder</_TargetId>
    <SiteUrlToLaunchAfterPublish />
    <TargetFramework>net10.0</TargetFramework>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <ProjectGuid>48eff821-2f4d-60cc-aa44-be0f1d6e5f35</ProjectGuid>
    <SelfContained>true</SelfContained>
  </PropertyGroup>
</Project>

Background: Folder publishing for ASP.Net projects is a whole different implementation, even though it looks like it was the same. The pubxml files must not be mixed between ASP.Net and other projects (like cosole app).

@softworkz commented on GitHub (Dec 7, 2025): Ah sorry - you said "on publish". I see it now. The reason why this happens is that you are using the wrong publish profile (copied from somewhere else?) When you use the publish wizard to publish the project, everything will be working fine. Example: ```xml <?xml version="1.0" encoding="utf-8"?> <!-- https://go.microsoft.com/fwlink/?LinkID=208121. --> <Project> <PropertyGroup> <DeleteExistingFiles>true</DeleteExistingFiles> <ExcludeApp_Data>false</ExcludeApp_Data> <LaunchSiteAfterPublish>true</LaunchSiteAfterPublish> <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration> <LastUsedPlatform>Any CPU</LastUsedPlatform> <PublishProvider>FileSystem</PublishProvider> <PublishUrl>publish\Release\net10.0\win-x64\</PublishUrl> <WebPublishMethod>FileSystem</WebPublishMethod> <_TargetId>Folder</_TargetId> <SiteUrlToLaunchAfterPublish /> <TargetFramework>net10.0</TargetFramework> <RuntimeIdentifier>win-x64</RuntimeIdentifier> <ProjectGuid>48eff821-2f4d-60cc-aa44-be0f1d6e5f35</ProjectGuid> <SelfContained>true</SelfContained> </PropertyGroup> </Project> ``` Background: Folder publishing for ASP.Net projects is a whole different implementation, even though it looks like it was the same. The pubxml files must not be mixed between ASP.Net and other projects (like cosole app).
Author
Owner

@AeonSake commented on GitHub (Dec 7, 2025):

Oh, interesting... I was following the wiki which listed my initial publish profile. Thanks for clarifying. It would probably be a good idea to update the wiki pages to have the correct publishing instructions.

@AeonSake commented on GitHub (Dec 7, 2025): Oh, interesting... I was following the [wiki](https://github.com/ElectronNET/Electron.NET/wiki/Package-Building) which listed my initial publish profile. Thanks for clarifying. It would probably be a good idea to update the wiki pages to have the correct publishing instructions.
Author
Owner

@softworkz commented on GitHub (Dec 7, 2025):

Ohhh ouch - that was my fault!

I'm very sorry about that!

@softworkz commented on GitHub (Dec 7, 2025): Ohhh ouch - that was my fault! I'm very sorry about that!
Author
Owner

@AeonSake commented on GitHub (Dec 7, 2025):

All good, glad it was solved regardless.

@AeonSake commented on GitHub (Dec 7, 2025): All good, glad it was solved regardless.
Author
Owner

@AeonSake commented on GitHub (Dec 7, 2025):

So publishing the example project now works perfectly, just not with the more complex project. But that might just be on my end. I'll try tweaking different things to hopefully get it to work. I think you can close the issue, unless you want to keep it around until the wiki is updated.

@AeonSake commented on GitHub (Dec 7, 2025): So publishing the example project now works perfectly, just not with the more complex project. But that might just be on my end. I'll try tweaking different things to hopefully get it to work. I think you can close the issue, unless you want to keep it around until the wiki is updated.
Author
Owner

@softworkz commented on GitHub (Dec 7, 2025):

So publishing the example project now works perfectly, just not with the more complex project. But that might just be on my end.

Let us know when you got any more questions!

unless you want to keep it around until the wiki is updated.

PR submitted already: https://github.com/ElectronNET/Electron.NET/pull/965

@softworkz commented on GitHub (Dec 7, 2025): > So publishing the example project now works perfectly, just not with the more complex project. But that might just be on my end. Let us know when you got any more questions! > unless you want to keep it around until the wiki is updated. PR submitted already: https://github.com/ElectronNET/Electron.NET/pull/965
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#1031