tags:

views:

72

answers:

1

I'm having a hell of a time trying to get a custom policy to install on TFS2010 using VSIX.

I have the policy up and running and working fine on my development PC, I have written a value to the registry manually, and the policy is enforced.

The trouble is setting up a VSIX project and deployment to our other development machines.

I followed the instructions in:

http://blogs.msdn.com/b/jimlamb/archive/2010/03/31/how-to-implement-package-and-deploy-custom-check-in-policy-for-tfs-2010.aspx

The preferred method appears to be to use the new VSIX project type in VS 2010, I add a VSIX project to my solution, but the instructions in the blog entry are very vague about what to do next. My understanding is that the PKGDEF file means you do not have write a value to the registry when deploying, and the content of the PKGDEF file is rolled into the config when you start Visual Studio. That's fine, but how do you build up the VSIX package?

I tried adding the custom policy project to the VSIX project as a VS Package type, but when I build I get the error: The target "PkgdefProjectOutputGroup" does not exist in the project.

I have tried adding just the dll, the pkgdef file as a custom content type, etc, but nothing works.

I have changed the PKGDEF file in the blog to match my own project.

When I install the VSIX package on a development machine, I can see the add-in in the Extensions Manager in Visual Studio, but when I check the custom policies in TFS, I get the "is not registered" error.

I really need a step-by-step to setting up a VSIX project to deploy a custom policy, can anyone help?

+1  A: 

The blog post definitely has a missing step. I think what the author intended was that you add the pkgdef file to the VSIX project (via the vsixmanifest editor) as Content of type VS Package. Then, add a project reference to the checkin policy project from your VSIX project (which will cause the checkin policy DLL to be added to your VSIX).

As a side note....when you pick "VS Package" as the content type and then point to a project...it needs to be a proper VS Package project (not just a vanilla C#/VB class library).

Aaron Marten
Aaron, thanks for the info. I tried making the changes you suggested, but I'm still getting the "is not registered" error. If I remove the custom policy from the Check-in policy window in TFS and try to readd it, it does not appear in the list of options. I think the problem hinges on the pkgdef file. It's like the info is not being picked up when I restart Visual Studio.
If I search my C drive for the pkgdef file, the only copies I can see are those in my development folder - you would expect to see this file deployed to a visual studio extensions folder or seomthing right? Am I missing another step? One other question - is the pkgdef file in the article the complete file, or just a snippet? Does the pkgdef file need to be generated with a tool, or can you just copy and paste the code sample and modify it for your own needs?
Ahhh...one step I forgot to mention. Did you set the pkgdef file to Build Action=Content and Include in VSIX = True (Properties window)? You should see it in under %LocalAppData%\Microsoft\VisualStudio\10.0Exp\Extensions when you debug your VSIX. You should be able to just use the snippet from the blog post.
Aaron Marten
Aaron - thanks, yeah, I have those properties set on the pkgdef. After I click on the VSIX package to install it, it installs with no error and I can see it in visual studio extensions. BUT, when I search my C drive for the pkgdef and the dll, they're only in my development folder - should they be copied somewhere by the VSIX on install? If so, how do I instruct the VSIX to do that?
VSIX is just a zip file. If they're in the file, they'll get installed. By default, VS extensions will install to %LocalAppData%\Microsoft\VisualStudio\10.0\Extensions. Do you have a subfolder there with your DLL, pkgdef, and vsixmanifest file(s)?
Aaron Marten
Aaron, no, there is no sign of those files anywhere on my hard drive after I install the extension - and yet the extension shows in the extension manager. It doesn't make much sense!
What is the output of this command (assuming you're running Vista or Win7)?:dir /b/s %LocalAppData%\Microsoft\VisualStudio\10.0\Extensions\*.vsixmanifestYou should see your vsixmanifest file there (and the pkgdef/dll sitting next to it). The only other possible place Extension Manager would be picking it up from would be somewhere under %VSInstallDir%\Common7\IDE\Extensions.
Aaron Marten
Aaron, I get "Cannot find the file specified" for both the directory locations you mentioned. What next?
Aaron, I checked my environment variables, and it doesn't even look like "localappdata" is defined...
If you're on XP, it will be C:\Documents and Settings\<username>\Application Data\Local Settings. It may be a hidden folder.
Aaron Marten
Hey!!! I found it!!! That's weird. I guess because it is a "hidden" folder it didn't show in the search on the C drive I did.OK - to summarise:I now know that the VSIX is installing my extension to C:\Documents and Settings\<username>\Local Settings\Application Data. It appears in the Extension Manager in Visual Studio. When I go to add the custom policy to a source control project in TFS (Right click on project in TFS Team Explorer, Team Project Settings, Source Control, Checkin Policy, Add), the policy does not appear in the list of options. What now?
Assuming you also found a pkgdef (with the matching assembly name of your DLL) there, and that information is being merged into the registry cache after you start VS (HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0_Config\TeamFoundation\SourceControl\Checkin Policies), then you've reached the limit of my knowledge. I'd suggest contacting the author of the blog post for further help with TFS checkin policies.
Aaron Marten
Aaron - Yes, the Pkgdef is in that location, and its name matches the dll file. I start VS, and I do not see the registry key appear in the location you mentioned. Is it supposed to actually physically appear in that location so you can view it with regedit?
Yes. See this post for more information on pkgdef: http://blogs.msdn.com/b/visualstudio/archive/2009/12/18/what-s-a-pkgdef-and-why.aspx
Aaron Marten
Thanks Aaron. I found a useful article at http://blogs.msdn.com/b/visualstudio/archive/2010/03/22/troubleshooting-pkgdef-files.aspx that explains how to log out the pkgdefs that do get loaded when visual studio loads up. It looks like pkgdef wasn't loading because of a syntax error - d'oh! I corrected the error and now everything works!!! Amazing. A tiny syntax error was the cause of all this. Thanks for leading me to the article that helped me find the devenv.exe log file, the solution to the problem was laid bare in the log file. Thank you once again.
Everything's looking good - but I just noticed another little problem. If a user has not installed the extension yet, they get an error message, and the Installtion Instructions are blank - even though I have put instructions into the InstallationInstruction property in the class that inherits from PolicyBase. Any reason why the installation instructions might not show?
To answer my own question... The property to override is InstallationInstructions, not InstallationInstruction... my bad. So yeah, now I'm golden.