简体   繁体   中英

Include files to build generated by angular-cli before build in asp.net mvc

I am struggling with a issue for files generated by nodejs needed to be included in build. It works well in local development but when i want to publish it then it won't include files fron dist folder to build and app will not have a dist folder. Can any one help on this?

Note:- files are created each time has different name so i cannot select and include them. I am using visual studio 2017. I hope i could explain the issue or let me know i can try better. Thanks in advance

You need to put your static files under the wwwroot folder to make them accessible on the production server.

To include those files for publishing, a simplest option would be to add them to wwwroot before a publishing starts, otherwise they will be ignored.

Another option would be to tell MSBuild to include the files explicitly. You can find an example of how to customize the project file at <Target Name="NgBuildAndAddToPublishOutput" AfterTargets="ComputeFilesToPublish"> .

You could build for production with Angular CLI with --output-hashing=none like so:

ng build --prod --output-hashing=none

And then include the generated js-files into your project-file (csproj). Then use a Script-bundle in BundleConfig.cs with BundleTable.EnableOptimizations = true; to generate the hashes for you by ASP.NET instead of Angular-cli.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM