Пример #1
0
        private string PrepareImportGlobalVariablesScript(DeployAgentData deployAgentData)
        {
            const int    serializationDepth = 5;
            const string clixmlFile         = "TfsDeployer.variables.clixml";
            const string scriptTemplate     = "(Import-Clixml -Path {0}).GetEnumerator() | ForEach-Object {{ Set-Variable -Name $_.Key -Value $_.Value -Scope global }};";

            var globalVariables = LocalPowerShellDeployAgent.CreateCommonVariables(deployAgentData);

            if (deployAgentData.DeployScriptParameters != null)
            {
                foreach (var deployParam in deployAgentData.DeployScriptParameters)
                {
                    globalVariables[deployParam.Name] = deployParam.Value;
                }
            }

            using (var shell = PowerShell.Create())
            {
                var clixmlPath = Path.Combine(deployAgentData.DeployScriptRoot, clixmlFile);
                shell.AddCommand("Export-Clixml").AddParameter("Depth", serializationDepth).AddParameter("Path", clixmlPath);
                shell.Invoke(new[] { globalVariables });
            }

            return(String.Format(scriptTemplate, clixmlFile));
        }
Пример #2
0
        public IDeployAgent GetDeployAgent(Mapping mapping)
        {
            if (string.IsNullOrEmpty(mapping.Script))
            {
                return(null);
            }

            IDeployAgent agent;

            if (mapping.RunnerType == RunnerType.BatchFile)
            {
                agent = new BatchFileDeployAgent();
            }
            else
            {
                agent = new LocalPowerShellDeployAgent();
            }
            return(agent);
        }
Пример #3
0
        public IDeployAgent GetDeployAgent(Mapping mapping)
        {
            IDeployAgent agent;

            if (mapping.RunnerType == RunnerType.BatchFile)
            {
                agent = new BatchFileDeployAgent();
            }
            else
            {
                var powerShellDeployAgent = new LocalPowerShellDeployAgent();
                if (Settings.Default.IgnoreSystemPowerShellExecutionPolicy)
                {
                    powerShellDeployAgent.ExecutionPolicyBehaviour = PowerShellExecutionPolicyBehaviour.Unrestricted;
                }
                agent = powerShellDeployAgent;
            }
            return(agent);
        }