本文整理汇总了C#中System.Diagnostics.ProcessStartInfo.StartAndWaitForExit方法的典型用法代码示例。如果您正苦于以下问题:C# ProcessStartInfo.StartAndWaitForExit方法的具体用法?C# ProcessStartInfo.StartAndWaitForExit怎么用?C# ProcessStartInfo.StartAndWaitForExit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.ProcessStartInfo
的用法示例。
在下文中一共展示了ProcessStartInfo.StartAndWaitForExit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoExecute
protected override bool DoExecute()
{
if (!base.DoExecute())
return false;
if (!File.Exists(PackagePath))
{
LogError($"Provided path {PackagePath} is invalid. File does not exist.");
return false;
}
string arguments = "push";
if (!string.IsNullOrWhiteSpace(Source))
arguments += $" -source {Source}";
arguments += $" \"{PackagePath}\"";
if (!string.IsNullOrWhiteSpace(ApiKey))
arguments += $" {ApiKey}";
var psi = new ProcessStartInfo(NuGetExePath);
psi.Arguments = arguments;
LogInformation($"Executing: \"{NuGetExePath}\" {psi.Arguments}");
var std_output = string.Empty;
var std_err = string.Empty;
var exit_code = -1;
if(psi.StartAndWaitForExit(TimeSpan.FromMilliseconds(TimeOut), out exit_code, out std_output, out std_err) && std_err.IsNullOrEmpty())
{
LogInformation($"NuGet Push complete.");
LogVerbose("NuGet Output: " + std_output);
return true;
}
else
{
LogError($"NuGet Push failed with exit code {exit_code}, {std_err}");
return false;
}
}
示例2: DoExecute
protected override bool DoExecute()
{
if (!base.DoExecute())
return false;
if (!File.Exists(SolutionPath))
{
LogError($"Provided path {SolutionPath} is invalid. File does not exist.");
return false;
}
string arguments = "restore";
arguments += $" \"{SolutionPath}\"";
if (!Source.IsNullOrEmpty())
arguments += $" -source \"{Source}\"";
if (!MSBuildVersion.IsNullOrEmpty())
arguments += $" -MSBuildVersion {MSBuildVersion}";
var psi = new ProcessStartInfo(NuGetExePath);
psi.Arguments = arguments;
LogInformation($"Executing: \"{NuGetExePath}\" {psi.Arguments}");
var std_output = string.Empty;
var std_err = string.Empty;
var exit_code = -1;
if (psi.StartAndWaitForExit(TimeSpan.FromMilliseconds(TimeOut), out exit_code, out std_output, out std_err) && std_err.IsNullOrEmpty())
{
LogInformation($"NuGet Restore complete.");
LogVerbose("NuGet Output: " + std_output);
return true;
}
else
{
LogError($"NuGet Restore failed with exit code {exit_code}, {std_err}");
return false;
}
}