in make-util.js [953:1023]
var createAggregatedZip = function (packagePath) {
assert(packagePath, 'packagePath');
// get branch/commit info
var refs = getRefs();
// initialize the aggregated layout
// mark the layout with a version number.
// servicing supports both this new format and the legacy layout format as well.
console.log();
console.log('> Creating aggregated layout');
var aggregatedLayoutPath = path.join(packagePath, 'aggregated-layout');
mkdir('-p', aggregatedLayoutPath);
fs.writeFileSync(path.join(aggregatedLayoutPath, 'layout-version.txt'), '2');
// link the tasks from the non-aggregated layout into the aggregated layout
var nonAggregatedLayoutPath = path.join(packagePath, 'non-aggregated-layout');
linkAggregatedLayoutContent(nonAggregatedLayoutPath, aggregatedLayoutPath, /*release:*/'', /*commit:*/refs.head.commit);
// link the tasks from previous releases into the aggregated layout
Object.keys(refs.releases)
.sort()
.reverse()
.forEach(function (release) {
// skip the current release (already covered by current build)
if (release == refs.head.release) {
return;
}
var commit = refs.releases[release].commit;
var releaseLayout = getNonAggregatedLayout(packagePath, release, commit);
linkAggregatedLayoutContent(releaseLayout, aggregatedLayoutPath, /*release:*/release, /*commit:*/commit);
});
// validate task uniqueness within the layout based on task GUID + major version
var majorVersions = { };
fs.readdirSync(aggregatedLayoutPath) // walk each item in the aggregate layout
.forEach(function (itemName) {
var itemPath = path.join(aggregatedLayoutPath, itemName);
if (!fs.statSync(itemPath).isDirectory()) { // skip files
return;
}
// load the task.json
var taskPath = path.join(itemPath, 'task.json');
var task = JSON.parse(fs.readFileSync(taskPath));
if (typeof task.version.Major != 'number') {
fail(`Expected task.version.Major/Minor/Patch to be a number (${taskPath})`);
}
assert(task.id, `task.id (${taskPath})`);
if (typeof task.id != 'string') {
fail(`Expected id to be a string (${taskPath})`);
}
// validate GUID + Major version is unique
var key = task.id + task.version.Major;
if (majorVersions[key]) {
fail(`Tasks GUID + Major version must be unique within the aggregated layout. Task 1: ${majorVersions[key]}; task 2: ${taskPath}`);
}
majorVersions[key] = taskPath;
});
// create the aggregated tasks zip
console.log();
console.log('> Zipping aggregated tasks layout');
var aggregatedZipPath = path.join(packagePath, 'pack-source', 'contents', 'Microsoft.TeamFoundation.Build.Tasks.zip');
mkdir('-p', path.dirname(aggregatedZipPath));
compressTasks(aggregatedLayoutPath, aggregatedZipPath);
}