本文整理汇总了C#中VariableDictionary.Save方法的典型用法代码示例。如果您正苦于以下问题:C# VariableDictionary.Save方法的具体用法?C# VariableDictionary.Save怎么用?C# VariableDictionary.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VariableDictionary
的用法示例。
在下文中一共展示了VariableDictionary.Save方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deploy
public void Deploy()
{
OctopusTestAzureSubscription.IgnoreIfCertificateNotInstalled();
var nugetPackageFile = PackageBuilder.BuildSamplePackage("Octopus.Sample.AzureCloudService", "1.0.0");
var variablesFile = Path.GetTempFileName();
var variables = new VariableDictionary();
OctopusTestAzureSubscription.PopulateVariables(variables);
OctopusTestCloudService.PopulateVariables(variables);
variables.Set(SpecialVariables.Action.Azure.Slot, "Staging");
variables.Set(SpecialVariables.Action.Azure.SwapIfPossible, false.ToString());
variables.Set(SpecialVariables.Action.Azure.UseCurrentInstanceCount, false.ToString());
variables.Set(SpecialVariables.Action.Name, "AzureCloudService");
variables.Set(SpecialVariables.Release.Number, "1.0.0");
// Disable cspkg extraction
variables.Set(SpecialVariables.Action.Azure.CloudServicePackageExtractionDisabled, true.ToString());
fileSystem = new WindowsPhysicalFileSystem();
stagingDirectory = Path.GetTempPath();
variables.Set(SpecialVariables.Action.Azure.PackageExtractionPath, stagingDirectory);
variables.Save(variablesFile);
result = Invoke(
Calamari()
.Action("deploy-azure-cloud-service")
.Argument("package", nugetPackageFile)
.Argument("variables", variablesFile));
}
开发者ID:enlightendesigns,项目名称:Calamari,代码行数:32,代码来源:DeployAzureCloudServiceSansPackageExtractionFixture.cs
示例2: InvokeScript
private int InvokeScript(CalamariVariableDictionary variables, VariableDictionary outputVariables)
{
if (!File.Exists(scriptFile))
throw new CommandException("Could not find script file: " + scriptFile);
var scriptEngine = new CombinedScriptEngine();
var runner = new CommandLineRunner(
new SplitCommandOutput(new ConsoleCommandOutput(), new ServiceMessageCommandOutput(variables), new ServiceMessageCommandOutput(outputVariables)));
var result = scriptEngine.Execute(scriptFile, variables, runner);
outputVariables.Save();
return result.ExitCode;
}
示例3: ShouldIncludeSensitiveVariables
public void ShouldIncludeSensitiveVariables()
{
const string encryptionPassword = "HumptyDumpty!";
var insensitiveVariables = new VariableDictionary(insensitiveVariablesFileName);
insensitiveVariables.Set("insensitiveVariableName", "insensitiveVariableValue");
insensitiveVariables.Save();
var sensitiveVariables = new Dictionary<string, string>
{
{"sensitiveVariableName", "sensitiveVariableValue"}
};
var salt = CreateEncryptedSensitiveVariablesFile(sensitiveVariablesFileName, encryptionPassword, sensitiveVariables);
var result = subject.IncludeSensitiveVariables(insensitiveVariablesFileName, encryptionPassword, salt);
Assert.AreEqual("sensitiveVariableValue", result.Get("sensitiveVariableName"));
Assert.AreEqual("insensitiveVariableValue", result.Get("insensitiveVariableName"));
}
示例4: ShouldSetAzureSubscription
public void ShouldSetAzureSubscription()
{
// If the Azure test certificate is not installed, we cannot run, so ignore
OctopusTestAzureSubscription.IgnoreIfCertificateNotInstalled();
var variablesFile = Path.GetTempFileName();
var variables = new VariableDictionary();
variables.Set(SpecialVariables.Account.AccountType, "AzureSubscription");
variables.Set(SpecialVariables.Account.Name, "AzureTest");
variables.Save(variablesFile);
OctopusTestAzureSubscription.PopulateVariables(variables);
var output = Invoke(Calamari()
.Action("run-script")
.Argument("script", GetFixtureResouce("AzureSubscription.ps1"))
.Argument("variables", variablesFile));
output.AssertZero();
output.AssertOutput("Current subscription ID: " + OctopusTestAzureSubscription.AzureSubscriptionId);
}
示例5: ShouldCallHello
public void ShouldCallHello()
{
var variablesFile = Path.GetTempFileName();
var variables = new VariableDictionary();
variables.Set("Name", "Paul");
variables.Set("Variable2", "DEF");
variables.Set("Variable3", "GHI");
variables.Set("Foo_bar", "Hello");
variables.Set("Host", "Never");
variables.Save(variablesFile);
using (new TemporaryFile(variablesFile))
{
var output = Invoke(Calamari()
.Action("run-script")
.Argument("script", GetFixtureResouce("Scripts", "hello.sh"))
.Argument("variables", variablesFile));
output.AssertZero();
output.AssertOutput("Hello Paul");
}
}
示例6: Execute
public override int Execute(string[] commandLineArguments)
{
Options.Parse(commandLineArguments);
Guard.NotNullOrWhiteSpace(packageFile, "No package file was specified. Please pass --package YourPackage.nupkg");
if (!File.Exists(packageFile))
throw new CommandException("Could not find package file: " + packageFile);
Log.Info("Deploying package: " + packageFile);
var fileSystem = CalamariPhysicalFileSystem.GetPhysicalFileSystem();
var variables = new CalamariVariableDictionary(variablesFile, sensitiveVariablesFile, sensitiveVariablesPassword);
var outputVariables = new VariableDictionary(outputVariablesFile);
variables.MergeWith(outputVariables);
var scriptCapability = new CombinedScriptEngine();
var replacer = new ConfigurationVariablesReplacer(variables.GetFlag(SpecialVariables.Package.IgnoreVariableReplacementErrors));
var substituter = new FileSubstituter(fileSystem);
var configurationTransformer = new ConfigurationTransformer(variables.GetFlag(SpecialVariables.Package.IgnoreConfigTransformationErrors), variables.GetFlag(SpecialVariables.Package.SuppressConfigTransformationLogging));
var embeddedResources = new CallingAssemblyEmbeddedResources();
var iis = new InternetInformationServer();
var commandLineRunner = new CommandLineRunner(new SplitCommandOutput(new ConsoleCommandOutput(), new ServiceMessageCommandOutput(variables), new ServiceMessageCommandOutput(outputVariables)));
var semaphore = new SystemSemaphore();
var journal = new DeploymentJournal(fileSystem, semaphore, variables);
var conventions = new List<IConvention>
{
new ContributeEnvironmentVariablesConvention(),
new ContributePreviousInstallationConvention(journal),
new LogVariablesConvention(),
new AlreadyInstalledConvention(journal),
new ExtractPackageToApplicationDirectoryConvention(new LightweightPackageExtractor(), fileSystem, semaphore),
new FeatureScriptConvention(DeploymentStages.BeforePreDeploy, fileSystem, embeddedResources, scriptCapability, commandLineRunner),
new ConfiguredScriptConvention(DeploymentStages.PreDeploy, scriptCapability, fileSystem, commandLineRunner),
new PackagedScriptConvention(DeploymentStages.PreDeploy, fileSystem, scriptCapability, commandLineRunner),
new FeatureScriptConvention(DeploymentStages.AfterPreDeploy, fileSystem, embeddedResources, scriptCapability, commandLineRunner),
new SubstituteInFilesConvention(fileSystem, substituter),
new ConfigurationTransformsConvention(fileSystem, configurationTransformer),
new ConfigurationVariablesConvention(fileSystem, replacer),
new CopyPackageToCustomInstallationDirectoryConvention(fileSystem),
new FeatureScriptConvention(DeploymentStages.BeforeDeploy, fileSystem, embeddedResources, scriptCapability, commandLineRunner),
new PackagedScriptConvention(DeploymentStages.Deploy, fileSystem, scriptCapability, commandLineRunner),
new ConfiguredScriptConvention(DeploymentStages.Deploy, scriptCapability, fileSystem, commandLineRunner),
new FeatureScriptConvention(DeploymentStages.AfterDeploy, fileSystem, embeddedResources, scriptCapability, commandLineRunner),
new LegacyIisWebSiteConvention(fileSystem, iis),
new FeatureScriptConvention(DeploymentStages.BeforePostDeploy, fileSystem, embeddedResources, scriptCapability, commandLineRunner),
new PackagedScriptConvention(DeploymentStages.PostDeploy, fileSystem, scriptCapability, commandLineRunner),
new ConfiguredScriptConvention(DeploymentStages.PostDeploy, scriptCapability, fileSystem, commandLineRunner),
new FeatureScriptConvention(DeploymentStages.AfterPostDeploy, fileSystem, embeddedResources, scriptCapability, commandLineRunner),
};
var deployment = new RunningDeployment(packageFile, variables);
var conventionRunner = new ConventionProcessor(deployment, conventions);
try
{
conventionRunner.RunConventions();
outputVariables.Save();
if (!deployment.SkipJournal)
journal.AddJournalEntry(new JournalEntry(deployment, true));
}
catch (Exception)
{
if (!deployment.SkipJournal)
journal.AddJournalEntry(new JournalEntry(deployment, false));
throw;
}
return 0;
}
示例7: ShouldSupportModulesInVariables
public void ShouldSupportModulesInVariables()
{
var variablesFile = Path.GetTempFileName();
var variables = new VariableDictionary();
variables.Set("Octopus.Script.Module[Foo]", "function SayHello() { Write-Host \"Hello from module!\" }");
variables.Save(variablesFile);
using (new TemporaryFile(variablesFile))
{
var output = Invoke(Calamari()
.Action("run-script")
.Argument("script", GetFixtureResouce("Scripts", "UseModule.ps1"))
.Argument("variables", variablesFile));
output.AssertZero();
output.AssertOutput("Hello from module!");
}
}
示例8: ShouldPrintVariables
public void ShouldPrintVariables()
{
var variablesFile = Path.GetTempFileName();
var variables = new VariableDictionary();
variables.Set("Variable1", "ABC");
variables.Set("Variable2", "DEF");
variables.Set("Variable3", "GHI");
variables.Set("Foo_bar", "Hello");
variables.Set("Host", "Never");
variables.Save(variablesFile);
using (new TemporaryFile(variablesFile))
{
var output = Invoke(Calamari()
.Action("run-script")
.Argument("script", GetFixtureResouce("Scripts", "PrintVariables.ps1"))
.Argument("variables", variablesFile));
output.AssertZero();
output.AssertOutput("V1= ABC");
output.AssertOutput("V2= DEF");
output.AssertOutput("V3= GHI");
output.AssertOutput("FooBar= Hello"); // Legacy - '_' used to be removed
output.AssertOutput("Foo_Bar= Hello"); // Current - '_' is valid in PowerShell
}
}
示例9: CreateSensitiveVariableFile
private void CreateSensitiveVariableFile()
{
var insensitiveVariables = new VariableDictionary(insensitiveVariablesFileName);
insensitiveVariables.Set("insensitiveVariableName", "insensitiveVariableValue");
insensitiveVariables.Save();
}