Thursday, June 29, 2017

Setting up CRM certificate on an environment restored from CRM Online

Download the certificate from your online instance (Settings >> Customizations >> Developer Resources)

image

Install the certificate into the user certificates:

Search for: Manager User Certificates
image

Right click on Personal >> Certificates and choose Import.

Browse and select the certificate you downloaded from CRM online

Right click on the certificate “*.crm.dynamics.com” and choose All Tasks >> Export

image

Choose “Base-64 encoded X.509 (.cer) as the format and click next and export it to a file.

Attach the certificate to CRM.

Open a powershell command window in Admin mode.

Add the CRM powershell snamp in by running: Add-PSSnapin Microsoft.Crm.PowerShell

Next install the certificate by running (replacing the path to the data file with the file from the step where you exported the base-64 file above:

Set-CrmCertificate -certificatetype appfabricissuer -StoreName My -StoreLocation LocalMachine -StoreFindType FindBySubjectDistinguishedName -DataFile C:\base64-crm.dynamics.com.cer

Finally validate that it worked by running: Get-CrmCertificate

More info:

https://msdn.microsoft.com/en-us/library/gg328249.aspx

Monday, June 26, 2017

DupFinder from JetBrains–XSLT

Jetbrains has a cool tool to find duplicates in your code-base called DupFinder.exe

Here is a slightly modified xsl, that also outputs the line numbers

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
     <xsl:output method="html" indent="yes" />
     <xsl:template match="/">
         <html>
             <body>
                 <h1>Statistics</h1>
                 <p>Total codebase size: <xsl:value-of select="//CodebaseCost"/></p>
                 <p>Code to analyze: <xsl:value-of select="//TotalDuplicatesCost"/></p>
                 <p>Total size of duplicated fragments: <xsl:value-of select="//TotalFragmentsCost" /></p>
                 <h1>Detected Duplicates</h1>
                 <xsl:for-each select="//Duplicates/Duplicate">
                     <h2>Duplicated Code. Cost: <xsl:value-of  select="@Cost"/></h2>
                     <h3>Duplicated Fragments:</h3>
                     <xsl:for-each select="Fragment">
                         <xsl:variable name="i" select="position()"/>
                         <p>Fragment <xsl:value-of select="$i"/>  in file <xsl:value-of select="FileName"/></p>
                         <p>Line Range Start: <xsl:value-of select="LineRange/@Start"/> End: <xsl:value-of select="LineRange/@End"/></p>
                         <pre><xsl:value-of select="Text"/></pre>
                         <br />
                     </xsl:for-each>
                 </xsl:for-each>
             </body>
         </html>
     </xsl:template>
</xsl:stylesheet>

Monday, June 12, 2017

Create an offline installer for Visual Studio 2017

Its as simple as:

1. Download the appropriate installer: https://www.visualstudio.com/downloads/

2. Run the following command on the installer (eg: if you downloaded the enterprise edition and the file was called “vs_enterprise__1432384505.1483734108.exe”

vs_enterprise__1432384505.1483734108.exe --layout vs2017_offline

Where vs2017_offline is the folder where the offline installer will be downloaded.

For more information see: https://docs.microsoft.com/en-us/visualstudio/install/create-a-network-installation-of-visual-studio.

Note: these steps can be applied to any Visual Studio installer (since 2015). Also, if you rerun the command, it will automatically update the folder with the latest release.

Thursday, June 08, 2017

Cannot open Sql Encryption Symmetric Key because Symmetric Key password does not exist in Config DB

We were getting this error when we were trying to set up service endpoint in CRM. Though you could get a similar error when you are trying other things in CRM too.

To change the key, you need to view the “Data Encryption” settings (under “Data Management”). Trying to open this page will give you the following error:

The HTTPS protocol is required for this type of request. Enable the HTTPS protocol and try again. For more information, see the Post-Installation and Configuration instructions.

To get around this error, (and ONLY do this in a dev environment. NEVER EVER in prod!), you can run this script:

UPDATE [MSCRM_CONFIG].[dbo].[DeploymentProperties]
SET [BitColumn]=1
WHERE ColumnName='DisableSSLCheckForEncryption' and BitColumn <> 1


Reference: https://technet.microsoft.com/en-us/library/dn531199.aspx?f=255&MSPPError=-2147217396