7 Zip exclude multiple files and directories

Adds to the archive.7z all files from Folder1 and its subfolders, except *.png files.

7z a archive.7z Folder1\ -xr!*.png

To exclude the list of directories and files, you can first store the items in a text file separated by new line for each, then run the following command

7z.exe a -t7z archive.7z C:\Project\Solution1 -xr@exclusionList.txt

a – Add to archive

-t7z – type of archive, in this example, it uses 7z

-xr@ – specify the exclusion list.

Happy Coding!

Sitecore – Add missing icons for specific media types

Recently, I was trying to save the PDF file in the media library and found this issue. The PDF file used empty icon instead.

Luckily, this seems a common issue and solution can be easily googling out.

Sitecore has official document in its knowledge base about this issue.

Missing icons for specific media types

What I want to point out is if you search this issue from google, you will be very likely found some other blog posts provide the similar approach, the only difference comparing to Sitecore official document is the type specified in the generator.

<generator type="Sitecore.Resources.Media.MediaThumbnailGenerator, Sitecore.Kernel">

The type seems redundant or causing icon failed to be displayed in my current Sitecore v8.0 update 3.

Below is my patch config instead of modifying the web.config

<mediaType name="PDF file" extensions="pdf" patch:before="*[@name='AVI video']" >

Happy coding 🙂



Sitecore – Reader is in incorrect state

My demo app came up with this issue after making some changes to patch config file today.

Reader is in incorrect state
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Exception: Reader is in incorrect state

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:
[Exception: Reader is in incorrect state]
Sitecore.Xml.Patch.XmlReaderSource..ctor(XmlReader reader, String sourceName) +123
Sitecore.Configuration.ConfigPatcher.GetXmlElement(XmlReader reader, String sourceName) +45
Sitecore.Configuration.ConfigPatcher.ApplyPatch(TextReader patch, String sourceName) +138
Sitecore.Configuration.ConfigPatcher.ApplyPatch(String filename) +93
Sitecore.Configuration.ConfigReader.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +177

This is a weird issue at the first glance, I still have no idea what happened under the hood, though I solved the problem.

I added a comment in my patch config which is in between and section, this is the fundamental cause.

To fix this YSOD, simply move the comment anywhere within section.

Happy coding 🙂

Jenkins 2.0 Set Up on OSX


  • JAVA JDK 7 or above
  • GIT
  • MAVEN 3 or above

Install Jenkins

  • Install jenkins via homebrew
  • brew update &amp;&amp; brew install jenkins

Starting Jenkins

After Jenkins is installed successfully, follow the instructions to start Jenkins on login

ln -sfv /usr/local/opt/jenkins/*.plist ~/Library/LaunchAgents

If you want to configure Jenkins to launch on system startup, for all users on OS X, then copy the plist file to the system Launchd location instead

$ sudo cp -fv /usr/local/opt/jenkins/*.plist /Library/LaunchDaemons

$ sudo chown `whoami` /Library/LaunchDaemons/homebrew.mxcl.jenkins.plist

You can always start Jenkins manually with

$ /usr/local/bin/jenkins

or if you have set up your PATH correctly when installing Homebrew, simply

$ jenkins

Starting Jenkins as service

Start service

brew services start jenkins

Stop service

brew services stop jenkins

Restart service

brew services restart jenkins

Restarting Jenkins

If you have an older version of Jenkins and you are upgrading it, then you can restart it this way:

$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist

$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist

Install Jenkins Plugins

  • Git
  • Maven
  • Parameterized Trigger Plugin (This plugin will simplify the maven profile configuration)
  • JUnit
  • PMD / FindBugs / Checkstyle (For quality analysis)
  • Greenball

Configure Jenkins

Go to Manage Jenkins -&gt; Global Tool Configuration, configure the following sections


  • Deselect Intall automatically as we will use the installed JDK
  • Fill the JDK Name E.g. JDK 1.7
  • Specify the JAVA_HOME path. E.g. /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home


  • Deselect Intall automatically as we will use the installed Maven
  • Fill the Maven Name E.g. Maven 3
  • Specify the MAVEN_HOME path. E.g. /usr/local/opt/maven31/libexec


Git intallation should be picked up by default, unless you install GIT after Jekins.

Set Up Job

  1. Create new maven project by giving a new.
  2. Go to Source Code Management sections, add repositories link.
  3. If you want to use SSH, click Add button in Credentials section. In the dialog, choose SSH Username with private key option, then select From the jenkins master ./ssh, Note: Dont put any value into Username
  4. Click Build Now to test the job.




Installing Jenkins OS X Homebrew


Maven doesn’t have a ‘lib’ subdirectory in Jenkins



The ‘lib’ folder should be linking to libexec subdirectory.

If you install your maven via homebrew, your maven home should /usr/local/opt/maven31/libexec. (Note: maven31 is the version I installed on my mac, change this according to your local setting.)

Jenkins CI on OSX


Uninstall Jenkins

Execute uninstall script from terminal:

'/Library/Application Support/Jenkins/Uninstall.command'

Set up EPiServer CMS + Commerce in 11 steps

Believe or not, it’s super easy to set up an empty CMS site with Commerce package in version 9. Thanks for the EPi team awesome work.


  • Visual Studio 2013/2015
  • Windows 8 above (At least, you will need to have localdb installed.)
  • EPiServer CMS VSIX. (You can install within Visual Studio Extension Manager or download from here)

Let’s start


  1. Use EPiServer VSIX template to set up an empty CMS project.
  2. Install package “EPiServer.Commerce.UI.ManagerIntegration”  via nuget package console.
  3. UPDATE ALL EPiServer packages.
  4. Install package “EPiServer.Commerce”
  5. Run cmdlet “update-epidatabase”  via nuget package console.
  6. Change local database location – Move database to db folders.
    In this demo, I placed the db out side of the CMS directory, and put it in the solution root directory.

    static EPiServerApplication()
    System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"\..\db\");
    AppDomain.CurrentDomain.SetData("DataDirectory", dir.FullName);
  7. Login to CMS administrative interface with default username : admin and password : store, then “execute all remaining steps” to run the migration


  1. Create an empty Mvc application with Visual Studio (Framework > 4.5.2)
  2. Install the nuget package “Episerver.CommerceManager”.
  3. Show all files and include App_Data,App_GlobalResources,Apps, NotificationTemplates folders and Default,Global.asax files.
  4. Make sure “CommerceManagerLink” in CMS is pointing to commerce manager url.
    <add key="CommerceManagerLink" value="http://localhost:{port}/" />

It’s the end, and that’s all you need to do for the setup. Enjoy your EPi development.

Uploading files will fail after ~7MB when using Windows 2008, over SSL, via a load balancer

One of the client recently encountered this issue with EPiServer CMS.

It’s very frastructing issue, my workmates spent lots of time looking from the EPiServer side, this is our perception as EPiServer had more bugs than Microsoft. However, this time we are wrong 🙂

Thanks for all my workmates hard work.

Hot-fix can be downloaded from here : https://support.microsoft.com/en-us/kb/2634328