I am using a TFS build project to build a Visual Studio 2015 project that contains a gulpfile for compiling SASS among other things. I am trying to understand the sequence of events using MSBuild Tasks and Task Runner bindings. It appears that MSBuild knows enough to detect and run my default gulp task BeforeBuild:
/// <binding BeforeBuild='default' />
var gulp = require('gulp');
var sass = require('gulp-sass');
var importer = require('sass-importer-npm');
gulp.task('sass', function () {
return gulp.src([
'./sass/**/*.scss',
'./node_modules/font-awesome/scss/**/*.scss'
])
.pipe(sass({ importer: importer }).on('error', sass.logError))
.pipe(gulp.dest('./Content/css'));
});
I am to using an MSBuild target to run after the BeforeBuild target so that I can include the generated files in the project for publishing:
<Target Name="CopyGulpFiles" AfterTargets="BeforeBuild">
Here is my MSBuild call in my build .proj file with the relevant info:
<ItemGroup>
<ProjectsToBuild Include="$(MSBuildThisFileDirectory)..\MyProject.sln">
<AdditionalProperties>
VisualStudioVersion=$(VisualStudioVersion);
OutputPath=$(OutputRoot);
WebPublishMethod=FileSystem;
publishUrl=$(StageFolder);
DeployOnBuild=false;
DeployTarget=WebPublish;
PublishProfile=$(MSBuildThisFileFullPath)
</AdditionalProperties>
</ProjectsToBuild>
</ItemGroup>
<MSBuild Projects="@(ProjectsToBuild)" Properties="Configuration=Dev"/>
These two things seem to run in the right order everytime I run them. This raises some questions though:
- Would the 'BeforeBuild' binding for Task Runner get executed before the 'BeforeBuild' target in MSBuild?
- Are the order of bindings/targets deterministic here?
- Does using the AfterTargets property ensure that this is run after the whole 'BeforeBuild' stage (targets and bindings) are completed?
- How does MSBuild know how to use my Gulp file? I assume it has to be the same mechanism as visual studio uses.