Posts tagged ‘packages’

Chocolatey

I played with Chocolatey today, I figured lets create an package to setup a development machine. Add handy packages that you might want starting out on a new machine. This is handy as well when you have a new developer joining your team, you can set them up with some common tools.

First create the spec file as below

<?xml version=“1.0”?>
<package>
  <metadata>
    <id>SoftwareCreations.devset</id>
    <title>SoftwareCreations.devset</title>
    <version>0.09</version>
    <authors>Orn Kristjansson</authors>
    <summary>Software Creations, installs dev tools.</summary>
    <owners>Orn Kristjansson</owners>
    <description>Installs handy development tools.</description>
    <projectUrl>https://github.com/ornatwork/</projectUrl>
    <tags>SoftwareCreations devset tools development</tags>
    <copyright>Software Creations</copyright>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <iconUrl>http://kristjansson.us/favicon.ico</iconUrl>
    <dependencies>
      <dependency id=“fiddler” />
      <dependency id=“filezilla” />
      <dependency id=“winrar” />
      <dependency id=“sublime” />
      <dependency id=“gimp” />
      <dependency id=“dotpeek” />
      <dependency id=“grepwin” />
      <dependency id=“skype” />
      <dependency id=“testdriven.net” />
      <dependency id=“MagicDisc” />
      <dependency id=“winmerge” />
      <dependency id=“tortoisesvn” />
      <dependency id=“TortoiseGit” />
      <dependency id=“windowstelnet” />
    </dependencies>
    <releaseNotes>
    </releaseNotes>
  </metadata>
  <files>
    <file src=“tools\**” target=“tools” />
    <file src=“content\**” target=“content” />
  </files>
</package>

For this spec I have only dependencies which means I’m not really installing anything myself. Rather pulling and installing the dependencies. As such there is a /tool directory that has a PowerScript file that doesn’t do anything. Secondly since some of these packages have /content directory that needs to be created as well. If not an error will be thrown when the package is run ( that’s a bug ). There for I just put fake.txt file in that directory that is enough to get around the error.

My source can be found on GitHub

Since I don’t like doing tasks by hand that can be automated I created a nant script to create the package and push it up on the Chocolatey server. When I make a change to the package I save it and then on the command line just run the nant script.

For example
> nant -D:version=0.10

<?xml version=“1.0”?>

<!– Chocolatey fun –>
<project name = “SofwareCreateions.devset”
                 default = “PackAndDeploy”
                 basedir=“.”>

  <!–  Register the sys.* properties; most specifically, sys.env.* for all environment vars   –>
  <sysinfo failonerror=“false” />

  <!– The version number for the package –>
  <property name=“version” value=“0.01” dynamic=“true” overwrite=“true” />
  <property name=“BuildDrive” value=“${string::substring(project::get-base-directory(), 0, 1)}”  dynamic=“true” />
  <property name=“path.base.drive” value=“${BuildDrive}:\” />
  <property name=”cmdChocolateyPath” value=”${path.base.drive}\Chocolatey\bin\” />
  <property name=”cmdChocolatey” value=”chocolatey.bat” />
  <property name=”nugetFile” value=”softwarecreations.devset” />

  <!– This is the main / default target –>
  <target name=”PackAndDeploy” depends=”Start, UpdateVersion, Package, Deploy“>
    <echo message=”Done !“/>
  </target>

  <!– Individual targets below, those should NOT have any dependancies –>
  <target name=”Start” >
    <echo message=”*** Version number=${version} “/>

  </target>

  <!– Update version number –>
  <target name=”UpdateVersion” description=”Update version files to the current version being built.”  >
   
    <echo message=”*** Start updateVersions: ver=${version}“/>
   
    <!– Update NuGet package version –>
    <xmlpoke file=”softwarecreations.devset.nuspec” xpath=”/package/metadata/version” value=”${version}” />

  </target>

  <!– Package –>
  <target name=”Package“>
    <echo message=”Start Package:“/>

    <echo message=”Push to Nuget feed:“/>
    <!– Deploy to Nuget Gallery –>
    <exec program=”${cmdChocolateyPath}${cmdChocolatey}” verbose=”true
          commandline=”
pack ${nugetFile}.nuspec“/>
   
  </target>

  <!– Deploy –>
  <target name=”Deploy“>
    <echo message=”Start Deploy:“/>
   
    <exec program=”${cmdChocolateyPath}${cmdChocolatey}” verbose=”true
          commandline=”
push ${nugetFile}.${version}.nupkg“/>
   
  </target>

</project>

My package and it’s content can be found here If your have Chocolatey installed you can run it from the command line, like so.

> cinst SoftwareCreations.devset

Chocolatey is like apt-get on the Linux box, when you start using it its hard to go back to the manual search – webpage – download – install routine. There are only about 1200+ packages available at this point but that will grow going forward for sure.