Introduction

ZeroDeploy Developer is a tool designed to improve the Sitecore development process by reducing the
number of times the Sitecore development environment restarts. Normally, everytime you push new
compiled code to Sitecore, the IIS Application Domain reloads itself. This process can take a while even
on a fast computer and a clean environment. ZeroDeploy Developer prevents Sitecore from restarting
every time compiled code changes.

This blog helps the developer setup ZeroDeploy Developer in their local environment and shows
some strategies that will help the Sitecore Developer get the most out of ZeroDeploy Developer.

Requirements
ZeroDeploy is designed to work on Sitecore 8.2 and later. The Visual Studio component of ZeroDeploy can only be installed on Visual Studio 2015 and 2017.

Getting Started:

Step 1:

  1. Click on https://www.teamdevelopmentforsitecore.com/Zero-Deploy-Beta link, sign in with Verndale credentials. You can download ZeroDeploy zip folder and you will also receive an email from Hedgehog, which has the trial key.
      2.  Unzip the folder and double click on Hedgehog.ZeroDeploy.VSAddin.vsix to install it on VS 2015 and above.

 Step 2: Zero Deploy setup for nuget

  1. Copy all *.nupkg files from the ZeroDeploy zip file to a local location (eg. C:\Projects\ZeroDeployBeta\)
  2. Create a nuget.config to the root of your solution (next to your *.sln file)
  3. Update the nuget.config file with the following code. In line number 4, the path should be the location of your ZeroDeployBeta nuget packages:
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <packageSources>
        <add key="Zero Deploy Beta" value="C:\Projects\ZeroDeployBeta" />
      </packageSources>
      <activePackageSource>
        <add key="All" value="(Aggregate source)" />
      </activePackageSource>
    </configuration>

  4. Open the solution. Right click on the main website project, usually located inside the Common folder and then select “Manage NuGet Packages…”
  5. Change to the “Zero Deploy Beta” package source in the top right dropdown control, and switch to the Browse tab in the top left:                                                                                                              
  6. Select the Hedgehog.ZeroDeploy.Build package and install it.
  7. Right click on the *.Website project located inside the Common folder, you should be able to see Zero Deploy tab, as shown below:

Step 3: Changes on Sitecore

ASP.Net has a feature to recycle the application pool automatically if it re-compiles too many views. This prevents memory leaks in a production environment due to obsolete view assemblies being held in memory. This is less of an issue in local development, and since ZeroDeploy allows you to make many changes to your assemblies without a recycle, this behavior is not desirable.
Setting the attribute numRecompilesBeforeAppRestart on the system.web/compilation element to a large number prevents .Net from recycling after a few View updates.
  1. Update Sitecore's web.config as shown: 
    <compilation defaultLanguage="c#" debug="false" targetFramework="4.5.2" numRecompilesBeforeAppRestart="200">
     <assemblies>
      ....
     </assemblies>
    </compilation>

  2. Add ZeroDeploy components to your Sitecore instance:
    Go to <website url>/sitecore/admin/UpdateInstallationWizard.aspx, select the Hedgehon.ZeroDeploy1.0.0.12.update file (which is in ZeroDeploy zip folder), and install it.

Step 4: Changes to the Solution for the main project :

  1. Create a new solution configuration:
    Click on Build->Configuration Manager


  2. In Active Solution Configuration, select New

  3. Create a new configuration as shown below

  4. In the configuration drop down, select the Zerodeploy

  5. Create a Conditional Compilation Symbol called ZERO_DEPLOY in Web Application project properties

  6. Select the Zero Deploy property tab and fill the fields with respect to your project

    Click on View License add your trial key.
  7. Update Properties/ApplicationInfo.cs as shown below
    [assembly: AssemblyFileVersion("1.0.0.0")]
    #if ZERO_DEPLOY
    [assembly: AssemblyVersion("1.0.*")]
    [assembly: Hedgehog.ZeroDeploy.Client.Attributes.ZeroDeployAssembly]
    #else
    [assembly: AssemblyVersion("1.0.0.0")]
    #endif 
  8. Build the project once.
  9. In your Sitecore instance, you should get your *.Website assembly under ZeroDeploy item, as shown below:

  10. Delete the ZeroDeploy assemblies from /bin folder of the main website project as shown:

         

Step 5: Changes to the Solution for  Adding additional assemblies to ZeroDeploy



  1. Add the Hedgehog.ZeroDeploy.Client NuGet package to the project you want to add ZeroDeploy support.
  2. Make the changes to the Properties/ApplicationInfo.cs file:
    [assembly: AssemblyFileVersion("1.0.0.0")]
    #if ZERO_DEPLOY
    [assembly: AssemblyVersion("1.0.*")]
    [assembly: Hedgehog.ZeroDeploy.Client.Attributes.ZeroDeployAssembly]
    #else
    [assembly: AssemblyVersion("1.0.0.0")]
    #endif
  3. Build the project. ZeroDeploy build process will push the assembly to your Sitecore instance. You should get a similar message in the output window:

  4. Test your Sitecore instance. You should get the assembly in your sitecore, under Zero deploy tab, as shown

  5. Delete the ZeroDeploy assemblies from /bin folder of the project as shown:

Usage

Work on your solution as usually. Every time you need to test a change that was made to a project, just build the project; the build process will copy the updated assembly to Sitecore and will automatically load it.Then you can test your changes in Sitecore.
From some quick tests we made: it takes about 3 minutes to get Sitecore up after a change in an assembly, after doing the same change with ZeroDeploy enabled, Sitecore is up in 10 seconds.

Known Limitations

  • Currently ZeroDeploy has no integrations made with TDS, that means that TDS projects have to be removed from the Build options when using ZeroDeploy configuration:

    But this also means the changes made to Views or configuration files will not be moved to Sitecore during a build. Hedgehog's solution to this problem is to use gulp to automatically move these files when they have been modified.
    Additionally, please know that updating a configuration file will also cause the AppPool to restart, breaking ZeroDeploy functionality.

Comments

Post a Comment