tasks/customaction.py
def build(ctx, vstudio_root=None, arch="x64", major_version='7', debug=False):
    """
    Build the custom action library for the agent
    """

    if sys.platform != 'win32':
        print("Custom action library is only for Win32")
        raise Exit(code=1)

    package_version = get_version(ctx, url_safe=True, major_version=major_version)
    ver = get_version_numeric_only(ctx, major_version=major_version)
    build_maj, build_min, build_patch = ver.split(".")
    verprops = f" /p:MAJ_VER={build_maj} /p:MIN_VER={build_min} /p:PATCH_VER={build_patch} "
    print(f"arch is {arch}")
    cmd = ""
    configuration = "Release"
    if debug:
        configuration = "Debug"

    if not os.getenv("VCINSTALLDIR"):
        print("VC Not installed in environment; checking other locations")

        vsroot = vstudio_root or os.getenv('VSTUDIO_ROOT')
        if not vsroot:
            print("Must have visual studio installed")
            raise Exit(code=2)
        batchfile = "vcvars64.bat"
        if arch == "x86":
            batchfile = "vcvars32.bat"
        vs_env_bat = f'{vsroot}\\VC\\Auxiliary\\Build\\{batchfile}'
        cmd = f'call "{vs_env_bat}" && msbuild {CUSTOM_ACTION_ROOT_DIR}\\cal /p:Configuration={configuration} /p:Platform={arch}'
    else:
        cmd = f'msbuild {CUSTOM_ACTION_ROOT_DIR}\\cal /p:Configuration={configuration} /p:Platform={arch}'

    cmd += verprops
    print(f"Build Command: {cmd}")

    # Try to run the command 3 times to alleviate transient
    # network failures
    succeeded = try_run(ctx, cmd, 3)
    if not succeeded:
        raise Exit("Failed to build the customaction.", code=1)

    artefacts = [
        {"source": "customaction.dll", "target": "customaction.dll"},
        {"source": "customaction.pdb", "target": f"customaction-{package_version}.pdb"},
        {"source": "customaction-tests.exe", "target": "customaction-tests.exe"},
    ]
    for artefact in artefacts:
        shutil.copy2(
            f"{CUSTOM_ACTION_ROOT_DIR}\\cal\\{arch}\\{configuration}\\{artefact['source']}",
            BIN_PATH + f"\\{artefact['target']}",
        )

    Build the custom action library for the agent
    
Build the custom action library for the agent
Build the custom action library for the agent
def build(ctx, vstudio_root=None, arch="x64", major_version='7', debug=False):
    if sys.platform != 'win32':
        print("Custom action library is only for Win32")
        raise Exit(code=1)
    package_version = get_version(ctx, url_safe=True, major_version=major_version)
    ver = get_version_numeric_only(ctx, major_version=major_version)
    build_maj, build_min, build_patch = ver.split(".")
    verprops = f" /p:MAJ_VER={build_maj} /p:MIN_VER={build_min} /p:PATCH_VER={build_patch} "
    print(f"arch is {arch}")
    cmd = ""
    configuration = "Release"
    if debug:
        configuration = "Debug"
    if not os.getenv("VCINSTALLDIR"):
        print("VC Not installed in environment; checking other locations")
        vsroot = vstudio_root or os.getenv('VSTUDIO_ROOT')
        if not vsroot:
            print("Must have visual studio installed")
            raise Exit(code=2)
        batchfile = "vcvars64.bat"
        if arch == "x86":
            batchfile = "vcvars32.bat"
        vs_env_bat = f'{vsroot}\\VC\\Auxiliary\\Build\\{batchfile}'
        cmd = f'call "{vs_env_bat}" && msbuild {CUSTOM_ACTION_ROOT_DIR}\\cal /p:Configuration={configuration} /p:Platform={arch}'
    else:
        cmd = f'msbuild {CUSTOM_ACTION_ROOT_DIR}\\cal /p:Configuration={configuration} /p:Platform={arch}'
    cmd += verprops
    print(f"Build Command: {cmd}")
    succeeded = try_run(ctx, cmd, 3)
    if not succeeded:
        raise Exit("Failed to build the customaction.", code=1)
    artefacts = [
        {"source": "customaction.dll", "target": "customaction.dll"},
        {"source": "customaction.pdb", "target": f"customaction-{package_version}.pdb"},
        {"source": "customaction-tests.exe", "target": "customaction-tests.exe"},
    ]
    for artefact in artefacts:
        shutil.copy2(
            f"{CUSTOM_ACTION_ROOT_DIR}\\cal\\{arch}\\{configuration}\\{artefact['source']}",
            BIN_PATH + f"\\{artefact['target']}",
        )
def build ( ctx , vstudio_root = None , arch = "x64" , major_version = '7' , debug = False ) : if sys . platform != 'win32' : print ( "Custom action library is only for Win32" ) raise Exit ( code = 1 ) package_version = get_version ( ctx , url_safe = True , major_version = major_version ) ver = get_version_numeric_only ( ctx , major_version = major_version ) build_maj , build_min , build_patch = ver . split ( "." ) verprops = f" /p:MAJ_VER={build_maj} /p:MIN_VER={build_min} /p:PATCH_VER={build_patch} " print ( f"arch is {arch}" ) cmd = "" configuration = "Release" if debug : configuration = "Debug" if not os . getenv ( "VCINSTALLDIR" ) : print ( "VC Not installed in environment; checking other locations" ) vsroot = vstudio_root or os . getenv ( 'VSTUDIO_ROOT' ) if not vsroot : print ( "Must have visual studio installed" ) raise Exit ( code = 2 ) batchfile = "vcvars64.bat" if arch == "x86" : batchfile = "vcvars32.bat" vs_env_bat = f'{vsroot}\\VC\\Auxiliary\\Build\\{batchfile}' cmd = f'call "{vs_env_bat}" && msbuild {CUSTOM_ACTION_ROOT_DIR}\\cal /p:Configuration={configuration} /p:Platform={arch}' else : cmd = f'msbuild {CUSTOM_ACTION_ROOT_DIR}\\cal /p:Configuration={configuration} /p:Platform={arch}' cmd += verprops print ( f"Build Command: {cmd}" ) succeeded = try_run ( ctx , cmd , 3 ) if not succeeded : raise Exit ( "Failed to build the customaction." , code = 1 ) artefacts = [ { "source" : "customaction.dll" , "target" : "customaction.dll" } , { "source" : "customaction.pdb" , "target" : f"customaction-{package_version}.pdb" } , { "source" : "customaction-tests.exe" , "target" : "customaction-tests.exe" } , ] for artefact in artefacts : shutil . copy2 ( f"{CUSTOM_ACTION_ROOT_DIR}\\cal\\{arch}\\{configuration}\\{artefact['source']}" , BIN_PATH + f"\\{artefact['target']}" , )
Build the custom action library for the agent
Build the custom action library for the agent
"""
    Build the custom action library for the agent
    """ # Try to run the command 3 times to alleviate transient # network failures
ctx
vstudio_root
arch
major_version
debug