Fail to build when using dotnet spa templates #207

Closed
opened 2026-01-29 16:33:49 +00:00 by claunia · 11 comments
Owner

Originally created by @bravecobra on GitHub (Aug 12, 2018).

Originally assigned to: @robertmuehsig, @GregorBiswanger on GitHub.

I use the angular template of https://github.com/aspnet/templating, but electronizing it fails. The dotnet publish fails at the last step trying to build the SPA

<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
    <!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
    <Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
    <Exec WorkingDirectory="$(SpaRoot)" Command="npm run build -- --prod" />
    <Exec WorkingDirectory="$(SpaRoot)" Command="npm run build:ssr -- --prod" Condition=" '$(BuildServerSideRenderer)' == 'true' " />
    <!-- Include the newly-built files in the publish output -->
    <ItemGroup>
      <DistFiles Include="$(SpaRoot)dist\**; $(SpaRoot)dist-server\**" />
      <DistFiles Include="$(SpaRoot)node_modules\**" Condition="'$(BuildServerSideRenderer)' == 'true'" />
      <ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
        <RelativePath>%(DistFiles.Identity)</RelativePath>
        <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
      </ResolvedFileToPublish>
    </ItemGroup>
  </Target>

Doing the ng build upfront and commenting the above part out of the csproj, makes it work perfectly. So there must be something going on with the publish function being called during start.

Originally created by @bravecobra on GitHub (Aug 12, 2018). Originally assigned to: @robertmuehsig, @GregorBiswanger on GitHub. I use the angular template of https://github.com/aspnet/templating, but electronizing it fails. The dotnet publish fails at the last step trying to build the SPA ``` <Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish"> <!-- As part of publishing, ensure the JS resources are freshly built in production mode --> <Exec WorkingDirectory="$(SpaRoot)" Command="npm install" /> <Exec WorkingDirectory="$(SpaRoot)" Command="npm run build -- --prod" /> <Exec WorkingDirectory="$(SpaRoot)" Command="npm run build:ssr -- --prod" Condition=" '$(BuildServerSideRenderer)' == 'true' " /> <!-- Include the newly-built files in the publish output --> <ItemGroup> <DistFiles Include="$(SpaRoot)dist\**; $(SpaRoot)dist-server\**" /> <DistFiles Include="$(SpaRoot)node_modules\**" Condition="'$(BuildServerSideRenderer)' == 'true'" /> <ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)"> <RelativePath>%(DistFiles.Identity)</RelativePath> <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> </ResolvedFileToPublish> </ItemGroup> </Target> ``` Doing the `ng build` upfront and commenting the above part out of the csproj, makes it work perfectly. So there must be something going on with the publish function being called during start.
claunia added the bug label 2026-01-29 16:33:49 +00:00
Author
Owner

@GregorBiswanger commented on GitHub (Sep 25, 2018):

Hello @bravecobra

which .NET core version do you use?
The next big release from Electron.NET Supports 2.1.

Best,
Gregor

@GregorBiswanger commented on GitHub (Sep 25, 2018): Hello @bravecobra which .NET core version do you use? The next big release from Electron.NET Supports 2.1. Best, Gregor
Author
Owner

@bravecobra commented on GitHub (Sep 27, 2018):

I am using .NET Core 2.1 already.

@bravecobra commented on GitHub (Sep 27, 2018): I am using .NET Core 2.1 already.
Author
Owner

@robertmuehsig commented on GitHub (Sep 27, 2018):

Mh... can you try to invoke the electronize command from a admin prompt? It appears that it fails because of some npm issues.

@robertmuehsig commented on GitHub (Sep 27, 2018): Mh... can you try to invoke the electronize command from a admin prompt? It appears that it fails because of some npm issues.
Author
Owner

@bravecobra commented on GitHub (Oct 1, 2018):

Same result. I don't think it's an admin issue though. Can you reproduce the issue?

@bravecobra commented on GitHub (Oct 1, 2018): Same result. I don't think it's an admin issue though. Can you reproduce the issue?
Author
Owner

@yamaoto commented on GitHub (Oct 2, 2018):

did you tried exec
npm run build -- --prod
npm run build:ssr -- --prod
?

I think the webpack could find errors

@yamaoto commented on GitHub (Oct 2, 2018): did you tried exec npm run build -- --prod npm run build:ssr -- --prod ? I think the webpack could find errors
Author
Owner

@bravecobra commented on GitHub (Oct 2, 2018):

Yes, first thing I tried. Those run perfectly. My node version is 8.11.3, npm version is 5.11

@bravecobra commented on GitHub (Oct 2, 2018): Yes, first thing I tried. Those run perfectly. My node version is 8.11.3, npm version is 5.11
Author
Owner

@bravecobra commented on GitHub (Oct 2, 2018):

Just to be sure, I ran the npm commands again and checked the exitcodes. Apparently that's, like expected, being 0. I also ran the actual command ElectronNET is executing, namely the dotnet publish -r win-x64 --output "<%abspath%>\obj\Host\bin" and that also exits with 0. So I also fail to see why the dotnet electronize start would fail executing the same command.

@bravecobra commented on GitHub (Oct 2, 2018): Just to be sure, I ran the npm commands again and checked the exitcodes. Apparently that's, like expected, being 0. I also ran the actual command ElectronNET is executing, namely the `dotnet publish -r win-x64 --output "<%abspath%>\obj\Host\bin"` and that also exits with 0. So I also fail to see why the `dotnet electronize start` would fail executing the same command.
Author
Owner

@bravecobra commented on GitHub (Oct 2, 2018):

I just found these lines in the source code. c1bd48b58d/ElectronNET.CLI/ProcessHelper.cs (L47-L50)
Sorry to say but that's unfortunately a naive way of interpreting the output. The build output of Angular does contain that word, because it has error handlers. It sure sounds like that's the reason it fails...there must be another way to check for the actual exitcode.

@bravecobra commented on GitHub (Oct 2, 2018): I just found these lines in the source code. https://github.com/ElectronNET/Electron.NET/blob/c1bd48b58de773967ca01b60407e6dc6ef10f9fa/ElectronNET.CLI/ProcessHelper.cs#L47-L50 Sorry to say but that's unfortunately a naive way of interpreting the output. The build output of Angular does contain that word, because it has error handlers. It sure sounds like that's the reason it fails...there must be another way to check for the actual exitcode.
Author
Owner

@aplocher commented on GitHub (Dec 6, 2018):

Running into the same issue when using ASP.NET Core / Angular config'ed project template

@aplocher commented on GitHub (Dec 6, 2018): Running into the same issue when using ASP.NET Core / Angular config'ed project template
Author
Owner

@aboimpinto commented on GitHub (Dec 14, 2018):

hello ...
I'm having the same issue. I follow the tutorial
https://www.youtube.com/watch?v=nuM6AojRFHk
that says that we should use the SPA but the example is with a MVC and Controllers ... the SPA return this strange error.

Can you please make a tutorial with SPA or tell us how to create this... please!!!

Paulo Aboim Pinto

@aboimpinto commented on GitHub (Dec 14, 2018): hello ... I'm having the same issue. I follow the tutorial https://www.youtube.com/watch?v=nuM6AojRFHk that says that we should use the SPA but the example is with a MVC and Controllers ... the SPA return this strange error. Can you please make a tutorial with SPA or tell us how to create this... please!!! Paulo Aboim Pinto
Author
Owner

@LeatonChuter commented on GitHub (Apr 15, 2019):

I too am having this problem, both build and publish work independently but Dotnet Electronize Start throws a ''Error occurred during dotnet publish".

A tutorial for SPA or just a fix for this problem if that's all the issue is would be greatly appreciated!

@LeatonChuter commented on GitHub (Apr 15, 2019): I too am having this problem, both build and publish work independently but Dotnet Electronize Start throws a ''Error occurred during dotnet publish". A tutorial for SPA or just a fix for this problem if that's all the issue is would be greatly appreciated!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#207