5

I have an ASP.NET Core project, which also hosts an Aurelia CLI project, using TypeScript / SASS. The IDE is Visual Studio 2015.

When the project is built by Visual Studio or MSBuild, the au build command is executed in the precompilation target, so when I build or run the ASP.NET Core project from Visual Studio using F5, Aurelia CLI will build and bundle the assets for the Aurelia app into wwwroot as well.

This workflow ensures that any solution changes are correctly built, and it also ensures that .NET Core is running as the web server, however, it's slow for developers, because any changes to front-end code (HTML, SASS, or TS) that need to be made requires full recompilation / bundling of the Aurelia app as well.

Recent changes to the Aurelia CLI (0.25+) have sped up the front-end build a lot, which is great, but it's still not optimal.

I can't use au run --watch because that doesn't run the .NET Core server.

I'm looking for guidance on how to optimize the developer workflow for this configuration - ideally, hitting F5 should work as it currently does, but with the addition of activating the watch in Aurelia as well, so that any changes to watched files will trigger an incremental build in Aurelia which updates the browser directly.

Sam
  • 6,167
  • 30
  • 39
  • "the au build command is executed in the precompilation target" Why not execute it on prepublish instead? So developers can run it once manually (i.e. on bundle a gulp task to the clear-trigger or on solution open). This way it won't rebuilt it when just changing a file and hitting F5 – Tseng Mar 23 '17 at 14:13

1 Answers1

3

We use au run --watch almost exclusively but we still run the app via F5 in VS as you would expect. We don't care that the run command actually serves the files (if there was a watch flag on the build command we would use au build --watch instead). We start the watch automatically when the project is first opened, then we can manually stop/restart it as we work throughout the day using tasks we defined in a gulpfile (see below) and the Task Runner Explorer window (so I don't need to have a console open). This way I only need to recompile the server side code when I actually change server side code.

We don't have browsersync set up so this doesn't refresh the browser automatically, but we're fine with that - I don't find that ctrl+R is a big time sink.

We have "au build --env prod" in the prepublish step to make sure the build machine does a production build.

Our gulpfile.js:

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

gulp.task('build-dev', shell.task(['au build --env dev']));
gulp.task('watch', shell.task(['au run --watch']));
gulp.task('test', shell.task(['au test --watch']));
gulp.task('build-prod', shell.task(['au build --env prod']));
mgiesa
  • 1,023
  • 7
  • 9
  • We had a PR to add the `--watch` flag to `au build`, but it caused issues and thus was closed. I have pinged Jedd Ahyoung to see if he can update that PR to fix the issues and get it added. – Ashley Grant Mar 23 '17 at 17:33
  • Thanks for the gulpfile, but I couldn't get it working. I did an `npm install gulp-shell --save-dev` first, then running the `watch` task generated this error: ```Error: spawn au run --watch ENOENT at exports._errnoException (util.js:856:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32) at onErrorNT (internal/child_process.js:344:16) at nextTickCallbackWith2Args (node.js:474:9) at process._tickCallback (node.js:388:17) at Function.Module.runMain (module.js:431:11) at startup (node.js:139:18) at node.js:999:3 ``` Any ideas? – Sam Mar 24 '17 at 01:03
  • 1
    Fixed the problem - http://stackoverflow.com/questions/35889975/gulp-task-failing-when-run-from-vs-2015-task-runner-explorer-but-not-from-comma was the underlying issue. – Sam Mar 24 '17 at 06:46
  • Ashley - thanks for doing that. Sam - glad you worked it out – mgiesa Mar 27 '17 at 04:08