private static DeployAgentResult DeployFailingPowerShellScript() { using (var scriptFile = new TemporaryFile(".ps1", PowerShellScripts.FailingPowerShellScript)) { var testDeployData = new DeployAgentData { NewQuality = "Released", OriginalQuality = null, DeployScriptFile = scriptFile.FileInfo.Name, DeployScriptRoot = scriptFile.FileInfo.DirectoryName, DeployScriptParameters = new List <DeployScriptParameter>(), TfsBuildDetail = new BuildDetail() }; var psAgent = new LocalPowerShellDeployAgent(); return(psAgent.Deploy(testDeployData)); } }
public void Should_include_written_text_in_output() { using (var scriptFile = TemporaryFile.FromResource(".ps1", "Tests.TfsDeployer.PowerShellRunnerTests.WriteHostScript.ps1")) { var testDeployData = new DeployAgentData { NewQuality = "Released", OriginalQuality = null, DeployScriptFile = scriptFile.FileInfo.Name, DeployScriptRoot = scriptFile.FileInfo.DirectoryName, DeployScriptParameters = new List<DeployScriptParameter>(), TfsBuildDetail = new BuildDetail() }; var psAgent = new LocalPowerShellDeployAgent(); var result = psAgent.Deploy(testDeployData); Assert.AreEqual("Hello world\n", result.Output); } }
private void ApplyInternetZoneIdentifier(string fileName) { //TODO find a way to utilise the IZoneIdentifier interface from managed code // http://msdn.microsoft.com/en-us/library/ms537032(VS.85).aspx using (var applyScript = new TemporaryFile(".cmd", PowerShellScripts.ApplyInternetZoneIdentifier)) { var processTimeout = (int)new TimeSpan(0, 0, 15).TotalMilliseconds; var startInfo = new ProcessStartInfo(applyScript.FileInfo.FullName, fileName); startInfo.CreateNoWindow = true; startInfo.UseShellExecute = false; var process = Process.Start(startInfo); if (!process.WaitForExit(processTimeout)) { throw new TimeoutException("Process exceeded execution time limit."); } if (process.ExitCode != 0) { throw new ApplicationException("Processed returned non-zero exit code."); } } }