Electron.net: Fail to build when using dotnet spa templates

Created on 12 Aug 2018  路  11Comments  路  Source: ElectronNET/Electron.NET

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.

bug

All 11 comments

Hello @bravecobra

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

Best,
Gregor

I am using .NET Core 2.1 already.

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

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

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

I think the webpack could find errors

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

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.

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.

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

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

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GregorBiswanger picture GregorBiswanger  路  4Comments

ernestotw85 picture ernestotw85  路  3Comments

yoDon picture yoDon  路  4Comments

philiphobgen picture philiphobgen  路  3Comments

BrianAllred picture BrianAllred  路  5Comments