Successfully implemented through npm and gulp. For those attempting a similar task:
package.json
{
"version": "1.0.0",
"name": "ASP.NET",
"private": true,
"devDependencies": {
"gulp": "3.9.0",
"gulp-typescript": "2.10.0",
"gulp-concat": "2.6.0",
"gulp-sourcemaps": "1.6.0"
}
}
gulpfile.js (portion for generating 1 file)
var gulp = require('gulp');
var typescript = require('gulp-typescript');
var sourcemaps = require('gulp-sourcemaps');
gulp.task('compileTypeScriptFiles', function () {
var tsResult = gulp.src(['Scripts/file1.ts', 'Scripts/file2.ts'])
.pipe(sourcemaps.init()) // Sourcemaps will be generated
.pipe(typescript({
noImplicitAny: false,
target: 'ES5',
removeComments: true,
out: 'final.js',
preserveConstEnums: true,
noEmitOnError: false
}))
.pipe(sourcemaps.write('.')) // Write sourcemap to same folder
.pipe(gulp.dest('Scripts'));
});
For local development (VS 2015) link the action to Task Runner Explorer after build.
For TFS build server, follow these steps:
- Install node.js (https://nodejs.org/en/blog/release/v0.12.0/)
- Install rimraf. This is necessary to delete the node_module folder in your build since windows has deletion issues with this specific folder. Open the node cmd and execute "npm install rimraf -g"
- Create a powershell script and attach it to the pre-build event.
My powershell snippet
Param (
[string]$path = $env:TF_BUILD_SOURCESDIRECTORY
)
cd $path
# Install npm from package.json. An error might occur here due to outdated scripts but can be ignored.
&npm --loglevel=error install
# Compile typescript using gulpfile.js
&node_modules\.bin\gulp compileTypeScriptFiles
# Remove node modules.
&rimraf $path\node_modules
Hopefully this information proves useful.