Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

422
Views
.Net Core / Angular CLI - NPM Build Automation (html to cshtml)

I am developing a build process using .Net Core (netcoreapp1.1) and Angular CLI (1.0.1) using npm scripts in Visual Studio 2017.

Is it possible to script npm to take the contents of the Index.html body tag (from the file created by Angular CLI) and place it into the body of a .cshtml file?

Ideally, I would like to use npm scripts exclusively and move away from Gulp, but I can accept a Gulp solution if necessary.

Update for clarification: My objective is to include the necessary scripts from the Index.html file created by Angular CLI into a pre-existing cshtml View that has some code that I need to keep.

If it is necessary to create a new file, is there a way to parse the data from two existing files (html and cshtml) and join them into one? I really just need the scripts from the body of the html added to my View.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

If you're not going to be adding any server code to the generated HTML and you're really just looking to rename file, then it could be as simple as using the CLI itself.

  • Renaming index.html to index.cshtml
  • Updating the index entry in .angular-cli.json to index.cshtml
  • And then build normally using the CLI

I tested this with a new project and seemed to work well with both a dev build (ng b) as well as production (ng b -prod -aot). You may also try actually including some server code, though you may run into some parse errors if the compiler finds invalid markup.

over 4 years ago · Santiago Trujillo Report

0

this is a gulp solution,

var gulp = require('gulp');
var rename = require('gulp-rename');

gulp.task('default', function () {
    copy('<your html path>', 'cshtml file name', '<destination path>');
});

function copy(src, filename, dest) {
    gulp.src(src)
        .pipe(rename(filename))
        .pipe(gulp.dest(dest));
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!