-
Notifications
You must be signed in to change notification settings - Fork 0
Deployment using a Deployment Manifest
dazinator edited this page Dec 10, 2014
·
4 revisions
You can now specify what should be deployed in a manifest file. You can then pass that to CrmUp.
Example:
public static int Main(string[] args)
{
var currentDir = Directory.GetCurrentDirectory();
var pathToDeploymentManifest = System.IO.Path.Combine(currentDir, "DeploymentManifest.xml");
var manifest = DeploymentManifest.FromFile(pathToDeploymentManifest);
var upgrader =
DeployChanges.To
.DynamicsCrmOrganisation("someconnectionstring")
.WithDeploymentManifest(manifest)
.LogToConsole()
.Build();
var result = upgrader.PerformUpgrade();
if (!result.Successful)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(result.Error);
Console.ResetColor();
return -1;
}
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Success!");
Console.ResetColor();
return 0;
}
Where DeploymentManifest.xml looks like:
<?xml version="1.0" encoding="utf-16"?>
<DeploymentManifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Assemblies>
<DeploymentAssembly>
<Name>CrmUp.Tests.dll</Name>
</DeploymentAssembly>
</Assemblies>
<Steps>
<DeploymentStep>
<StepName>Deploy Solution: TP888888_1_0_0_1_managed.zip</StepName>
<SolutionFileName>TP888888_1_0_0_1_managed.zip</SolutionFileName>
</DeploymentStep>
<DeploymentStep>
<StepName>Code Migration: Import Something</StepName>
<CodeMigrationScriptName>TestMigration</CodeMigrationScriptName>
</DeploymentStep>
<DeploymentStep>
<StepName>Deploy Solution: TP999999_1_0_0_0_managed.zip</StepName>
<SolutionFileName>TP999999_1_0_0_0_managed.zip</SolutionFileName>
</DeploymentStep>
</Steps>
</DeploymentManifest>
The solution files that you list in this manifest, such as 'TP999999_1_0_0_0_managed.zip' should exist in your applications root directory, or in a sub directory of your application.
Note that, the second deployment step is a CodeMigration
that lives in the assembly CrmUp.Tests.dll
exists along side the console application.
Alternatively, you can build up your deployment manifest in code:
var manifest = new DeploymentManifest();
// Add a solution file step.
var deploymentStep = new DeploymentStep();
deploymentStep.StepName = "Deploy Solution: TP888888_1_0_0_1_managed.zip";
deploymentStep.SolutionFileName = "TP888888_1_0_0_1_managed.zip";
manifest.Steps.Add(deploymentStep);
// Add an assembly that contains code migrations to use on the deployment.
var deploymentAssembly = new DeploymentAssembly();
deploymentAssembly.Name = "CrmUp.Tests.dll";
manifest.Assemblies.Add(deploymentAssembly);
// Add a code migration step.
var deploymentStep2 = new DeploymentStep();
deploymentStep2.StepName = "Code Migration: Import Something";
deploymentStep2.CodeMigrationScriptName = "TestMigration";
manifest.Steps.Add(deploymentStep2);
// Add another solution file step.
var deploymentStep3 = new DeploymentStep();
deploymentStep3.StepName = "Deploy Solution: TP999999_1_0_0_0_managed.zip";
deploymentStep3.SolutionFileName = "TP999999_1_0_0_0_managed.zip";
manifest.Steps.Add(deploymentStep3);
You could optionally save it to an Xml file if you want to persist it for any reason:
manifest.Save("C://DeploymentManifest.xml");