当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ToolRunner.argIf方法代码示例

本文整理汇总了TypeScript中vsts-task-lib/toolrunner.ToolRunner.argIf方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ToolRunner.argIf方法的具体用法?TypeScript ToolRunner.argIf怎么用?TypeScript ToolRunner.argIf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vsts-task-lib/toolrunner.ToolRunner的用法示例。


在下文中一共展示了ToolRunner.argIf方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: run

async function run() {
    try {
        tl.setResourcePath(path.join( __dirname, 'task.json'));

        //--------------------------------------------------------
        // Tooling
        //--------------------------------------------------------
        tl.setEnvVar('DEVELOPER_DIR', tl.getInput('xcodeDeveloperDir', false));

        var useXctool : boolean = tl.getBoolInput('useXctool', false);
        var tool : string = useXctool ? tl.which('xctool', true) : tl.which('xcodebuild', true);
        tl.debug('Tool selected: '+ tool);

        //--------------------------------------------------------
        // Paths
        //--------------------------------------------------------
        var workingDir : string = tl.getPathInput('cwd');
        tl.cd(workingDir);

        var outPath : string = tl.resolve(workingDir, tl.getInput('outputPattern', true)); //use posix implementation to resolve paths to prevent unit test failures on Windows
        tl.mkdirP(outPath);

        //--------------------------------------------------------
        // Xcode args
        //--------------------------------------------------------
        var ws : string = tl.getPathInput('xcWorkspacePath', false, false);
        if(tl.filePathSupplied('xcWorkspacePath')) {
            var workspaceMatches = tl.glob(ws);
            tl.debug("Found " + workspaceMatches.length + ' workspaces matching.');

            if (workspaceMatches.length > 0) {
                ws = workspaceMatches[0];
                if (workspaceMatches.length > 1) {
                    tl.warning(tl.loc('MultipleWorkspacesFound', ws));
                }
            }
            else {
                throw tl.loc('WorkspaceDoesNotExist');
            }
        }

        var sdk : string = tl.getInput('sdk', false);
        var configuration : string  = tl.getInput('configuration', false);
        var scheme : string = tl.getInput('scheme', false);
        var useXcpretty : boolean = tl.getBoolInput('useXcpretty', false);
        var xctoolReporter : string = tl.getInput('xctoolReporter', false);
        var actions : string [] = tl.getDelimitedInput('actions', ' ', true);
        var packageApp : boolean = tl.getBoolInput('packageApp', true);
        var args : string = tl.getInput('args', false);

        //--------------------------------------------------------
        // Exec Tools
        //--------------------------------------------------------

        // --- Xcode Version ---
        var xcv : ToolRunner = tl.tool(tool);
        xcv.arg('-version');
        await xcv.exec();

        // --- Xcode build arguments ---
        var xcb: ToolRunner = tl.tool(tool);
        xcb.argIf(sdk, ['-sdk', sdk]);
        xcb.argIf(configuration, ['-configuration', configuration]);
        if(ws && tl.filePathSupplied('xcWorkspacePath')) {
            xcb.arg('-workspace');
            xcb.arg(ws);
        }
        xcb.argIf(scheme, ['-scheme', scheme]);
        xcb.argIf(useXctool && xctoolReporter, ['-reporter', 'plain', '-reporter', xctoolReporter]);
        xcb.arg(actions);
        xcb.arg('DSTROOT=' + path.join(outPath, 'build.dst'));
        xcb.arg('OBJROOT=' + path.join(outPath, 'build.obj'));
        xcb.arg('SYMROOT=' + path.join(outPath, 'build.sym'));
        xcb.arg('SHARED_PRECOMPS_DIR=' + path.join(outPath, 'build.pch'));
        if (args) {
            xcb.line(args);
        }

        //--------------------------------------------------------
        // iOS signing and provisioning
        //--------------------------------------------------------
        var signMethod : string = tl.getInput('signMethod', false);
        var keychainToDelete : string;
        var profileToDelete : string;

        if(signMethod === 'file') {
            var p12 : string = tl.getPathInput('p12', false, false);
            var p12pwd : string = tl.getInput('p12pwd', false);
            var provProfilePath : string = tl.getPathInput('provProfile', false);
            var removeProfile : boolean = tl.getBoolInput('removeProfile', false);

            if(tl.filePathSupplied('p12') && tl.exist(p12)) {
                p12 = tl.resolve(workingDir, p12);
                var keychain : string = path.join(workingDir, '_xcodetasktmp.keychain');
                var keychainPwd : string = '_xcodetask_TmpKeychain_Pwd#1';

                //create a temporary keychain and install the p12 into that keychain
                await sign.installCertInTemporaryKeychain(keychain, keychainPwd, p12, p12pwd);
                xcb.arg('OTHER_CODE_SIGN_FLAGS=--keychain=' + keychain);
                keychainToDelete = keychain;
//.........这里部分代码省略.........
开发者ID:HSAR,项目名称:vso-agent-tasks,代码行数:101,代码来源:xcode.ts

示例2: run

async function run() {

    let codesignKeychain: string;
    let profileToDelete: string;

    try {
        tl.setResourcePath(path.join(__dirname, 'task.json'));

        // Get build inputs
        let solutionPath: string = tl.getPathInput('solution', true, true);
        let configuration: string = tl.getInput('configuration', true);
        let clean: boolean = tl.getBoolInput('clean');
        let args: string = tl.getInput('args');
        let packageApp: boolean = tl.getBoolInput('packageApp');
        let buildForSimulator: boolean = tl.getBoolInput('forSimulator');
        let device: string = (buildForSimulator) ? 'iPhoneSimulator' : 'iPhone';
        tl.debug('device: ' + device);
        let cwd: string = tl.getInput('cwd');
        let runNugetRestore: boolean = tl.getBoolInput('runNugetRestore');

        // find the build tool path based on the build tool and location inputs
        let buildTool: string = tl.getInput('buildTool');
        let buildToolLocation: string = tl.getInput('mdtoolLocation', false);
        let buildToolPath: string;
        if (buildToolLocation) {
            // location is specified
            buildToolPath = buildToolLocation;
            if (buildTool === 'xbuild' && !buildToolLocation.toLowerCase().endsWith('xbuild')) {
                buildToolPath = path.join(buildToolLocation, 'xbuild');
            }
            if (buildTool === 'msbuild' && !buildToolLocation.toLowerCase().endsWith('msbuild')) {
                buildToolPath = path.join(buildToolLocation, 'msbuild');
            }
        } else {
            // no build tool path is supplied, check PATH
            if (buildTool === 'msbuild') {
                // check for msbuild 15 or higher, if not fall back to xbuild
                buildToolPath = await msbuildhelpers.getMSBuildPath('15.0');
            } else {
                buildToolPath = tl.which('xbuild', true);
            }
        }
        tl.checkPath(buildToolPath, 'build tool');
        tl.debug('Build tool path = ' + buildToolPath);

        if (clean) {
            let cleanBuildRunner: ToolRunner = tl.tool(buildToolPath);
            cleanBuildRunner.arg(solutionPath);
            cleanBuildRunner.argIf(configuration, '/p:Configuration=' + configuration);
            cleanBuildRunner.argIf(device, '/p:Platform=' + device);
            cleanBuildRunner.arg('/t:Clean');
            await cleanBuildRunner.exec();
        }

        if (runNugetRestore) {
            // Find location of nuget
            let nugetPath: string = tl.which('nuget', true);

            // Restore NuGet packages of the solution
            let nugetRunner: ToolRunner = tl.tool(nugetPath);
            nugetRunner.arg(['restore', solutionPath]);
            await nugetRunner.exec();
        }

        //Process working directory
        let workingDir: string = cwd || tl.getVariable('System.DefaultWorkingDirectory');
        tl.cd(workingDir);

        let signMethod: string = tl.getInput('signMethod', false);
        let provProfileUUID: string = null;
        let signIdentity: string = null;

        if (signMethod === 'file') {
            let p12: string = tl.getPathInput('p12', false, false);
            let p12pwd: string = tl.getInput('p12pwd', false);
            let provProfilePath: string = tl.getPathInput('provProfile', false);
            let removeProfile: boolean = tl.getBoolInput('removeProfile', false);

            if (tl.filePathSupplied('p12') && tl.exist(p12)) {
                p12 = tl.resolve(cwd, p12);
                tl.debug('cwd = ' + cwd);
                let keychain: string = tl.resolve(cwd, '_xamariniostasktmp.keychain');
                let keychainPwd: string = '_xamariniostask_TmpKeychain_Pwd#1';

                //create a temporary keychain and install the p12 into that keychain
                tl.debug('installing cert in temp keychain');
                await sign.installCertInTemporaryKeychain(keychain, keychainPwd, p12, p12pwd, false);
                codesignKeychain = keychain;

                //find signing identity
                signIdentity = await sign.findSigningIdentity(keychain);
            }

            //determine the provisioning profile UUID
            if (tl.filePathSupplied('provProfile') && tl.exist(provProfilePath)) {
                provProfileUUID = await sign.getProvisioningProfileUUID(provProfilePath);

                if (removeProfile && provProfileUUID) {
                    profileToDelete = provProfileUUID;
                }
//.........这里部分代码省略.........
开发者ID:colindembovsky,项目名称:vsts-tasks,代码行数:101,代码来源:xamarinios.ts

示例3: run

async function run() {
    try {
        tl.setResourcePath(path.join(__dirname, 'task.json'));

        //read inputs
        let solution: string = tl.getPathInput('solution', true, false);
        let platform: string = tl.getInput('platform');
        let configuration: string = tl.getInput('configuration');
        let msbuildArguments: string = tl.getInput('msbuildArguments');
        let clean: boolean = tl.getBoolInput('clean');

        let logsolutionEvents: boolean = tl.getBoolInput('logsolutionEvents');
        if (logsolutionEvents) {
            tl.warning(tl.loc('RecordProjectDetailsOnlySupportedOnWindows'));
        }

        let createLogFile: boolean = tl.getBoolInput('createLogFile');
        if (createLogFile) {
            tl.warning(tl.loc('CreateLogFileOnlySupportedOnWindows'));
        }

        let msbuildLocationMethod: string = tl.getInput('msbuildLocationMethod');
        if (!msbuildLocationMethod) {
            msbuildLocationMethod = 'version';
        }

        let msbuildTool: string;
        if (msbuildLocationMethod === 'version') {
            let msbuildVersion: string = tl.getInput('msbuildVersion');
            msbuildTool = await msbuildHelpers.getMSBuildPath(msbuildVersion);
        }
        if (msbuildLocationMethod === 'location') {
            msbuildTool = tl.getInput('msbuildLocation');
        } 

        let filesList: string[] = tl.findMatch(null, solution, { followSymbolicLinks: false, followSpecifiedSymbolicLink: false }, { matchBase: true });
        for (let file of filesList) {
            if (clean) {
                let cleanTool: ToolRunner = tl.tool(msbuildTool);
                cleanTool.arg(file);
                cleanTool.argIf(clean, '/t:Clean');
                cleanTool.argIf(platform, '/p:Platform=' + platform);
                cleanTool.argIf(configuration, '/p:Configuration=' + configuration);
                if (msbuildArguments) {
                    cleanTool.line(msbuildArguments);
                }
                await cleanTool.exec();
            }

            let buildTool: ToolRunner = tl.tool(msbuildTool);
            buildTool.arg(file);
            buildTool.argIf(platform, '/p:Platform=' + platform);
            buildTool.argIf(configuration, '/p:Configuration=' + configuration);
            if (msbuildArguments) {
                buildTool.line(msbuildArguments);
            }
            await buildTool.exec();
        }
    } catch (err) {
        tl.setResult(tl.TaskResult.Failed, err);
    }
}
开发者ID:DarqueWarrior,项目名称:vsts-tasks,代码行数:62,代码来源:msbuild.ts

示例4: run

async function run() {
    try {
        tl.setResourcePath(path.join(__dirname, 'task.json'));

        //read inputs
        const project: string | null = tl.getPathInput('project', true);
        const target: string | null = tl.getInput('target');
        const outputDir: string | null = tl.getInput('outputDir');
        const configuration: string | null = tl.getInput('configuration');
        const createAppPackage: boolean | null = tl.getBoolInput('createAppPackage');
        const clean: boolean | null = tl.getBoolInput('clean');
        const msbuildArguments: string| null = tl.getInput('msbuildArguments');

        // find jdk to be used during the build
        const jdkSelection: string = tl.getInput('jdkSelection') || 'JDKVersion'; // fall back to JDKVersion for older version of tasks

        let specifiedJavaHome: string | null | undefined = null;
        let javaTelemetryData: { jdkVersion: string } | null = null;

        if (jdkSelection === 'JDKVersion') {
            tl.debug('Using JDK version to find JDK path');
            const jdkVersion: string | null = tl.getInput('jdkVersion');
            const jdkArchitecture: string | null = tl.getInput('jdkArchitecture');
            javaTelemetryData = { jdkVersion };

            if (jdkVersion !== 'default') {
                specifiedJavaHome = javacommons.findJavaHome(jdkVersion, jdkArchitecture);
            }
        } else {
            tl.debug('Using path from user input to find JDK');
            specifiedJavaHome = tl.getPathInput('jdkUserInputPath', true, true);
            javaTelemetryData = { jdkVersion: "custom" };
        }
        javacommons.publishJavaTelemetry('XamarinAndroid', javaTelemetryData);

        //find build tool path to use
        let buildToolPath: string | undefined;

        const buildLocationMethod: string = tl.getInput('msbuildLocationMethod') || 'version';

        const buildToolLocation: string | null = tl.getPathInput('msbuildLocation');
        if (buildToolLocation) {
            // msbuildLocation was specified, use it for back compat
            if (buildToolLocation.endsWith('xbuild') || buildToolLocation.endsWith('msbuild')) {
                buildToolPath = buildToolLocation;
            } else {
                // use xbuild for back compat if tool folder path is specified
                buildToolPath = path.join(buildToolLocation, 'xbuild');
            }
            tl.checkPath(buildToolPath, 'build tool');
        } else if (buildLocationMethod === 'version') {
            // msbuildLocation was not specified, look up by version
            const msbuildVersion: string = tl.getInput('msbuildVersion');
            buildToolPath = await msbuildHelpers.getMSBuildPath(msbuildVersion);
        }

        if (!buildToolPath) {
            throw tl.loc('MSB_BuildToolNotFound');
        }
        tl.debug('Build tool path = ' + buildToolPath);

        // Resolve files for the specified value or pattern
        const filesList: string[] = tl.findMatch('', project, { followSymbolicLinks: false, followSpecifiedSymbolicLink: false });

        // Fail if no matching .csproj files were found
        if (!filesList || filesList.length === 0) {
            throw tl.loc('NoMatchingProjects', project);
        }

        for (const file of filesList) {
            try {
                // run the build for each matching project
                const buildRunner: ToolRunner = tl.tool(buildToolPath);
                buildRunner.arg(file);
                buildRunner.argIf(clean, '/t:Clean');
                buildRunner.argIf(target, '/t:' + target);
                buildRunner.argIf(createAppPackage, '/t:PackageForAndroid');
                if (msbuildArguments) {
                    buildRunner.line(msbuildArguments);
                }
                buildRunner.argIf(outputDir, '/p:OutputPath=' + outputDir);
                buildRunner.argIf(configuration, '/p:Configuration=' + configuration);
                buildRunner.argIf(specifiedJavaHome, '/p:JavaSdkDirectory=' + specifiedJavaHome);

                await buildRunner.exec();
            } catch (err) {
                throw tl.loc('XamarinAndroidBuildFailed', err);
            }
            tl.setResult(tl.TaskResult.Succeeded, tl.loc('XamarinAndroidSucceeded'));
        }
    } catch (err) {
        tl.setResult(tl.TaskResult.Failed, err);
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:94,代码来源:xamarinandroid.ts

示例5: run

async function run() {
    try {
        tl.setResourcePath(path.join(__dirname, 'task.json'));

        //--------------------------------------------------------
        // Tooling
        //--------------------------------------------------------
        var devDir = tl.getInput('xcodeDeveloperDir', false);
        if (devDir) {
            tl.setVariable('DEVELOPER_DIR', devDir);
        }

        var useXctool: boolean = tl.getBoolInput('useXctool', false);
        var tool: string = useXctool ? tl.which('xctool', true) : tl.which('xcodebuild', true);
        tl.debug('Tool selected: ' + tool);

        //--------------------------------------------------------
        // Paths
        //--------------------------------------------------------
        var workingDir: string = tl.getPathInput('cwd');
        tl.cd(workingDir);

        var outPath: string = tl.resolve(workingDir, tl.getInput('outputPattern', true)); //use posix implementation to resolve paths to prevent unit test failures on Windows
        tl.mkdirP(outPath);

        //--------------------------------------------------------
        // Xcode args
        //--------------------------------------------------------
        var ws: string = tl.getPathInput('xcWorkspacePath', false, false);
        if (tl.filePathSupplied('xcWorkspacePath')) {
            var workspaceMatches = tl.findMatch(workingDir, ws, { followSymbolicLinks: false, followSpecifiedSymbolicLink: false });
            tl.debug("Found " + workspaceMatches.length + ' workspaces matching.');

            if (workspaceMatches.length > 0) {
                ws = workspaceMatches[0];
                if (workspaceMatches.length > 1) {
                    tl.warning(tl.loc('MultipleWorkspacesFound', ws));
                }
            }
            else {
                throw tl.loc('WorkspaceDoesNotExist', ws);
            }
        }

        var isProject = false;
        if (ws && ws.trim().toLowerCase().endsWith('.xcodeproj')) {
            isProject = true;
        }

        var sdk: string = tl.getInput('sdk', false);
        var configuration: string = tl.getInput('configuration', false);
        var scheme: string = tl.getInput('scheme', false);
        var useXcpretty: boolean = tl.getBoolInput('useXcpretty', false);
        var xctoolReporter: string = tl.getInput('xctoolReporter', false);
        var actions: string[] = tl.getDelimitedInput('actions', ' ', true);
        var packageApp: boolean = tl.getBoolInput('packageApp', true);
        var args: string = tl.getInput('args', false);

        //--------------------------------------------------------
        // Exec Tools
        //--------------------------------------------------------

        // --- Xcode Version ---
        var xcv: ToolRunner = tl.tool(tool);
        xcv.arg('-version');
        var xcodeVersion: number = 0;
        xcv.on('stdout', (data) => {
            var match = data.toString().trim().match(/Xcode (.+)/g);
            tl.debug('match = ' + match);
            if (match) {
                var version: number = parseInt(match.toString().replace('Xcode', '').trim());
                tl.debug('version = ' + version);
                if (!isNaN(version)) {
                    xcodeVersion = version;
                }
            }
        });

        await xcv.exec();
        tl.debug('xcodeVersion = ' + xcodeVersion);

        // --- Xcode build arguments ---
        var xcb: ToolRunner = tl.tool(tool);
        xcb.argIf(sdk, ['-sdk', sdk]);
        xcb.argIf(configuration, ['-configuration', configuration]);
        if (ws && tl.filePathSupplied('xcWorkspacePath')) {
            xcb.argIf(isProject, '-project');
            xcb.argIf(!isProject, '-workspace');
            xcb.arg(ws);
        }
        xcb.argIf(scheme, ['-scheme', scheme]);
        xcb.argIf(useXctool && xctoolReporter, ['-reporter', 'plain', '-reporter', xctoolReporter]);
        xcb.arg(actions);
        if (actions.toString().indexOf('archive') < 0) {
            // redirect build output if archive action is not passed
            // xcodebuild archive produces an invalid archive if output is redirected
            xcb.arg('DSTROOT=' + tl.resolve(outPath, 'build.dst'));
            xcb.arg('OBJROOT=' + tl.resolve(outPath, 'build.obj'));
            xcb.arg('SYMROOT=' + tl.resolve(outPath, 'build.sym'));
            xcb.arg('SHARED_PRECOMPS_DIR=' + tl.resolve(outPath, 'build.pch'));
//.........这里部分代码省略.........
开发者ID:DarqueWarrior,项目名称:vsts-tasks,代码行数:101,代码来源:xcode.ts

示例6: run


//.........这里部分代码省略.........

        let sdk: string = tl.getInput('sdk', false);
        let configuration: string = tl.getInput('configuration', false);
        let useXcpretty: boolean = tl.getBoolInput('useXcpretty', false);
        let actions: string[] = tl.getDelimitedInput('actions', ' ', true);
        let packageApp: boolean = tl.getBoolInput('packageApp', true);
        let args: string = tl.getInput('args', false);

        //--------------------------------------------------------
        // Exec Tools
        //--------------------------------------------------------

        // --- Xcode Version ---
        let xcv: ToolRunner = tl.tool(tool);
        xcv.arg('-version');
        let xcodeVersion: number = 0;
        xcv.on('stdout', (data) => {
            let match = data.toString().trim().match(/Xcode (.+)/g);
            tl.debug('match = ' + match);
            if (match) {
                let version: number = parseInt(match.toString().replace('Xcode', '').trim());
                tl.debug('version = ' + version);
                if (!isNaN(version)) {
                    xcodeVersion = version;
                }
            }
        });

        await xcv.exec();
        tl.debug('xcodeVersion = ' + xcodeVersion);

        // --- Xcode build arguments ---
        let xcb: ToolRunner = tl.tool(tool);
        xcb.argIf(sdk, ['-sdk', sdk]);
        xcb.argIf(configuration, ['-configuration', configuration]);
        if (ws && tl.filePathSupplied('xcWorkspacePath')) {
            xcb.argIf(isProject, '-project');
            xcb.argIf(!isProject, '-workspace');
            xcb.arg(ws);
        }
        xcb.argIf(scheme, ['-scheme', scheme]);
        // Add a -destination argument for each device and simulator.
        if (destinations) {
            destinations.forEach(destination => {
                xcb.arg(['-destination', destination]);
            });
        }
        xcb.arg(actions);
        if (args) {
            xcb.line(args);
        }

        //--------------------------------------------------------
        // iOS signing and provisioning
        //--------------------------------------------------------
        let signingOption: string = tl.getInput('signingOption', true);
        let keychainToDelete: string;
        let profileToDelete: string;
        let xcode_codeSigningAllowed: string;
        let xcode_codeSignStyle: string;
        let xcode_otherCodeSignFlags: string;
        let xcode_codeSignIdentity: string;
        let xcode_provProfile: string;
        let xcode_provProfileSpecifier: string;
        let xcode_devTeam: string;
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:66,代码来源:xcode.ts

示例7: run

async function run() {
    try {
        tl.setResourcePath(path.join(__dirname, 'task.json'));

        // Check platform is macOS since demands are not evaluated on Hosted pools
        if (os.platform() !== 'darwin') {
            throw new Error(tl.loc('BuildRequiresMac'));
        }
        
        // Get build inputs
        const solutionInput: string = tl.getPathInput('solution', true, false);
        const configuration: string = tl.getInput('configuration', true);
        const clean: boolean = tl.getBoolInput('clean');
        const args: string = tl.getInput('args');
        const packageApp: boolean = tl.getBoolInput('packageApp');
        const buildForSimulator: boolean = tl.getBoolInput('forSimulator');
        const device: string = (buildForSimulator) ? 'iPhoneSimulator' : 'iPhone';
        tl.debug('device: ' + device);
        const cwd: string = tl.getPathInput('cwd', false, true);
        const runNugetRestore: boolean = tl.getBoolInput('runNugetRestore');

        // find the build tool path based on the build tool and location inputs
        const buildToolLocation: string = tl.getInput('buildToolLocation', false);
        let buildToolPath: string;
        if (buildToolLocation) {
            buildToolPath = buildToolLocation;
        } else {
            // no build tool path is supplied, check PATH
            // check for msbuild 15 or higher, if not fall back to xbuild
            buildToolPath = await msbuildhelpers.getMSBuildPath('latest');
        }
        tl.checkPath(buildToolPath, 'build tool');
        tl.debug('Build tool path = ' + buildToolPath);

        const solutionPath = expandSolutionWildcardPatterns(solutionInput);

        if (clean) {
            const cleanBuildRunner: ToolRunner = tl.tool(buildToolPath);
            cleanBuildRunner.arg(solutionPath);
            cleanBuildRunner.argIf(configuration, '/p:Configuration=' + configuration);
            cleanBuildRunner.argIf(device, '/p:Platform=' + device);
            if (args) {
                cleanBuildRunner.line(args);
            }
            cleanBuildRunner.arg('/t:Clean');
            await cleanBuildRunner.exec();
        }

        if (runNugetRestore) {
            // Find location of nuget
            const nugetPath: string = tl.which('nuget', true);

            // Restore NuGet packages of the solution
            const nugetRunner: ToolRunner = tl.tool(nugetPath);
            nugetRunner.arg(['restore', solutionPath]);
            await nugetRunner.exec();
        }

        //Process working directory
        const workingDir: string = cwd || tl.getVariable('System.DefaultWorkingDirectory');
        tl.cd(workingDir);

        const provProfileUUID: string = tl.getInput('provProfileUuid');
        const signIdentity: string = tl.getInput('iosSigningIdentity');

        // Prepare build command line
        const buildRunner: ToolRunner = tl.tool(buildToolPath);
        buildRunner.arg(solutionPath);
        buildRunner.argIf(configuration, '/p:Configuration=' + configuration);
        buildRunner.argIf(device, '/p:Platform=' + device);
        buildRunner.argIf(packageApp, '/p:BuildIpa=true');
        if (args) {
            buildRunner.line(args);
        }
        if (signIdentity && signIdentity.indexOf(',') > 0) {
            // Escape the input to workaround msbuild bug https://github.com/Microsoft/msbuild/issues/471
            tl.debug('Escaping , in arg /p:Codesignkey to workaround msbuild bug.');
            const signIdentityEscaped = signIdentity.replace(/[,]/g, '%2C');
            buildRunner.arg('/p:Codesignkey=' + signIdentityEscaped);
        } else {
            tl.debug('Passing in arg /p:Codesignkey as is without escpaing any characters.')
            buildRunner.argIf(signIdentity, '/p:Codesignkey=' + signIdentity);
        }
        buildRunner.argIf(provProfileUUID, '/p:CodesignProvision=' + provProfileUUID);

        // Execute build
        await buildRunner.exec();

        tl.setResult(tl.TaskResult.Succeeded, tl.loc('XamariniOSSucceeded'));

    } catch (err) {
        tl.setResult(tl.TaskResult.Failed, tl.loc('XamariniOSFailed', err));
    } 
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:94,代码来源:xamarinios.ts

示例8: run

async function run() {
    try {
        tl.setResourcePath(path.join(__dirname, 'task.json'));

        //read inputs
        let project: string = tl.getPathInput('project', true);
        let target: string = tl.getInput('target');
        let outputDir: string = tl.getInput('outputDir');
        let configuration: string = tl.getInput('configuration');
        let createAppPackage: boolean = tl.getBoolInput('createAppPackage');
        let clean: boolean = tl.getBoolInput('clean');
        let msbuildArguments: string = tl.getInput('msbuildArguments');

        // find jdk to be used during the build
        let jdkSelection: string = tl.getInput('jdkSelection');
        if (!jdkSelection) {
            jdkSelection = 'JDKVersion'; //fallback to JDKVersion for older version of tasks
        }
        let specifiedJavaHome = null;

        if (jdkSelection === 'JDKVersion') {
            tl.debug('Using JDK version to find JDK path');
            let jdkVersion: string = tl.getInput('jdkVersion');
            let jdkArchitecture: string = tl.getInput('jdkArchitecture');

            if (jdkVersion !== 'default') {
                // jdkVersion should be in the form of 1.7, 1.8, or 1.10
                // jdkArchitecture is either x64 or x86
                // envName for version 1.7 and x64 would be "JAVA_HOME_7_X64"
                let envName: string = "JAVA_HOME_" + jdkVersion.slice(2) + "_" + jdkArchitecture.toUpperCase();
                specifiedJavaHome = tl.getVariable(envName);
                if (!specifiedJavaHome) {
                    throw tl.loc('JDKNotFound', envName);
                }
            }
        }
        else {
            tl.debug('Using path from user input to find JDK');
            let jdkUserInputPath: string = tl.getPathInput('jdkUserInputPath', true, true);
            specifiedJavaHome = jdkUserInputPath;
        }

        //find build tool path to use
        let buildToolPath: string;

        let buildLocationMethod: string = tl.getInput('msbuildLocationMethod');
        if (!buildLocationMethod) {
            buildLocationMethod = 'version';
        }

        let buildToolLocation: string = tl.getPathInput('msbuildLocation');
        if (buildToolLocation) {
            // msbuildLocation was specified, use it for back compat
            if (buildToolLocation.endsWith('xbuild') || buildToolLocation.endsWith('msbuild')) {
                buildToolPath = buildToolLocation;
            } else {
                // use xbuild for back compat if tool folder path is specified
                buildToolPath = path.join(buildToolLocation, 'xbuild');
            }
            tl.checkPath(buildToolPath, 'build tool');
        } else if (buildLocationMethod === 'version') {
            // msbuildLocation was not specified, look up by version
            let msbuildVersion: string = tl.getInput('msbuildVersion');
            buildToolPath = await msbuildHelpers.getMSBuildPath(msbuildVersion);
        }

        if (!buildToolPath) {
            throw tl.loc('MSB_BuildToolNotFound');
        }
        tl.debug('Build tool path = ' + buildToolPath);

        // Resolve files for the specified value or pattern
        let filesList: string[] = tl.findMatch(null, project, { followSymbolicLinks: false, followSpecifiedSymbolicLink: false });

        // Fail if no matching .csproj files were found
        if (!filesList || filesList.length === 0) {
            throw tl.loc('NoMatchingProjects', project);
        }

        for (let file of filesList) {
            try {
                // run the build for each matching project
                let buildRunner: ToolRunner = tl.tool(buildToolPath);
                buildRunner.arg(file);
                buildRunner.argIf(clean, '/t:Clean');
                buildRunner.argIf(target, '/t:' + target);
                buildRunner.argIf(createAppPackage, '/t:PackageForAndroid');
                if (msbuildArguments) {
                    buildRunner.line(msbuildArguments);
                }
                buildRunner.argIf(outputDir, '/p:OutputPath=' + outputDir);
                buildRunner.argIf(configuration, '/p:Configuration=' + configuration);
                buildRunner.argIf(specifiedJavaHome, '/p:JavaSdkDirectory=' + specifiedJavaHome);

                await buildRunner.exec();
            } catch (err) {
                throw tl.loc('XamarinAndroidBuildFailed', err);
            }
            tl.setResult(tl.TaskResult.Succeeded, tl.loc('XamarinAndroidSucceeded'));
        }
//.........这里部分代码省略.........
开发者ID:DarqueWarrior,项目名称:vsts-tasks,代码行数:101,代码来源:xamarinandroid.ts


注:本文中的vsts-task-lib/toolrunner.ToolRunner.argIf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。