本文整理汇总了C#中Kudu.Core.Deployment.DeploymentContext类的典型用法代码示例。如果您正苦于以下问题:C# DeploymentContext类的具体用法?C# DeploymentContext怎么用?C# DeploymentContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeploymentContext类属于Kudu.Core.Deployment命名空间,在下文中一共展示了DeploymentContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Build
public Task Build(DeploymentContext context)
{
var tcs = new TaskCompletionSource<object>();
ILogger innerLogger = context.Logger.Log(Resources.Log_PreparingFiles);
try
{
using (context.Tracer.Step("Copying files to output directory"))
{
// Copy to the output path and use the previous manifest if there
DeploymentHelper.CopyWithManifest(_sourcePath, context.OutputPath, context.PreviousMainfest);
}
using (context.Tracer.Step("Building manifest"))
{
// Generate a manifest from those build artifacts
context.ManifestWriter.AddFiles(_sourcePath);
}
// Log the copied files from the manifest
innerLogger.LogFileList(context.ManifestWriter.GetPaths());
}
catch (Exception ex)
{
context.Tracer.TraceError(ex);
context.GlobalLogger.Log(ex);
innerLogger.Log(ex);
tcs.SetException(ex);
// Bail out early
return tcs.Task;
}
try
{
// Download node packages
DownloadNodePackages(context);
AddIISNodeConfig(context);
tcs.SetResult(null);
}
catch (Exception ex)
{
context.Tracer.TraceError(ex);
// HACK: Log an empty error to the global logger (post receive hook console output).
// The reason we don't log the real exception is because the 'live output' when downloding
// npm packages has already been captured.
context.GlobalLogger.LogError();
tcs.SetException(ex);
}
return tcs.Task;
}
开发者ID:randome,项目名称:kudu,代码行数:60,代码来源:BasicBuilder.cs
示例2: Build
public override Task Build(DeploymentContext context)
{
ILogger buildLogger = context.Logger.Log(Resources.Log_BuildingSolution, Path.GetFileName(SolutionPath));
try
{
string propertyString = GetPropertyString();
if (!String.IsNullOrEmpty(propertyString))
{
propertyString = " /p:" + propertyString;
}
using (context.Tracer.Step("Running msbuild on solution"))
{
// Build the solution first
string log = ExecuteMSBuild(context.Tracer, @"""{0}"" /verbosity:m /nologo{1}", SolutionPath, propertyString);
buildLogger.Log(log);
}
return BuildProject(context);
}
catch (Exception ex)
{
context.Tracer.TraceError(ex);
buildLogger.Log(ex);
var tcs = new TaskCompletionSource<object>();
tcs.SetException(ex);
return tcs.Task;
}
}
开发者ID:loudej,项目名称:kudu,代码行数:34,代码来源:SolutionBasedSiteBuilder.cs
示例3: BuildProject
protected override Task BuildProject(DeploymentContext context)
{
var tcs = new TaskCompletionSource<object>();
var innerLogger = context.Logger.Log("Using website project {0}.", _projectPath);
try
{
using (context.Profiler.Step("Copying files to output directory"))
{
// Copy to the output path
DeploymentHelper.CopyWithManifest(_projectPath, context.OutputPath, context.PreviousMainfest);
}
using (context.Profiler.Step("Building manifest"))
{
// Generate the manifest from the project path
context.ManifestWriter.AddFiles(_projectPath);
}
innerLogger.Log("Done.");
tcs.SetResult(null);
}
catch (Exception e)
{
innerLogger.Log("Copying website failed.", LogEntryType.Error);
innerLogger.Log(e);
tcs.SetException(e);
}
return tcs.Task;
}
开发者ID:piscisaureus,项目名称:kudu,代码行数:31,代码来源:WebSiteBuilder.cs
示例4: BuildProject
protected override Task BuildProject(DeploymentContext context)
{
var tcs = new TaskCompletionSource<object>();
ILogger copyLogger = context.Logger.Log(Resources.Log_PreparingFiles);
try
{
using (context.Tracer.Step("Copying files to output directory"))
{
// Copy to the output path
DeploymentHelper.CopyWithManifest(_projectPath, context.OutputPath, context.PreviousMainfest);
}
using (context.Tracer.Step("Building manifest"))
{
// Generate the manifest from the project path
context.ManifestWriter.AddFiles(_projectPath);
}
// Log the copied files from the manifest
copyLogger.LogFileList(context.ManifestWriter.GetPaths());
tcs.SetResult(null);
}
catch (Exception ex)
{
context.Tracer.TraceError(ex);
copyLogger.Log(ex);
tcs.SetException(ex);
}
return tcs.Task;
}
开发者ID:chrisdias,项目名称:kudu,代码行数:35,代码来源:WebSiteBuilder.cs
示例5: DownloadNodePackages
/// <summary>
/// Download node packages as part of the deployment
/// </summary>
private void DownloadNodePackages(ILogger logger, DeploymentContext context)
{
// Check to see if there's a package.json file
string packagePath = Path.Combine(context.OutputPath, PackageJsonFile);
if (!File.Exists(packagePath))
{
// If the package.json file doesn't exist then don't bother to run npm install
return;
}
using (context.Profiler.Step("Downloading node packages"))
{
var npm = new NpmExecutable(context.OutputPath);
if (!npm.IsAvailable)
{
logger.Log("NPM not installed or couldn't be located. Skipping package installation.");
return;
}
// Set the npm proxy settings based on the default settings
var proxy = WebRequest.DefaultWebProxy;
var httpProxyUrl = proxy.GetProxy(new Uri("http://registry.npmjs.org/"));
var httpsProxyUrl = proxy.GetProxy(new Uri("https://registry.npmjs.org/"));
if (httpProxyUrl != null)
{
npm.EnvironmentVariables["HTTP_PROXY"] = httpProxyUrl.ToString();
}
if (httpsProxyUrl != null)
{
npm.EnvironmentVariables["HTTPS_PROXY"] = httpsProxyUrl.ToString();
}
// Use the temp path as the user profile path in case we don't have the right
// permission set. This normally happens under IIS as a restricted user (ApplicationPoolIdentity).
string npmUserProfile = Path.Combine(_tempPath, "npm");
npm.EnvironmentVariables["USERPROFILE"] = npmUserProfile;
npm.EnvironmentVariables["LocalAppData"] = npmUserProfile;
npm.EnvironmentVariables["AppData"] = npmUserProfile;
try
{
// Use the http proxy since https is failing for some reason
npm.Execute("config set registry \"http://registry.npmjs.org/\"");
}
catch(Exception ex)
{
// This fails if it's already set
Debug.WriteLine(ex.Message);
}
// Run install on the output directory
string log = npm.Execute(context.Profiler, "install").Item1;
logger.Log(log);
}
}
开发者ID:piscisaureus,项目名称:kudu,代码行数:62,代码来源:BasicBuilder.cs
示例6: DownloadNodePackages
/// <summary>
/// Download node packages as part of the deployment
/// </summary>
private void DownloadNodePackages(ILogger logger, DeploymentContext context)
{
// Check to see if there's a package.json file
string packagePath = Path.Combine(context.OutputPath, PackageJsonFile);
if (!File.Exists(packagePath))
{
// If the package.json file doesn't exist then don't bother to run npm install
return;
}
using (context.Profiler.Step("Downloading node packages"))
{
var npm = new NpmExecutable(context.OutputPath);
if (!npm.IsAvailable)
{
logger.Log(Resources.Log_NpmNotInstalled);
return;
}
// Set the npm proxy settings based on the default settings
var proxy = WebRequest.DefaultWebProxy;
var httpUrl = new Uri("http://registry.npmjs.org/");
var httpsUrl = new Uri("https://registry.npmjs.org/");
var proxyHttpProxyUrl = proxy.GetProxy(httpUrl);
var proxyHttpsProxyUrl = proxy.GetProxy(httpsUrl);
if (proxyHttpProxyUrl != httpUrl)
{
npm.EnvironmentVariables["HTTP_PROXY"] = proxyHttpProxyUrl.ToString();
}
if (proxyHttpsProxyUrl != httpsUrl)
{
npm.EnvironmentVariables["HTTPS_PROXY"] = proxyHttpsProxyUrl.ToString();
}
try
{
// Use the http proxy since https is failing for some reason
npm.Execute("config set registry \"http://registry.npmjs.org/\"");
}
catch (Exception ex)
{
// This fails if it's already set
Debug.WriteLine(ex.Message);
}
// Run install on the output directory
string log = npm.Execute(context.Profiler, "install").Item1;
logger.Log(log);
}
}
开发者ID:jimlamb,项目名称:kudu,代码行数:57,代码来源:BasicBuilder.cs
示例7: Build
public Task Build(DeploymentContext context)
{
var tcs = new TaskCompletionSource<object>();
ILogger innerLogger = context.Logger.Log(Resources.Log_CopyingFiles);
try
{
using (context.Tracer.Step("Copying files to output directory"))
{
// Copy to the output path and use the previous manifest if there
DeploymentHelper.CopyWithManifest(_sourcePath, context.OutputPath, context.PreviousMainfest);
}
using (context.Tracer.Step("Building manifest"))
{
// Generate a manifest from those build artifacts
context.ManifestWriter.AddFiles(_sourcePath);
}
// Log the copied files from the manifest
innerLogger.LogFileList(context.ManifestWriter.GetPaths());
}
catch (Exception ex)
{
context.Tracer.TraceError(ex);
innerLogger.Log(ex);
tcs.SetException(ex);
// Bail out early
return tcs.Task;
}
try
{
// Download node packages
DownloadNodePackages(context);
tcs.SetResult(null);
}
catch (Exception ex)
{
context.Tracer.TraceError(ex);
tcs.SetException(ex);
}
return tcs.Task;
}
开发者ID:loudej,项目名称:kudu,代码行数:51,代码来源:BasicBuilder.cs
示例8: Build
public Task Build(DeploymentContext context)
{
var tcs = new TaskCompletionSource<object>();
ILogger customLogger = context.Logger.Log("Running custom deployment...");
Executable exe = GetExecutable();
exe.EnvironmentVariables[SourcePath] = _repositoryPath;
exe.EnvironmentVariables[TargetPath] = context.OutputPath;
// Populate the enviornment with the build propeties
foreach (var property in _propertyProvider.GetProperties())
{
exe.EnvironmentVariables[property.Key] = property.Value;
}
// Add the msbuild path and git path to the %PATH% so more tools are available
var toolsPaths = new[] {
Path.GetDirectoryName(PathUtility.ResolveMSBuildPath()),
Path.GetDirectoryName(PathUtility.ResolveGitPath())
};
exe.AddToPath(toolsPaths);
try
{
string output = exe.ExecuteWithConsoleOutput(context.Tracer, String.Empty).Item1;
customLogger.Log(output);
tcs.SetResult(null);
}
catch (Exception ex)
{
context.Tracer.TraceError(ex);
// HACK: Log an empty error to the global logger (post receive hook console output).
// The reason we don't log the real exception is because the 'live output' running
// msbuild has already been captured.
context.GlobalLogger.LogError();
customLogger.Log(ex);
tcs.SetException(ex);
}
return tcs.Task;
}
开发者ID:vlad-c,项目名称:kudu,代码行数:48,代码来源:CustomBuilder.cs
示例9: HandleAutoSwap
public async Task HandleAutoSwap(string currentDeploymetId, DeploymentContext context)
{
ITracer tracer = context.Tracer;
if (!IsAutoSwapEnabled())
{
tracer.Trace("AutoSwap is not enabled");
return;
}
string jwtToken = System.Environment.GetEnvironmentVariable(Constants.SiteRestrictedJWT);
if (string.IsNullOrWhiteSpace(jwtToken))
{
tracer.Trace("Jwt token is null");
return;
}
// active deployment is always a success deployment
string lastDeploymentId = _deploymentStatusManager.ActiveDeploymentId;
if (string.Equals(currentDeploymetId, lastDeploymentId, StringComparison.OrdinalIgnoreCase))
{
tracer.Trace("Deployment haven't changed, no need for auto swap: {0}", lastDeploymentId);
return;
}
try
{
FileSystemHelpers.WriteAllTextToFile(_autoSwapLockFilePath, String.Empty);
}
catch (Exception ex)
{
tracer.TraceError(ex);
}
string operationId = "AUTOSWAP" + Guid.NewGuid();
var queryStrings = HttpUtility.ParseQueryString(string.Empty);
queryStrings["slot"] = _autoSwapSlotName;
queryStrings["operationId"] = operationId;
var client = new OperationClient(context.Tracer);
await client.PostAsync<string>("/operations/autoswap?" + queryStrings.ToString());
context.Logger.Log("Requesting auto swap to slot - '{0}' operation id - '{1}' deployment id - '{2}'".FormatInvariant(_autoSwapSlotName, operationId, currentDeploymetId));
}
开发者ID:WCOMAB,项目名称:kudu,代码行数:44,代码来源:AutoSwapHandler.cs
示例10: Build
public override Task Build(DeploymentContext context)
{
ILogger buildLogger = context.Logger.Log(Resources.Log_BuildingSolution, Path.GetFileName(SolutionPath));
try
{
string propertyString = GetPropertyString();
if (!String.IsNullOrEmpty(propertyString))
{
propertyString = " /p:" + propertyString;
}
string extraArguments = GetMSBuildExtraArguments();
using (context.Tracer.Step("Running msbuild on solution"))
{
// Build the solution first
string log = ExecuteMSBuild(context.Tracer, @"""{0}"" /verbosity:m /nologo{1} {2}", SolutionPath, propertyString, extraArguments);
buildLogger.Log(log);
}
return BuildProject(context);
}
catch (Exception ex)
{
context.Tracer.TraceError(ex);
// HACK: Log an empty error to the global logger (post receive hook console output).
// The reason we don't log the real exception is because the 'live output' running
// msbuild has already been captured.
context.GlobalLogger.Log(String.Empty, LogEntryType.Error);
buildLogger.Log(ex);
var tcs = new TaskCompletionSource<object>();
tcs.SetException(ex);
return tcs.Task;
}
}
开发者ID:dpvreony-forks,项目名称:kudu,代码行数:41,代码来源:SolutionBasedSiteBuilder.cs
示例11: Build
public override Task Build(DeploymentContext context)
{
var tcs = new TaskCompletionSource<object>();
var innerLogger = context.Logger.Log("Building web project {0}.", Path.GetFileName(_projectPath));
try
{
string buildTempPath = Path.Combine(_tempPath, "builds", Guid.NewGuid().ToString());
string log = null;
using (context.Profiler.Step("Running msbuild on project file"))
{
log = BuildProject(context.Profiler, buildTempPath);
}
using (context.Profiler.Step("Copying files to output directory"))
{
// Copy to the output path and use the previous manifest if there
DeploymentHelper.CopyWithManifest(buildTempPath, context.OutputPath, context.PreviousMainfest);
}
using (context.Profiler.Step("Building manifest"))
{
// Generate a manifest from those build artifacts
context.ManifestWriter.AddFiles(buildTempPath);
}
innerLogger.Log(log);
tcs.SetResult(null);
}
catch (Exception ex)
{
innerLogger.Log("Building web project failed.", LogEntryType.Error);
innerLogger.Log(ex);
tcs.SetException(ex);
}
return tcs.Task;
}
开发者ID:piscisaureus,项目名称:kudu,代码行数:40,代码来源:WapBuilder.cs
示例12: Build
public Task Build(DeploymentContext context)
{
var tcs = new TaskCompletionSource<object>();
var innerLogger = context.Logger.Log("Copying files.");
innerLogger.Log("Copying files to {0}.", context.OutputPath);
try
{
using (context.Profiler.Step("Copying files to output directory"))
{
// Copy to the output path and use the previous manifest if there
DeploymentHelper.CopyWithManifest(_sourcePath, context.OutputPath, context.PreviousMainfest);
}
// Download node packages
DownloadNodePackages(innerLogger, context);
using (context.Profiler.Step("Building manifest"))
{
// Generate a manifest from those build artifacts
context.ManifestWriter.AddFiles(_sourcePath);
}
innerLogger.Log("Done.");
tcs.SetResult(null);
}
catch (Exception ex)
{
innerLogger.Log("Copying files failed.");
innerLogger.Log(ex);
tcs.SetException(ex);
}
return tcs.Task;
}
开发者ID:piscisaureus,项目名称:kudu,代码行数:36,代码来源:BasicBuilder.cs
示例13: Build
/// <summary>
/// Builds and deploys a particular changeset. Puts all build artifacts in a deployments/{id}
/// </summary>
private void Build(string id, ITracer tracer, IDisposable deployStep)
{
if (String.IsNullOrEmpty(id))
{
throw new ArgumentException();
}
ILogger logger = null;
DeploymentStatusFile currentStatus = null;
IDisposable buildStep = null;
try
{
logger = GetLogger(id);
ILogger innerLogger = logger.Log(Resources.Log_PreparingDeployment, TrimId(id));
currentStatus = OpenStatusFile(id);
currentStatus.Complete = false;
currentStatus.StartTime = DateTime.Now;
currentStatus.Status = DeployStatus.Building;
currentStatus.StatusText = String.Format(CultureInfo.CurrentCulture, Resources.Status_BuildingAndDeploying, id);
currentStatus.Save(_fileSystem);
ReportStatus(id);
ISiteBuilder builder = null;
try
{
builder = _builderFactory.CreateBuilder(tracer, innerLogger);
}
catch (Exception ex)
{
_globalLogger.Log(ex);
tracer.TraceError(ex);
innerLogger.Log(ex);
MarkFailed(currentStatus);
ReportStatus(id);
deployStep.Dispose();
return;
}
buildStep = tracer.Step("Building");
var context = new DeploymentContext
{
ManifestWriter = GetDeploymentManifestWriter(id),
PreviousMainfest = GetActiveDeploymentManifestReader(),
Tracer = tracer,
Logger = logger,
GlobalLogger = _globalLogger,
OutputPath = _environment.DeploymentTargetPath,
};
builder.Build(context)
.Then(() =>
{
// End the build step
buildStep.Dispose();
// Run post deployment steps
FinishDeployment(id, tracer, deployStep);
})
.Catch(ex =>
{
// End the build step
buildStep.Dispose();
MarkFailed(currentStatus);
ReportStatus(id);
// End the deploy step
deployStep.Dispose();
});
}
catch (Exception ex)
{
tracer.TraceError(ex);
logger.LogUnexpetedError();
if (buildStep != null)
{
buildStep.Dispose();
}
deployStep.Dispose();
}
}
开发者ID:cburgdorf,项目名称:kudu,代码行数:99,代码来源:DeploymentManager.cs
示例14: Build
/// <summary>
/// Builds and deploys a particular changeset. Puts all build artifacts in a deployments/{id}
/// </summary>
private void Build(string id, ITracer tracer, IDisposable deployStep)
{
if (String.IsNullOrEmpty(id))
{
throw new ArgumentException("The id parameter is null or empty", "id");
}
ILogger logger = null;
IDeploymentStatusFile currentStatus = null;
IDisposable buildStep = null;
try
{
logger = GetLogger(id);
ILogger innerLogger = logger.Log(Resources.Log_PreparingDeployment, TrimId(id));
currentStatus = _status.Open(id);
currentStatus.Complete = false;
currentStatus.StartTime = DateTime.Now;
currentStatus.Status = DeployStatus.Building;
currentStatus.StatusText = String.Format(CultureInfo.CurrentCulture, Resources.Status_BuildingAndDeploying, id);
currentStatus.Save();
ISiteBuilder builder = null;
try
{
builder = _builderFactory.CreateBuilder(tracer, innerLogger);
}
catch (Exception ex)
{
// If we get a TargetInvocationException, use the inner exception instead to avoid
// useless 'Exception has been thrown by the target of an invocation' messages
var targetInvocationException = ex as System.Reflection.TargetInvocationException;
if (targetInvocationException != null)
{
ex = targetInvocationException.InnerException;
}
_globalLogger.Log(ex);
tracer.TraceError(ex);
innerLogger.Log(ex);
currentStatus.MarkFailed();
deployStep.Dispose();
return;
}
buildStep = tracer.Step("Building");
var context = new DeploymentContext
{
ManifestWriter = GetDeploymentManifestWriter(id),
PreviousManifest = GetActiveDeploymentManifestReader(),
Tracer = tracer,
Logger = logger,
GlobalLogger = _globalLogger,
OutputPath = _environment.WebRootPath,
};
context.NextManifestFilePath = context.ManifestWriter.ManifestFilePath;
if (context.PreviousManifest == null)
{
// In the first deployment we want the wwwroot directory to be cleaned, we do that using a manifest file
// That has the expected content of a clean deployment (only one file: hostingstart.html)
// This will result in KuduSync cleaning this file.
context.PreviousManifest = new DeploymentManifest(Path.Combine(_environment.ScriptPath, Constants.FirstDeploymentManifestFileName));
}
context.PreviousManifestFilePath = context.PreviousManifest.ManifestFilePath;
builder.Build(context)
.Then(() =>
{
// End the build step
buildStep.Dispose();
// Run post deployment steps
FinishDeployment(id, deployStep);
})
.Catch(ex =>
{
// End the build step
buildStep.Dispose();
currentStatus.MarkFailed();
// End the deploy step
deployStep.Dispose();
return ex.Handled();
});
//.........这里部分代码省略.........
开发者ID:GregPerez83,项目名称:kudu,代码行数:101,代码来源:DeploymentManager.cs
示例15: Build
public override Task Build(DeploymentContext context)
{
var tcs = new TaskCompletionSource<object>();
string buildTempPath = Path.Combine(_tempPath, Guid.NewGuid().ToString());
ILogger buildLogger = context.Logger.Log(Resources.Log_BuildingWebProject, Path.GetFileName(_projectPath));
try
{
using (context.Tracer.Step("Running msbuild on project file"))
{
string log = BuildProject(context.Tracer, buildTempPath);
// Log the details of the build
buildLogger.Log(log);
}
}
catch (Exception ex)
{
context.Tracer.TraceError(ex);
// HACK: Log an empty error to the global logger (post receive hook console output).
// The reason we don't log the real exception is because the 'live output' running
// msbuild has already been captured.
context.GlobalLogger.LogError();
buildLogger.Log(ex);
tcs.SetException(ex);
return tcs.Task;
}
ILogger copyLogger = context.Logger.Log(Resources.Log_PreparingFiles);
try
{
using (context.Tracer.Step("Copying files to output directory"))
{
// Copy to the output path and use the previous manifest if there
DeploymentHelper.CopyWithManifest(buildTempPath, context.OutputPath, context.PreviousMainfest);
}
using (context.Tracer.Step("Building manifest"))
{
// Generate a manifest from those build artifacts
context.ManifestWriter.AddFiles(buildTempPath);
}
// Log the copied files from the manifest
copyLogger.LogFileList(context.ManifestWriter.GetPaths());
tcs.SetResult(null);
}
catch (Exception ex)
{
context.Tracer.TraceError(ex);
context.GlobalLogger.Log(ex);
copyLogger.Log(ex);
tcs.SetException(ex);
}
finally
{
// Clean up the build artifacts after copying them
CleanBuild(context.Tracer, buildTempPath);
}
return tcs.Task;
}
开发者ID:remcoros,项目名称:kudu,代码行数:72,代码来源:WapBuilder.cs
示例16: SelectNodeVersion
/// <summary>
/// Selects a node.js version to run the application with and augments iisnode.yml accordingly
/// </summary>
private void SelectNodeVersion(DeploymentContext context)
{
var fileSystem = new FileSystem();
var nodeSiteEnabler = new NodeSiteEnabler(
fileSystem,
repoFolder: _sourcePath,
siteFolder: context.OutputPath,
scriptPath: _scriptPath);
ILogger innerLogger = null;
try
{
if (nodeSiteEnabler.LooksLikeNode())
{
innerLogger = context.Logger.Log(Resources.Log_SelectNodeJsVersion);
string log = nodeSiteEnabler.SelectNodeVersion(context.Tracer);
if (!String.IsNullOrEmpty(log))
{
innerLogger.Log(log);
}
}
}
catch (Exception ex)
{
if (innerLogger != null)
{
innerLogger.Log(ex);
}
throw;
}
}
开发者ID:ashleybrener,项目名称:kudu,代码行数:38,代码来源:BasicBuilder.cs
示例17: Build
public abstract Task Build(DeploymentContext context);
开发者ID:chrisdias,项目名称:kudu,代码行数:1,代码来源:MsBuildSiteBuilder.cs
示例18: TryTouchWebConfig
private static void TryTouchWebConfig(DeploymentContext context)
{
try
{
// Touch web.config
string webConfigPath = Path.Combine(context.OutputPath, "web.config");
if (File.Exists(webConfigPath))
{
File.SetLastWriteTimeUtc(webConfigPath, DateTime.UtcNow);
}
}
catch (Exception ex)
{
context.Tracer.TraceError(ex);
}
}
开发者ID:NorimaConsulting,项目名称:kudu,代码行数:16,代码来源:DeploymentManager.cs
示例19: HandleAutoSwapTests
public async Task HandleAutoSwapTests()
{
string deploymentId = Guid.Empty.ToString();
var deploymentSettingsMock = new Mock<IDeploymentSettingsManager>();
var enviromentMock = new Mock<IEnvironment>();
var deploymentStatusManagerMock = new Mock<IDeploymentStatusManager>();
var tracerMock = new Mock<ITracer>();
var deploymentContextMock = new DeploymentContext()
{
Logger = Mock.Of<ILogger>(),
Tracer = tracerMock.Object
};
enviromentMock.Setup(e => e.LocksPath).Returns(@"x:\foo");
deploymentStatusManagerMock.Setup(d => d.ActiveDeploymentId).Returns(deploymentId);
var handler = new AutoSwapHandler(
enviromentMock.Object,
deploymentSettingsMock.Object,
Mock.Of<ITraceFactory>());
TestTracer.Trace("Autoswap will not happen, since it is not enabled.");
await handler.HandleAutoSwap(deploymentId, deploymentContextMock.Logger, deploymentContextMock.Tracer);
TestTracer.Trace("Autoswap will not happen, since there is no JWT token.");
System.Environment.SetEnvironmentVariable(Constants.SiteRestrictedJWT, null);
deploymentSettingsMock.Setup(
s => s.GetValue(It.Is<string>(v => "WEBSITE_SWAP_SLOTNAME".StartsWith(v)), It.IsAny<bool>())
).Returns("someslot");
handler = new AutoSwapHandler(
enviromentMock.Object,
deploymentSettingsMock.Object,
Mock.Of<ITraceFactory>());
var fileSystemMock = new Mock<IFileSystem>();
var fileInfoMock = new Mock<IFileInfoFactory>();
var fileInfoBaseMock = new Mock<FileInfoBase>();
FileSystemHelpers.Instance = fileSystemMock.Object;
fileSystemMock.Setup(f => f.FileInfo).Returns(fileInfoMock.Object);
fileInfoMock.Setup(f => f.FromFileName(It.IsAny<string>())).Returns(fileInfoBaseMock.Object);
fileInfoBaseMock.Setup(f => f.Exists).Returns(true);
fileInfoBaseMock.Setup(f => f.LastWriteTimeUtc).Returns(DateTime.UtcNow);
await handler.HandleAutoSwap(deploymentId, deploymentContextMock.Logger, deploymentContextMock.Tracer);
try
{
string jwtToken = Guid.NewGuid().ToString();
string hostName = "foo.scm.bar";
System.Environment.SetEnvironmentVariable(Constants.SiteRestrictedJWT, jwtToken);
System.Environment.SetEnvironmentVariable(Constants.HttpHost, hostName);
tracerMock.Verify(l => l.Trace("AutoSwap is not enabled", It.IsAny<IDictionary<string, string>>()), Times.Once);
tracerMock.Verify(l => l.Trace("AutoSwap is not enabled", It.IsAny<IDictionary<string, string>>()), Times.Once);
TestTracer.Trace("Autoswap will be triggered");
string newDeploymentId = Guid.NewGuid().ToString();
string autoSwapRequestUrl = null;
string bearerToken = null;
OperationClient.ClientHandler = new TestMessageHandler((HttpRequestMessage requestMessage) =>
{
autoSwapRequestUrl = requestMessage.RequestUri.AbsoluteUri;
bearerToken = requestMessage.Headers.GetValues("Authorization").First();
return new HttpResponseMessage(HttpStatusCode.OK);
});
await handler.HandleAutoSwap(newDeploymentId, deploymentContextMock.Logger, deploymentContextMock.Tracer);
Assert.NotNull(autoSwapRequestUrl);
Assert.True(autoSwapRequestUrl.StartsWith("https://foo.scm.bar/operations/autoswap?slot=someslot&operationId=AUTOSWAP"));
Assert.NotNull(bearerToken);
Assert.Equal("Bearer " + jwtToken, bearerToken);
}
finally
{
System.Environment.SetEnvironmentVariable(Constants.SiteRestrictedJWT, null);
System.Environment.SetEnvironmentVariable(Constants.HttpHost, null);
OperationClient.ClientHandler = null;
}
}
开发者ID:NorimaConsulting,项目名称:kudu,代码行数:83,代码来源:AutoSwapHandlerFacts.cs
示例20: Build
public Task Build(DeploymentContext context)
{
var tcs = new TaskCompletionSource<object>();
ILogger customLogger = context.Logger.Log("Running custom deployment command...");
// Creates an executable pointing to cmd and the working directory being
// the repository root
var exe = new Executable(&qu
|
请发表评论