title: Custom TFS Check-In Policy in Visual Studio 2017
body: <p>A while ago I developed a custom TFS check-in policy that was <strong>working fine with Visual Studio 2015</strong>.
  Now I installed Visual Studio 2017 and wanted to register the check-in policy assembly the same way as I did with VS2015 before. But this does not work. <strong>How can I register custom check-in policy assemblies with VS2017?</strong></p>
  
  <p>For VS2015, I had these registry keys:</p>
  
  <pre><code>[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\TeamFoundation\SourceControl\Checkin Policies]
  "MyCheckInPolicy"="C:\\Program Files\\My\\MyCheckInPolicy.dll"
  </code></pre>
  
  <p>and</p>
  
  <pre><code>[HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\14.0_Config\TeamFoundation\SourceControl\Checkin Policies]
  "MyCheckInPolicy"="C:\\Program Files\\My\\MyCheckInPolicy.dll"
  </code></pre>
  
  <p>and accordingly I added those keys for VS2017 (<code>15.0</code>):</p>
  
  <pre><code>[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\15.0\TeamFoundation\SourceControl\Checkin Policies]
  "MyCheckInPolicy"="C:\\Program Files\\My\\MyCheckInPolicy.dll"
  [HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\15.0_Config\TeamFoundation\SourceControl\Checkin Policies]
  "MyCheckInPolicy"="C:\\Program Files\\My\\MyCheckInPolicy.dll"
  </code></pre>
  
  <p>But unfortunately this does not work:</p>
  
  <ul>
  <li>If I open the Team Project SourceControl settings, go to the "Check-in Policy" tab and try to <kbd>Add...</kbd> a policy, <code>MyCheckInPolicy</code> <em>does not appear</em><sup>1</sup></li>
  <li>If I open the team project that uses this check-in policy already and do the above, I got an error message telling me that the assembly (<code>mycheckinpolicy</code>) "has not been registered".</li>
  </ul>
  
  <p>Of course I restarted the IDE after the registry change, but even <a href="https://stackoverflow.com/questions/30467624/error-loading-custom-check-in-policy-visual-studio-2015">rebooting</a> my machine did not help.</p>
  
  <p>The <a href="https://www.visualstudio.com/en-us/docs/tfvc/add-check-policies" rel="noreferrer">information</a> I found so far <em>seems</em> to suggest that check-in policies now have to be part of an extension (vsix), which I don't want to believe.</p>
  
  <hr>
  
  <p>I guess that the problem comes from some references that cannot be resolved when the assembly is loaded into the IDE.</p>
  
  <p>The <code>MyCheckInPolicy</code> project references the <code>Microsoft.TeamFoundation.VersionControl.Client.dll</code> v14.0 from the VS2015 folder <code>C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer</code>.<br>
  I tried to reference the respective dll from the VS2017 folders, but then the assembly does not work in <em>both</em> IDEs.</p>
  
  <p>I also tried to use the Nuget package "Microsoft.TeamFoundation.VersionControl.All" v12.0.30723.2 instead and deployed all files from the output directory (which seem to contain all assemblies of the package) to the location mentioned in the registry keys. This had the same result: the policy cannot be loaded in neither VS2015 nor VS2017.</p>
  
  <p>We are using <strong>TFS 12.0.30723.0</strong>.</p>
  
  <hr>
  
  <p><sup>1</sup>So it seems VS2017 doesn't even try to load the assembly and does not care about the registry keys?</p>