Terje Sandstrom

------ Chief Software Geek at Inmeta Consulting in Scandinavia ----- and a Visual Studio ALM MVP

  Home  |   Contact  |   Syndication    |   Login
  59 Posts | 1 Stories | 97 Comments | 0 Trackbacks

News

Subscribe

Delicious Save this on Delicious Visual Studio Feeds

¨

Tag Cloud


Article Categories

Archives

Post Categories

Image Galleries

Company stuff

Interesting bloggers

Interesting companies

Microsoft

Microsoft Norge

Microsoft Regional Directors

Microsoft Test

MSFT Blogs

MVP

NNUG

Other interesting stuff

TFS

Visual Studio

Saturday, March 10, 2012 #

Deployment of custom checkin policies can be done using either an MSI or VSIX.  There are many reasons to prefer using the VSIX format. It is more lightweight, and thus more suitable for small components for VS, as it will not “pollute” the installed programs store. Further, since the Visual Studio setup projects have been cut from Visual Studio 11, the VSIX is a better choice, being supported both in VS 2010 and VS 11.  VSIX is also very easy to create, once you know how, and it is very fast running too.

Jim Lamb had an excellent blog post about how to implement, package and deploy custom checkin policies using VSIX. Unfortunately that post lacks some details.  Aaron Marten found some of the issues here.  I have gone through both of these and in this blog post I will show the details of how you can package this in a VSIX.

Jim Lambs post fully explains how to implement a custom policy, so I will not go through that again.

In order to package it in a VSIX, follow the steps below:

  1. Install the Visual Studio SDK.  The SDK has the project templates for the VSIX
    1. Visual Studio 2010 SDK:  http://www.microsoft.com/download/en/details.aspx?id=2680 
    2. Visual Studio 11 SDK:  http://www.microsoft.com/download/en/details.aspx?id=28990 
    3. When you install the SDK, you get a new set of Project items under the folder “Extensibility” (1 in figure below)
  2. Add a VSIX project to the solution with your custom checkin policy
    1. SNAGHTML9e57448
    2.   Choose the VSIX Project type (2).
  3. In the VSIX project add a reference to your custom checkin policy project
    1. image
  4. You then should add some items to the project, but only one of these is mandatory:
    1. image
    2. Item #1 is an icon bitmap.  Nice to have, but optional
    3. Item #2 is a license text document. Nice to have, but optional
    4. Item #3 is a package definition file. This is mandatory, and contains instructions for setting up a registry key. This registry key is needed by Visual Studio in order to find and load the checkin policies.
      1. You just add a text file, and name it policies.pkgdef.  The name can be anything, but the extension should be “pkgdef”.
  5. Edit the policies.pkgdef to look like this:
    1. [$RootKey$\TeamFoundation\SourceControl\Checkin Policies]
      "Inmeta.TFS.CheckinPolicies"="$PackageFolder$\Inmeta.TFS.CheckinPolicies.dll"     (Copy paste from this)
      image
      Part 1:  This is a name you choose to give your policy package, and which will be the name of the key in the registry 
      Part 2:  This is the assembly name as defined in the project properties, Application/Assembly name field. image
  6. At last you have to set up the vsixmanifest file, the one named source.extension.vsixmanifest.  In VS 2010 there is an editor for that file, but in VS 11 Beta the editor is not there, and you must edit the file yourself. It can be an easy way out to make it first in VS 2010, and then open it up afterwards in VS 11.  The whole VSIX project will then be upgraded to the VSIX format for VS 11.
    1. VS2010:  Using the editor to set up the manifest

image

1) When you update your checkin policy, increment the version number too.  This will make the VSIX updateable.

2) Select the Visual Studio editions the VSIX shall apply for.  You only need to set the lowest SKU, all above are automatically allowed.

SNAGHTMLa280755

3) You have to add the policies.pkgdef file as Content to the manifest.

SNAGHTMLa265fe0

4) The result of the Add Content operation in 3).

5) These fields are optional. The License Terms is the name of a text or rtf file. Add one to the project and name it here. The Icons and Preview Image’s can be added, any bitmap file will do. The icon must have the right size of course. The URL field and Getting started guide can be filled in as one likes.

Now, for VS 11, the manifest must be edited as an XML file:

<?xml version="1.0" encoding="utf-8"?>
<Vsix xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2010">
  <Identifier Id="Inmeta.CheckinPolicies11.VSIX..69ec79aa-3c86-492e-b440-decf901288e4">
    <Name>Inmeta.CheckinPolicies11.VSIX</Name>
    <Author>Inmeta Consulting AS</Author>
    <Version>1.437</Version>
    <Description xml:space="preserve">Inmeta Checkin Policies for Visual Studio 11</Description>
    <Locale>1033</Locale>
    <MoreInfoUrl>http://intranet.osiris.no/knowledge/Wiki%20Pages/OCPChangeLog.aspx</MoreInfoUrl>
    <License>License.txt</License>
    <Icon>ICP.bmp</Icon>
    <SupportedProducts>
      <VisualStudio Version="11.0">
        <Edition>Pro</Edition>
      </VisualStudio>
    </SupportedProducts>
    <SupportedFrameworkRuntimeEdition MinVersion="4.0" MaxVersion="4.0" />
  </Identifier>
  <References />
  <Content>
    <VsPackage>policies.pkgdef</VsPackage>
  </Content>
</Vsix>

Note that you must change the Visual Studio version attribute to read “11.0”.  Otherwise the rest of the fields should be easily understandable from the editor description above.

 

Finishing it: 

This is all you need to do. Compile it, and install the VSIX by double-clicking it. Note that it first takes effect when you restart Visual Studio.

 

Notes:

When you port your checkin policies from VS 2010 to VS 11, be aware that you change the references from pointing to the VS 2010 assemblies to point to the new VS 11 assemblies.

In our case we had these assemblies:

image

You may have more or less than these, dependent upon what kind of custom checkin policies you have made.

Also note that one checkin project can contain many checkin policies.  Our package contains these:

image

 

There are guidelines on the net on how to use assembly binding redirection to make VS 11 use VS 2010 assemblies.  This is also a way to go, but I prefer to convert them to VS 11 proper.