SPClientSideDeployment 3.0 adds auto-deploy on save option and support for compilable JS and CSS

I have just released version 3.0 of SPClientSideDeployment with two major enhancements:

  • Auto-deploy on save: when this option is enabled, files will automatically be deployed to SharePoint each time you save them
  • Support for compilable JavaScript and CSS: the tool detects if the file is TypeScript, JSX, LESS or SASS, and if so deploys the compiled output to SharePoint

Download it now!

You can download the latest version of SPClientSideDeployment from the Visual Studio Gallery.

Auto-deploy on save

When this option is enabled, files configured for deployment in DeploymentSettings.xml will be automatically deployed to SharePoint each time they are saved.

To enable this option go to Tools \ Options \ SPClientSideDeployment and set Automatically Deploy on Save to true.

1 Option Menu

Note that this option does not report any error if the file you are saving is not defined in DeploymentSettings.xml. If a file is not being deployed on save as you had expected, then check if the file is correctly configured in DeploymentSettings.xml by explicitly triggering a deployment for the file (i.e. right-click then Deploy to SharePoint).

Support for compilable JavaScript and CSS

You can now specify TypeScript, JSX, LESS and SASS items in DeploymentSettings.xml for deployment. When the tool encounters one of these file types, it will look for and deploy the corresponding compiled output file instead of the actual source file.

For example, if the following was specified in DeploymentSettings.xml:

<File localPath="Scripts.ts">
	<Destinations>
		<Destination targetFolder="Style Library" />
	</Destinations>
</File>

then the tool will look for the file Scripts.js and deploy that to the Style Library. 

“Compilable” items are also supported when the Folder element is used in DeploymentSettings.xml. When processing files in the specified folder, the tool would look for and deploy the corresponding compiled outputs for any detected compilable items. Non-compilable items are processed as normal.

How compiled outputs are inferred

The tool always looks for the compiled output in the same physical location as the source file. The file name of the compiled output is inferred from the file name of the source file.

  • TypeScript source file: example.ts   –   compiled output: example.js
  • JSX source file: example.jsx   –   compiled output: example.js
  • LESS source file: example.less   –   compiled output: example.css
  • SASS source file: example.scss   –   compiled output: example.css

Automatic compilation of compilable JavaScript and CSS

The tool only looks for and deploys the compiled outputs of compilable items. It does not perform any compilation. The tool works best when automatic compilation of these items are enabled in Visual Studio.

For TypeScript, automatic compilation is supported in Visual Studio 2015. By default this is only available for ASP.NET Web Application projects. See this post for enabling it on other project types.

For JSX, LESS and SASS, you can use the Web Compiler extension to enable this.

SPClientSideDeployment’s option to automatically deploy on save works nicely with automatic compilation. If you have enabled this option, then the tool will monitor and automatically deploy the compiled outputs after the compilation has finished.

How compilable items are treated when publishing deployment package

SPClientSideDeployment has a feature that allows you to publish your project as a package for deployment. The package includes a PowerShell script that you can use to deploy the files to a target SharePoint instance. I encourage you to read more about this feature here if you are not already familiar with it.

Support for compilable items has also been added to this feature. When publishing a package, if a compilable item is detected, then only its compiled output would be included in the package. The generated PowerShell script would correctly deploy the compiled outputs to the target SharePoint instance.

Note that the PowerShell script has been updated to include this support. Therefore, if you are updating an existing project to take advantage of this feature, then you’d need to republish the package to regenerate the PowerShell script.

Support for minified version of compiled outputs

Currently there are no supports for minified version of the compiled outputs. This will be added in the next version.

Conclusion

This release aims to further streamline your dev-deploy-test-repeat process and enables you to extend this streamlined approach to compilable JavaScript and CSS. I hope you find the new features useful – and as always, would love to hear from you with feedback and suggestion.

 

Advertisements
Posted in SharePoint, SPClientSideDeployment | Leave a comment

Enabling native TypeScript support in other project types in Visual Studio 2015

Native TypeScript support in Visual Studio 2015 is not available for all project types by default. As far as I’m aware, it is only available for the ASP.NET Web Application project type.

Sometime, you may be working with TypeScript but would prefer to use a different project type, e.g. when you are working with CRM or SharePoint. To add native TypeScript support to a project type of your choice, add the following to the project file:

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" />

Reload your project, go to the project’s properties in Visual Studio and you should now see the TypeScript Build tab.

Posted in CRM, JavaScript, SharePoint | Leave a comment

How to hide custom sub-grid ribbon button in Advanced Find results [CRM]

With RibbonDiff you can add a custom button to the ribbon of a sub-grid. You can further add a display rule to only show this button when the sub-grid is being shown within the form of a particular parent entity type. This is achieved by the FormEntityContextRule. Below is an example RibbonDiff XML to add the “Click Me!!” button and to have it shown only when the sub-grid is being displayed on the new_staff form.

<RibbonDiffXml>
	<CustomActions>
		<CustomAction Id="new.new_staff.Test1.CustomAction" Location="Mscrm.SubGrid.new_staff.MainTab.Management.Controls._children" Sequence="1">
			<CommandUIDefinition>
				<Button Id="new.new_staff.Test1.Button" Command="new.new_staff.Test1.Command" Image32by32="/_imgs/Ribbon/Entity32_8006.png" Image16by16="/_imgs/Ribbon/Entity16_8006.png" LabelText="Click Me!!" Sequence="1" TemplateAlias="o1"/>
			</CommandUIDefinition>
		</CustomAction>
	</CustomActions>
	<CommandDefinitions>
		<CommandDefinition Id="new.new_staff.Test1.Command">
			<EnableRules/>
			<DisplayRules>
				<DisplayRule Id="new.new_staff.DisplayRule.StaffFormOnly"/>
			</DisplayRules>
			<Actions>
				<JavaScriptFunction FunctionName="isNaN" Library="$webresource:new_staff/staff.js"/>
			</Actions>
		</CommandDefinition>
	</CommandDefinitions>
	<RuleDefinitions>
		<TabDisplayRules/>
		<DisplayRules>
			<DisplayRule Id="new.new_staff.DisplayRule.StaffFormOnly">
				<FormEntityContextRule EntityName="new_staff"/>
			</DisplayRule>
		</DisplayRules>
		<EnableRules/>
	</RuleDefinitions>
</RibbonDiffXml>

By default however this button would then also be shown in Advanced Find results. This is because Advanced Find results is essentially treated as a sub-grid.

Sub-grid on the Staff form:

1 Sub-Grid on Form

Advanced Find results:

2 Advanced Find

To hide the button in Advanced Find results, we need to add the Default=”false” attribute to the FormEntityContextRule as below.

<FormEntityContextRule EntityName="new_staff" Default="false"/>

By the way, check out CRMQuickDeploy if you are a CRM ninja that works with RibbonDiff XML directly in Visual Studio and wants to quickly deploy it to CRM.

Posted in CRM | Leave a comment

New version of SPClientSideDeployment adds support for folder-based file deployment and automatic folder creation

I have just released version 2.0 of SPClientSideDeployment with two major enhancements:

  • Folder-based file deployment – this allows you to define a local folder in the DeploymentSettings.xml file. All files under this folder (and its sub-folders) will be processed by the tool.
  • Automatic folder creation – all folders on the target path will now be automatically created by the Visual Studio command.

Download it now!

You can download the latest version of SPClientSideDeployment from the Visual Studio Gallery.

Folder-based file deployment

In previous versions, each file to be deployed needed to be declared individually in the DeploymentSettings.xml file. This can be cumbersome for large projects. In this release you can now use the Folder element to define a local folder to be deployed to SharePoint. All files under this folder (and all of its sub-folders) will be processed by the tool. The schema for this new element is very similar to the File element. Review the inline comment below for more details.

<?xml version="1.0" encoding="utf-8" ?>
<DeploymentSettings>
	<Files>
		<!-- Define local items to be deployed by using a combination of File and Folder elements. -->
		
		
		<File localPath="Script1.js">
			...
		</File>
		<File localPath="Script2.js">
			...
		</File>

		<!-- localPath: Required. Local path of the folder to deploy. Relative to the current project. Value should not start with '/'. Files within this folder and all of its sub-folders will be processed. -->
		<Folder localPath="Scripts">
			<Destinations>
				<!-- Same usage as Destination element for File. targetFileName is not supported when this element is being used for Folder. All files in the local folder will be deployed to the target location using the local file name. The local sub-folder structure will be automatically re-created at the target location. -->
				<Destination targetWeb="" targetFolder="Style Library"/>
			</Destinations>
			
			<!-- Same usage as Metadata element for File. The same metadata will be applied to all files within this folder. -->
			<Metadata>
				<Field name="ContentTypeId" value="0x01010007FF3057"/>
			</Metadata>
		</Folder>
	</Files>
</DeploymentSettings>

The sub-folder structure of the defined local folder will be automatically re-created at the target location. For example, given the Scripts folder and its content below:

      Scripts\utility.js

      Scripts\Search\search.js

and the definition in the DeploymentSettings.xml file:

		<Folder localPath="Scripts">
			<Destinations>
				<Destination targetFolder="Style Library/Intranet"/>
			</Destinations>
		</Folder>

The file utility.js will be deployed to the Style Library, under the Intranet folder. The file search.js will be deployed to the Style Library, under the Intranet/Search folder. The Intranet folder under the Style Library and its Search sub-folder will be created automatically.

Remember to republish your deployment package if you are planning to update your existing DeploymentSettings.xml to use the new Folder element. This is because the DeployFiles.ps1 has been updated to support the new element.

Automatic folder creation

In previous versions, all folders on the target deployment path (specified via the targetFolder attribute) must exist at the target location when using the Visual Studio command. This however was not a requirement when using the PowerShell deployment script generated by the tool (as the script automatically creates any non-existing folder). This release brings the same capability to the Visual Studio command. Any non-existing folder at the target location will now be created automatically by the Visual Studio command, in the same manner as the PowerShell deployment script.

Conclusion

This release brings two major enhancements that aim to simplify your deployment configuration. I hope you find them useful – and as always, would love to hear from you with feedback and suggestion.

 

Posted in SharePoint, SPClientSideDeployment | 1 Comment

CRMQuickDeploy 2.6 adds RibbonDiff deployment from Visual Studio

Rather than storing the ZIP solution in source control, some project teams choose to store the source code of each individual component instead, for example by using the SolutionPackager tool. This allow team members to easily track changes to components at check-in, or to understand how a component was changed over time.

One type of component that may be stored in source control in this way is the RibbonDiff XML for entities. The process of modifying and deploying RibbonDiff is pretty cumbersome though. Natively it involves exporting a solution, modifying the XML and reimporting the solution. The popular Ribbon Workbench automates this process and provides a great UI for editing the XML, but it is rather slow for making small changes – and it also does not help in storing the source code for the RibbonDiff.

CRMQuickDeploy 2.6 adds a feature that allows you to quickly deploy RibbonDiff XML from Visual Studio to CRM for an entity.

1 Deploy Ribbon (1)

Download it now!

You can download the latest version of CRMQuickDeploy from the Visual Studio Gallery.

Accessing the command

This command is accessible by right-clicking on the code editor of the RibbonDiff.xml file, or by the Alt+Q, F shortcut key.

2 Context Menu

Note that this is the same command for deploying web resource. The command determines the current file in the code editor to be a RibbonDiff if its file name is RibbonDiff.xml, and if it is not located under the WebResources folder of the project.

Therefore, to use this command for RibbonDiff deployment, ensure that:

  • The file is named RibbonDiff.xml
  • The file is not located under the WebResources folder of the project, or one of its sub-folders
  • The file is contained in an immediate folder with the name of the target entity (see below)

Specifying target entity for RibbonDiff

The RibbonDiff schema does not contain information about the target entity. The command therefore uses the name of the immediate parent folder of the RibbonDiff file to determine the target entity. If the target entity is new_staff for example, place the RibbonDiff file for this entity directly under a folder named new_staff.

Posted in CRM, CRMQuickDeploy | Leave a comment

New deployment context menu in SPClientSideDeployment 1.2

I have just released version 1.2 of SPClientSideDeployment. This version adds a “Deploy to SharePoint” context menu to files and folders in the Solution Explorer.

1 Context Menu

With this addition, you can now selectively deploy files that you typically don’t open in the code editor, such as images. For folders, this command deploys all files within the selected folder(s) and their sub-folders. Multiple selection of files and folders is supported.

Note that the command is not available for code files (i.e. .CS or .VB files). Selecting files and folders across multiple projects is not supported.

Download it now!

You can download the latest version of SPClientSideDeployment from the Visual Studio Gallery.

Posted in SharePoint, SPClientSideDeployment | Leave a comment

Getting entity type code from CRM UI for an entity

Entity type code for custom entities may be different across environments. Sometime you may need to work out the entity name from an entity type code, for example when CRM throws an error message at you.

Here is a quick way to confirm the entity type code for an entity using the CRM UI:

  1. Open a record of the entity type you’d like to check
  2. Go to the Customize tab and click on Form to launch the form editor
    1 Customise Menu_2
  3. Notice the URL of the form editor. This URL has an etc query string parameter. This is the entity type code for the entity.
    2 Url

The above steps are for CRM 2011 but should also work for later versions of CRM.

This method works best when you have some gut feels of which entity a given code may be for, and of course if you can access a record of the suspecting entity. There are other methods of retrieving entity type codes, such as querying the CRM database, or invoking the RetrieveAllEntitiesRequest against the web service. These other methods however may not be available to you, particularly in environments that are higher than DEV.

Posted in CRM | Leave a comment