emonney / QuickApp

ASP.NET Core / Angular startup project template with complete login, user and role management. Plus other useful services for Quick Application Development
https://www.ebenmonney.com/quickapp
MIT License
1.26k stars 594 forks source link

App doesn't publish. #75

Closed AnassL closed 6 years ago

AnassL commented 6 years ago

Publishing with Visual Studio 2017 give the following error:

Severity Code Description Project File Line Suppression State Error: The command "node node_modules/webpack/bin/webpack.js --env.prod" exited with code 2.
QuickApp C:\Projects\QuickApp\src\QuickApp\QuickApp.csproj 62

This is related to AOT compilation of Angular, and I read some explanations here.

For a given component all its members (methods, properties) accessed by its template must be public in the ahead-of-time compilation scenario. This is due to the fact that a template is turned into a TS class. A generated class and a component are 2 separate classes now and you can't access private members cross-class.

Could someone confirm that this is the case here ?

If so where specifically apply the changes ?

I am using: Angular version: 5.1.1 tried also with 5.1.0 (same error) Browser: [all] Language: [TypeScript 2.6.2] Node (for AoT issues): node --version = 8.9.3 (LTS) npm --version = 5.5.1

emonney commented 6 years ago

This is the case for all angular apps from version 4.x and above (I don't recall the exact version). You have a property you're referencing from the template and you need to remove the private access modifier from it. Are you experiencing this from a vanilla installation?

Support requests are better discussed from the support forum. And github issues for bug reports.

AnassL commented 6 years ago

I just tried a new vanilla installation, and this issue don't happen, so as you said I need to find the private access causing that. Thank you.

codestellar commented 6 years ago

@Sami-L This is indeed having issue. So, I published them separately. Removed this code from QuickApp.csproj `

<Exec Command="npm install" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" />
<Exec Command="node node_modules/webpack/bin/webpack.js --env.prod" />

<!-- Include the newly-built files in the publish output -->
<ItemGroup>
  <DistFiles Include="wwwroot\dist\**; ClientApp\dist\**" />
  <ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
    <RelativePath>%(DistFiles.Identity)</RelativePath>
    <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
  </ResolvedFileToPublish>
</ItemGroup>

` Then run the following commands:

  1. dotnet publish -c release -r win10-x64 --self-contained
  2. webpack --config webpack.config.vendor.js
  3. webpack
  4. Copy the publish folder in bin > release > win10-x64 > publish and dist from wwwroot to the location where you want to deploy or add tasks in the deployment profile.
AnassL commented 6 years ago

@codestellar thanks for the workaround,

  1. dotnet publish -c release -r win10-x64 --self-contained still gives the error: The command "node node_modules/webpack/bin/webpack.js --env.prod" exited with code 2
  2. ok
  3. ok
  4. There is nothing to copy from the ~\bin\release\win10-x64\publish folder

I copied the ~\bin\release\win10-x64 folder content and the wwwroot folder to the hosting folder, but got the following error: HTTP Error 502.5 - Process Failure

codestellar commented 6 years ago

@Sami-L Make sure that you have installed ASPNet Core module. https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/aspnet-core-module?tabs=aspnetcore2x

AnassL commented 6 years ago

Figured it out,

Visual Studio 2017 doesn't detect all TypeScript errors, thanks to this link I could find an error in code using the command

node node_modules/webpack/bin/webpack.js --env.prod

fixed the error, then the project published normally.

codestellar commented 6 years ago

@Sami-L I would recommend using VSCode strongly specially for front end development. :) The command line gives clear errors :)

AnassL commented 6 years ago

@codestellar I agree, thank you, now I have to check errors also with VSCode, since VS 2017 keeps needed for Backend tasks.