How to associate project filetypes with project type in Visual Studio Extension (VSIX)

447 views Asked by At

I'm trying to fix a bug in VsClojure whereby Visual Studio does not recognize a file with the extension .cljproj as a Clojure project. This only happens when VS is not already open; in other words, if you open VS and then open a solution containing a Clojure project, it recognizes the project. But if you open the solution from Explorer or try to open the project itself from Explorer, it says "This project type is not recognized by Visual Studio."

My hunch is that whatever Visual Studio needs to load in order to recognize this project type is not loaded soon enough when opening the project from Explorer, but is loaded when Visual Studio is already up and running. My question, then, what is it that Visual Studio needs to load in order to recognize an extension's project type? And how do I tell Visual Studio to load it?

I've looked through MSDN's VSIX documentation for answers, but there is a ton of documentation to go through, and in what I looked at, I saw nothing pertaining to this question. I've also looked at IronPython's extension, but it seems to be structured completely differently from VsClojure's. Any help would be much appreciated.

1

There are 1 answers

0
Scott Lerch On BEST ANSWER

You must add the project type to the registry so Visual Studio can recognize and load the *.cljproj file. See this MSDN article for details along with this article with all the steps involved when adding a new project type.

Unfortunately you can't make this changes from a VSIX, as MSDN states:

The VSIX format uses strictly file-based deployment and does not support writing to the Global Assembly Cache (GAC), or to the system registry.

Instead you will need to create an MSI installer. In that case pick your MSI creation method. IronPython uses Windows Installer XML (WiX) toolset so you can use that as your example. Here is a snippet from the WiX XML that sets up some of the registry for the project type:

<Component Id="Comp_PyProgRegistration" DiskId="1" Guid="A7BC75A8-F418-4133-8BF9-490A76E99108">
  <RegistryValue Root='HKCR' Key='.pyproj' Type='string' Name='PerceivedType' Value='text' />
  <RegistryValue Root='HKCR' Key='VisualStudio.Launcher.pyproj.10.0\DefaultIcon' Type='string' Value='[IpyToolsInstallDir]PythonProject.ico' />
  <ProgId Id="VisualStudio.Launcher.pyproj.10.0" Description="IronPython Project">
    <Extension Id="pyproj" ContentType="text/plain">
      <Verb Id="OpenPyProj" Command="Open" TargetProperty="VSLAUNCHER" Argument="&quot;%1&quot;"/>
    </Extension>
  </ProgId>
</Component>

Check out the Msi directory under in the IronPython source tree for the full example.