forked from WaelHamze/xrm-ci-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Cmdlet to Pack Solution using solutionpackager.exe
- Loading branch information
Showing
9 changed files
with
200 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
MSDYNV9/Xrm.Framework.CI/Xrm.Framework.CI.PowerShell.Cmdlets/CompressXrmSolution.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Management.Automation; | ||
using Microsoft.Crm.Sdk.Messages; | ||
using Xrm.Framework.CI.Common; | ||
|
||
namespace Xrm.Framework.CI.PowerShell.Cmdlets | ||
{ | ||
/// <summary> | ||
/// <para type="synopsis">Invokes a WhoAmIRequest</para> | ||
/// <para type="description">This cmdlet can be used to test your connectivity to CRM by calling | ||
/// WhoAmIRequest and returning a WhoAmIResponse object. | ||
/// </para> | ||
/// </summary> | ||
/// <example> | ||
/// <code>C:\PS>Export-XrmSolution -ConnectionString "" -EntityName "account"</code> | ||
/// <para>Exports the "" managed solution to "" location</para> | ||
/// </example> | ||
[Cmdlet(VerbsData.Compress, "XrmSolution")] | ||
[OutputType(typeof(WhoAmIResponse))] | ||
public class CompressXrmSolution : CommandBase | ||
{ | ||
#region Parameters | ||
|
||
/// <summary> | ||
/// <para type="description">The absolute path to the solutionpackager.exe</para> | ||
/// </summary> | ||
[Parameter(Mandatory = true)] | ||
public string SolutionPackagerPath { get; set; } | ||
|
||
/// <para type="description">The package type used by the solution packager</para> | ||
/// </summary> | ||
[Parameter(Mandatory = true)] | ||
public string PackageType { get; set; } | ||
|
||
|
||
/// <para type="description">The folder containing the unpacked customizations</para> | ||
/// </summary> | ||
[Parameter(Mandatory = true)] | ||
public string Folder { get; set; } | ||
|
||
/// <summary> | ||
/// <para type="description">The mapping file used by the solution packager</para> | ||
/// </summary> | ||
[Parameter(Mandatory = false)] | ||
public string MappingFile { get; set; } | ||
|
||
/// <summary> | ||
/// <para type="description">The new version of the solution to set in solution.xml</para> | ||
/// </summary> | ||
[Parameter(Mandatory = false)] | ||
public string Version { get; set; } | ||
|
||
/// <summary> | ||
/// <para type="description">Set to true to include the version number in the generated solution file</para> | ||
/// </summary> | ||
[Parameter(Mandatory = false)] | ||
public bool IncludeVersionInName { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// <para type="description">Set to true to update solution release version</para> | ||
/// </summary> | ||
[Parameter(Mandatory = false)] | ||
public bool IncrementReleaseVersion { get; set; } | ||
|
||
/// <summary> | ||
/// <para type="description">Set to true to cause operation to fail if warnings are encountered</para> | ||
/// </summary> | ||
[Parameter(Mandatory = false)] | ||
public bool TreatWarningsAsErrors { get; set; } | ||
|
||
/// <summary> | ||
/// <para type="description">The absolute path to the location of the packed solutions</para> | ||
/// </summary> | ||
[Parameter(Mandatory = true)] | ||
public string OutputFolder { get; set; } | ||
|
||
/// <summary> | ||
/// <para type="description">The directory where the pack logs should be placed.</para> | ||
/// </summary> | ||
[Parameter(Mandatory = false)] | ||
public string LogsDirectory { get; set; } | ||
|
||
#endregion | ||
|
||
#region Process Record | ||
|
||
protected override void ProcessRecord() | ||
{ | ||
base.ProcessRecord(); | ||
|
||
Logger.LogInformation("Packing Solution from Path: {0}", Folder); | ||
|
||
SolutionPackagerManager packagerManager = new SolutionPackagerManager(Logger); | ||
|
||
SolutionPackager_PackageType packageType; | ||
if (!Enum.TryParse<SolutionPackager_PackageType>(PackageType, out packageType)) | ||
{ | ||
throw new Exception($"{PackageType} is not valid"); | ||
} | ||
|
||
bool result = packagerManager.PackSolution( | ||
SolutionPackagerPath, | ||
OutputFolder, | ||
Folder, | ||
packageType, | ||
IncludeVersionInName, | ||
MappingFile, | ||
TreatWarningsAsErrors, | ||
IncrementReleaseVersion, | ||
Version, | ||
LogsDirectory); | ||
|
||
if (!result) | ||
{ | ||
throw new System.Exception("Packing Solution failed. Check logs for more information"); | ||
} | ||
|
||
Logger.LogInformation("Packing Solution Completed"); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...V9/Xrm.Framework.CI/Xrm.Framework.CI.PowerShell.Scripts/UpdateSolutionVersionInFolder.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# | ||
# UpdateSolutionVersionInFolder.ps1 | ||
# | ||
|
||
param( | ||
[string]$unpackedFilesFolder, | ||
[string]$VersionNumber | ||
) | ||
|
||
$ErrorActionPreference = "Stop" | ||
|
||
Write-Verbose 'Entering UpdateSolutionVersionInFolder.ps1' | ||
|
||
#Parameters | ||
Write-Verbose "unpackedFilesFolder = $unpackedFilesFolder" | ||
Write-Verbose "VersionNumber = $VersionNumber" | ||
|
||
#Script Location | ||
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition | ||
Write-Verbose "Script Path: $scriptPath" | ||
|
||
#Load XrmCIFramework | ||
$xrmCIToolkit = $scriptPath + "\Xrm.Framework.CI.PowerShell.Cmdlets.dll" | ||
Write-Verbose "Importing CIToolkit: $xrmCIToolkit" | ||
Import-Module $xrmCIToolkit | ||
Write-Verbose "Imported CIToolkit" | ||
|
||
Write-Verbose "Setting Solution Version in File to: $VersionNumber" | ||
|
||
$SolutionXmlFile = "$UnpackedFilesFolder\Other\Solution.xml" | ||
|
||
Write-Verbose "Setting $SolutionXmlFile to IsReadyOnly = false" | ||
|
||
Set-ItemProperty $SolutionXmlFile -name IsReadOnly -value $false | ||
|
||
Set-XrmSolutionVersionInFolder -SolutionFilesFolderPath $UnpackedFilesFolder -Version $VersionNumber | ||
|
||
Write-Host "$SolutionXmlFile updated with $VersionNumber" | ||
|
||
Write-Verbose 'Leaving UpdateSolutionVersionInFolder.ps1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters