Skip to content

Commit

Permalink
Merge pull request #26 from shanec-/development
Browse files Browse the repository at this point in the history
Development - version 1.4.0
  • Loading branch information
shanec- committed Apr 17, 2017
2 parents f00e8e8 + 42b20ff commit 74d0e56
Show file tree
Hide file tree
Showing 19 changed files with 339 additions and 90 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ end_of_line = crlf

[*.md]
trim_trailing_whitespace = false

[*.ps1]
indent_style = tab
tab_width = 2
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# generator-nullfactory-xrm
> Dynamics CRM Solution Template
> Scaffolding Template for Dynamics CRM/365 Solutions
[![Build status](https://ci.appveyor.com/api/projects/status/4dmqta7pnueqxa11?svg=true)](https://ci.appveyor.com/project/shanec-/generator-nullfactory-xrm)

A yeoman template for managing [Solution Packager](https://msdn.microsoft.com/en-us/library/jj602987.aspx)-compatible Dynamics CRM solutions.
A yeoman tempate for scaffolding [Solution Packager](https://msdn.microsoft.com/en-us/library/jj602987.aspx)-compatible Dynamics CRM (365) solution structure.

The generated project structure is built around the Solution Packager provided in the official SDK and the [Microsoft.Xrm.Data.PowerShell](https://github.com/seanmcne/Microsoft.Xrm.Data.PowerShell) module. It facilitates the quick creation of team builds and release strategies with minimal effort and enables you to maintain a single source of truth for you CRM solutions.

## Installation

Expand Down Expand Up @@ -48,7 +50,7 @@ Optionally, install the [`Microsoft.Xrm.Data.PowerShell`](https://github.com/sea
Install-Module -Name Microsoft.Xrm.Data.PowerShell -Scope CurrentUser -Force
```

Even if you skip the above step, the sychrnoization powershell script would attempt to install it automatically.
Even if you skip the above step, the sychrnoization PowerShell script would attempt to install it automatically. The PowerShell scripts require a minimum of PowerShell 5.0 and Microsoft.Xrm.Data.PowerShell 2.5.

## Syncing a Solution to the Project

Expand All @@ -71,6 +73,7 @@ More information on source control management, setting up continuous integration
- [Release Strategy for Dynamics CRM - Part 2 - Setting Up the Build](http://www.nullfactory.net/2016/11/release-strategy-for-dynamics-crm-setting-up-the-build-part-2/)
- [Release Strategy for Dynamics CRM - Part 3 - Setting Up the Release](http://www.nullfactory.net/2016/11/release-strategy-for-dynamics-crm-setting-up-the-release-part-3/)
- [Release Strategy for Dynamics CRM - Part 4 - Versioning](http://www.nullfactory.net/2017/02/release-strategy-for-dynamics-crm-versioning-part-4/)
- [Release Strategy for Dynamics CRM - Part 5 - Deploy Third-Party Solutions](http://www.nullfactory.net/2017/04/release-strategy-for-dynamics-crm-deploying-third-party-solutions-part-5/)

## Feedback

Expand Down
8 changes: 6 additions & 2 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,13 @@ module.exports = yeoman.Base.extend({
this.destinationPath('Nullfactory.Xrm.Tooling/_Install/Install-Microsoft.Xrm.Data.PowerShell.ps1')
);

this.fs.copy(
this.fs.copyTpl(
this.templatePath('Nullfactory.Xrm.Tooling/Mappings/solution-mapping.xml'),
this.destinationPath('Nullfactory.Xrm.Tooling/Mappings/' + this.props.crmSolutionName + '-mapping.xml')
this.destinationPath('Nullfactory.Xrm.Tooling/Mappings/' + this.props.crmSolutionName + '-mapping.xml'), {
visualStudioSolutionProjectPrefix: this.props.visualStudioSolutionProjectPrefix,
isAddPluginProject: this.props.isAddPluginProject,
isAddWorkflowProject: this.props.isAddWorkflowProject
}
);

this.fs.copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@
<!-- <FileToFile map="PluginAssemblies\**\ProjectXrmPlugins.dll" to="..\Project.Xrm.Plugins\bin\**\Project.Xrm.Plugins.dll" />
<FileToFile map="WebResources\nf_MyComponent\Images\test_image.jpg" to="..\Project.Solution1.WebResources\MyComponent\Images\test_image.jpg" />
-->

<% if (isAddPluginProject == true) { %>
<FileToFile map="PluginAssemblies\**\<%= visualStudioSolutionProjectPrefix %>XrmPlugins.dll" to="..\<%= visualStudioSolutionProjectPrefix %>.Xrm.Plugins\bin\**\<%= visualStudioSolutionProjectPrefix %>.Xrm.Plugins.dll" />
<% } %>
<% if (isAddWorkflowProject == true) { %>
<FileToFile map="PluginAssemblies\**\<%= visualStudioSolutionProjectPrefix %>XrmWorkflows.dll" to="..\<%= visualStudioSolutionProjectPrefix %>.Xrm.Workflows\bin\**\<%= visualStudioSolutionProjectPrefix %>.Xrm.Workflows.dll" />
<% } %>

</Mapping>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- generated using [email protected] -->
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -30,23 +31,17 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Content Include="bin\coretools\AntiXSSLibrary.dll" />
<Content Include="bin\coretools\CrmSvcUtil.exe" />
<Content Include="bin\coretools\CrmSvcUtil.xml" />
<Content Include="bin\coretools\Microsoft.Crm.Sdk.Proxy.dll" />
<Content Include="bin\coretools\Microsoft.IdentityModel.Clients.ActiveDirectory.dll" />
<Content Include="bin\coretools\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll" />
<Content Include="bin\coretools\Microsoft.IdentityModel.dll" />
<Content Include="bin\coretools\Microsoft.Xrm.Client.CodeGeneration.dll" />
<Content Include="bin\coretools\Microsoft.Xrm.Client.dll" />
<Content Include="bin\coretools\Microsoft.Xrm.Portal.dll" />
<Content Include="bin\coretools\Microsoft.Xrm.Sdk.Deployment.dll" />
<Content Include="bin\coretools\Microsoft.Xrm.Sdk.dll" />
<Content Include="bin\coretools\Microsoft.Xrm.Tooling.Connector.dll" />
<Content Include="bin\coretools\Microsoft.Xrm.Tooling.CrmConnectControl.dll" />
<Content Include="bin\coretools\Other Redistributable.txt" />
<Content Include="bin\coretools\SolutionPackager.exe" />
<Content Include="bin\coretools\WebsiteCopy.exe" />
<Content Include="Mappings\<%= crmSolutionName %>-mapping.xml" />
</ItemGroup>
<ItemGroup>
Expand All @@ -56,6 +51,7 @@
<None Include="Scripts\Deploy-CrmSolution.ps1" />
<None Include="Scripts\Pull-CrmSolution.Param.ps1" />
<None Include="Scripts\Pull-CrmSolution.ps1" />
<None Include="Scripts\CrmSolution.Common.ps1" />
<None Include="_Install\Install-Microsoft.Xrm.Data.PowerShell.ps1" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
<#
.SYNOPSIS
Recursively finds a list of files and uses a pattern to match and replace matches with a specified version number.
.DESCRIPTION
Recursively finds a list of files within a folder and uses a regular expression pattern to match and replace it with a specified version number.
.NOTES
Author: Shane Carvalho
Version: [email protected]
.LINK
https://nullfactory.net
.PARAMETER BuildSourcePath
The root folder to search.
.PARAMETER versionFile
The pattern of file to be searched.
.PARAMETER regexPattern
The regex pattern to be searched.
.PARAMETER finalVersion
The new version number.
.PARAMETER encoding
The optional encoding. Common encoding values include ASCII, Unicode, UTF8, Default. Default uses the encoding of the system's current ANSI code page.
.EXAMPLE
ReplaceVersion ".\SourceRootFolder" "*AssemblyInfo.cs" "\d+\.\d+\.\d+\.\d+" "1.3.0"
Gets a list of all files starting with "*AssemblyInfo.cs" within the folder "SourceRootFolder". Within these files it attempts to match all instances of a version number ex. 0.0.0.0 and replace it with the new version number.
#>
function ReplaceVersion([string]$BuildSourcePath, [string] $versionFile, [string] $regexPattern, [string]$finalVersion, [string]$encoding='Default')
{
[bool]$output = $false
Expand All @@ -19,6 +43,16 @@ function ReplaceVersion([string]$BuildSourcePath, [string] $versionFile, [string
return $output
}

<#
.SYNOPSIS
Applies a specified version number to a list of file matching a pattern.
.PARAMETER BuildSourcePath
The root folder containing the source files.
.PARAMETER BuildBuildNumber
The new build number.
.EXAMPLE
ApplyVersionToAssemblies ".\RootFolder" "0.1.2"
#>
function ApplyVersionToAssemblies
{
[CmdletBinding()]
Expand All @@ -40,6 +74,16 @@ function ApplyVersionToAssemblies
}
}

<#
.SYNOPSIS
Applies a specified version number to a CRM solution.
.PARAMETER BuildSourcePath
The root folder containing the extracted (via solutio packager) CRM Solution.
.PARAMETER BuildBuildNumber
The new build number.
.EXAMPLE
ApplyVersionToCrmSolution ".\RootFolder" "0.1.2"
#>
function ApplyVersionToCrmSolution
{
[CmdletBinding()]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
function GetUsername($solutionName)
<#
.SYNOPSIS
Retrieves the username for the specified CRM solution.
.DESCRIPTION
Retrieves the username for the specified CRM solution which is stored in a user-environmental variable. If one does not exist, the script would prompt the user for a new username, which is then stored in a new environment variable.
.NOTES
Author: Shane Carvalho
Version: [email protected]
.LINK
https://nullfactory.net
.PARAMETER solutionName
The name of the CRM solution.
.EXAMPLE
$username = Get-CrmUsername("Nullfactory.Solution1")
#>
function Get-CrmUsername($solutionName)
{
$variableName = "nfac_" + $solutionName + "_username"
$username = [environment]::GetEnvironmentVariable($variableName, "User")
Expand All @@ -12,7 +27,18 @@ function GetUsername($solutionName)
return $username;
}

function GetPassword($solutionName)
<#
.SYNOPSIS
Retrieves the password for the specified CRM solution.
.DESCRIPTION
Retrieves the password for the specified CRM solution which is stored in a user-environmental variable. If one does not exist, the script would prompt the user for a new password, which is then stored in a new environment variable.
Note that the password is stored as plain-text.
.PARAMETER solutionName
The name of the CRM solution.
.EXAMPLE
$username = Get-CrmPassword("Nullfactory.Solution1")
#>
function Get-CrmPassword($solutionName)
{
$variableName = "nfac_" + $solutionName + "_password"
$plainTextPassword = [environment]::GetEnvironmentVariable($variableName, "User")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,47 @@
<#
.SYNOPSIS
Manually deploy the CRM Solutions to the remote CRM servers.
.DESCRIPTION
Manually deploy the CRM solution to the configured remote CRM servers.
.NOTES
Author: Shane Carvalho
Version: [email protected]
.LINK
https://nullfactory.net
#>

# Importing common functions
. .\CrmSolution.Common.ps1

Write-Host "Attempting to deploy solution(s)..."
# Defaulting to increased verbosity for manual execution
$oldverbose = $VerbosePreference
$VerbosePreference = "continue"

.\Deploy-CrmSolution.ps1 `
-serverUrl "<%= crmServerUrl %>" `
-username (GetUsername "<%= crmSolutionName %>") `
-password (GetPassword "<%= crmSolutionName %>") `
-solutionName "<%= crmSolutionName %>" `
-publishChanges `
-activatePlugins
Write-Host "Attempting to deploy solution(s)..."
try
{
.\Deploy-CrmSolution.ps1 `
-serverUrl "<%= crmServerUrl %>" `
-username (Get-CrmUsername "<%= visualStudioSolutionProjectPrefix %>.<%= crmSolutionName %>") `
-password (Get-CrmPassword "<%= visualStudioSolutionProjectPrefix %>.<%= crmSolutionName %>") `
-solutionName "<%= visualStudioSolutionProjectPrefix %>.<%= crmSolutionName %>" `
-publishChanges `
-activatePlugins

# Include new entry for each CRM solution to be released manually
# Include new entry for each CRM solution to be released manually

# .\Deploy-CrmSolution.ps1 `
# -serverUrl "http://servername/secondary" `
# -username (GetUsername "env_secondary_username_key") `
# -password (GetPassword "env_secondary_password_key") `
# -solutionName "secondary" `
# -publishChanges `
# -activatePlugins
# .\Deploy-CrmSolution.ps1 `
# -serverUrl "http://servername/secondary" `
# -username (GetUsername "env_secondary_username_key") `
# -password (GetPassword "env_secondary_password_key") `
# -solutionName "secondary" `
# -publishChanges `
# -activatePlugins

Write-Host "Deployment(s) complete." -ForegroundColor Green
Write-Host "Deployment(s) complete." -ForegroundColor Green
}
finally
{
# Reset the verbosity to original level
$VerbosePreference = $oldverbose
}
Loading

0 comments on commit 74d0e56

Please sign in to comment.