本文整理汇总了C#中Instance.GeneratePublishSettings方法的典型用法代码示例。如果您正苦于以下问题:C# Instance.GeneratePublishSettings方法的具体用法?C# Instance.GeneratePublishSettings怎么用?C# Instance.GeneratePublishSettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Instance
的用法示例。
在下文中一共展示了Instance.GeneratePublishSettings方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PublishProjectAsync
/// <summary>
/// Publishes an ASP.NET 4.x project to the given GCE <seealso cref="Instance"/>.
/// </summary>
/// <param name="projectPath">The full path to the project file.</param>
/// <param name="targetInstance">The instance to deploy.</param>
/// <param name="credentials">The Windows credentials to use to deploy to the <paramref name="targetInstance"/>.</param>
/// <param name="progress">The progress indicator.</param>
/// <param name="outputAction">The action to call with lines of output.</param>
/// <returns></returns>
public static async Task<bool> PublishProjectAsync(
string projectPath,
Instance targetInstance,
WindowsInstanceCredentials credentials,
IProgress<double> progress,
Action<string> outputAction)
{
var stagingDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
Directory.CreateDirectory(stagingDirectory);
progress.Report(0.1);
var publishSettingsPath = Path.GetTempFileName();
var publishSettingsContent = targetInstance.GeneratePublishSettings(credentials.User, credentials.Password);
File.WriteAllText(publishSettingsPath, publishSettingsContent);
using (var cleanup = new Disposable(() => Cleanup(publishSettingsPath, stagingDirectory)))
{
// Wait for the bundle operation to finish and update the progress in the mean time to show progress.
if (!await ProgressHelper.UpdateProgress(
CreateAppBundleAsync(projectPath, stagingDirectory, outputAction),
progress,
from: 0.1, to: 0.5))
{
return false;
}
progress.Report(0.6);
// Update for the deploy operation to finish and update the progress as it goes.
if (!await ProgressHelper.UpdateProgress(
DeployAppAsync(stagingDirectory, publishSettingsPath, outputAction),
progress,
from: 0.6, to: 0.9))
{
return false;
}
progress.Report(1);
}
return true;
}