function updateTaskVersion()

in BuildTasks/Common/Common.ts [376:401]


function updateTaskVersion(manifest: any, extensionVersionString: string, extensionVersionType: string): unknown {
    const versionParts = extensionVersionString.split(".");
    if (versionParts.length > 3) {
        tl.warning("Detected a version that consists of more than 3 parts. Build tasks support only 3 parts, ignoring the rest.");
    }

    const extensionversion = { major: +versionParts[0], minor: +versionParts[1], patch: +versionParts[2] };

    if (!manifest.version && extensionVersionType !== "major") {
        tl.warning("Detected no version in task manifest. Forcing major.");
        manifest.version = extensionversion;
    } else {
        tl.debug(`Task manifest ${manifest.name} version before: ${JSON.stringify(manifest.version)}`);

        switch (extensionVersionType) {
            default:
            case "major": manifest.version.Major = `${extensionversion.major}`;
            // eslint-disable-next-line no-fallthrough
            case "minor": manifest.version.Minor = `${extensionversion.minor}`;
            // eslint-disable-next-line no-fallthrough
            case "patch": manifest.version.Patch = `${extensionversion.patch}`;
        }
    }
    tl.debug(`Task manifest ${manifest.name} version after: ${JSON.stringify(manifest.version)}`);
    return manifest;
}