Do, Recognise, Codify.
This philosophy is at the very core of what we do at endjin so we decided to share the knowledge with the community by releasing, with an open source license, a series of tools and framework under the umbrella of “Work Smarter, Not Harder”.
The first tool is called Templify and it aims to solve one simple problem and solve it well:
Every project starts the same way,
You create a place to put Solution Artefacts
On one file system
On one computer
That’s it. It’s a simple problem. It’s a process that developers all over the world will do hundreds of thousands of times a day. The real issue is that it’s a wasteful process. Within the Microsoft ecosystem – it’s a problem that really hasn’t been solved because Microsoft (and in particular Visual Studio) believes that the story starts and ends within the IDE. You create a Project which automatically creates a wrapping solution – but you have no control over the solution structure. A new Visual Studio solution doesn’t take into account best practices such as a branchable folder structure or how best to organise your referenced assemblies, where your automated build process should be located, or which oft reusable frameworks and tools you use in every project.
Templify elegantly solves the problem by recognising where the process actually starts – inside Windows Explorer. Templify has two modes – Create and Deploy. In Create mode you can take a pre-existing solution and turn it into a deployable template. You do this by first installing Templify, then navigating to the parent folder of the solution you want to Templify inside Windows Explorer. In the following example we are using the default assets from Sharp Architecture 1.6:
Next, right click on the folder and display the context menu. Select the “Templify This Folder” option:
This will launch the Templify UI, which will ask you to fill in the following details:
In the token field you should enter the repeating token (the top namespace identifier) that will be replaced with a new value when the package will be deployed. In the sample above the repeating token is “SA169” which is the top level namespace and solution name used within Sharp Architecture 1.6. Templify UI is built using Caliburn Micro and takes advantage of the convention based databinding and validation within that framework. For example until you enter values in all the required fields the “Templify” button will be disabled:
But once you have entered a valid version number the “Templify” button is now enabled:
The create screen also allows you to manage which files and folders you want to exclude from the template package creation process – for example you would not like StyleCop.Cache files, .User files or bin and obj folders being included in your template as these are temporary build artefacts – or Git / SVN versioning folders.
Once you have entered all your settings you can click the “Templify” button and the templification process will begin. Progress is displayed via a progress bar and a status message telling which step is occurring:
Templify has the following steps:
Build Package File Manifest, Build Package, Clone Package, Tokenise Package Contents, Tokenise Package Structure, Creating Package Archive, Clean Up Temporary Files.
When the solution has been templified and turned into a package a toast will appear notifying you that the process has been successful. Packages are created at the following location:
Packages are created using the wonderful 7Zip format but with an extension changed to .pkg. If you want to peek inside a package simply open it with 7Zip.
The second mode Templify supports is Deploy mode. In Windows Explorer, select an empty folder that you want to deploy your template to. Right click on the folder and select “Templify Here”
This will spawn a new instance of Templify that knows about the folder you just highlighted. It will ask you to select a template and to enter the new name of your solution:
By default Templify ships with Sharp Architecture 1.6:
Again using Caliburn Micro’s convention based validation – the deploy button is disabled until you complete all the fields:
This screen also allows you to manage existing packages – by clicking on the “Manage Templates” button – which will spawn a dialog that will allow you to delete any of the packages within the repository
Once you’ve clicked “Deploy Template” a progress bar will appear showing the progress of the steps Templify is going through to deploy the package (which are essentially the reverse of the Create mode):
Extract Files From Package, Tokenise Package Structure, Tokenise Package Contents, Clean Up Temporary Files.
Once the package has been successfully deployed another toast will appear to notify you.
And now you should be up and running with a complete customised version of your template, which contains an automated build, referenced assemblies, projects etc.
In future posts we’ll cover using Templify from the command line, how you can integrate it into your CI process to automatically create a package as a build artefact.
Hopefully Templify will help you Work Smarter, Not Harder.