I'm looking to create a custom project system for Visual Studio. But some of the materials online have me somewhat confused. They all refer to VSPackages, and as far as I can tell, these are quite different things from VSIX. My existing extension functionality is offered through a VSIX. Is it impossible to offer a new project type through VSIX?
I also looked at their sample code and it's some hideous COM stuff. Is there no new shiny MEF stuff for projects like there is for extending the editor with syntax highlighting and stuff?
What is MEF? The Managed Extensibility Framework or MEF is a library for creating lightweight, and extensible applications. It allows application developers to discover and use extensions with no configuration required. It also lets extension developers easily encapsulate code and avoid fragile hard dependencies.
The two main types of extensions are VSPackages and MEF extensions. In general, VSPackage extensions are used for extensions that use or extend commands, tool windows, and projects. MEF extensions are used to extend or customize the Visual Studio editor.
Create a new project like we create every other project in Visual Studio. Select File->New->Project Now in the Templates, navigate to Extensibility and select VSIX project. Note that these templates are shown here because we modified Visual Studio configuration to use Visual Studio Extensibility.
The Visual Studio editor can both provide and consume MEF component parts. The MEF is contained in the .NET Framework version 4 System.ComponentModel.Composition.dll assembly. For more information about MEF, see Managed Extensibility Framework (MEF).
VSIX deployment supports VSPackages, assemblies, MEF components, project templates, item templates, toolbox controls, and custom extension types. To use VSIX projects, you must install the Visual Studio SDK. For more information about the Visual Studio SDK, see Visual Studio SDK.
A manifest file (as the name suggests) keeps all the information related to the VSIX project and this file actually can be called a manifest to the extension created in the project. We can clearly see that the "Getting Started" page comes from the index.html file which uses stylesheet.css.
There is no MEF support/API for implementing support for a new project system. There are two ways you could go about implementing support.
I'll assume you are going with option #2.
The MPF library was once part of the Visual Studio SDK, but eventually moved to CodePlex around the time Visual Studio 2010 was released. Rather than use that one, this post will focus on a version of this library that I modified and released on GitHub. This version of the library has many advantages over other previous releases, some of which are documented in the readme that shows when you follow this link.
Managed Package Framework for Visual Studio 2010
To implement support for your language, you'll need to do the following.
Implement command line MSBuild support for your language.
*.targets
necessary for building projects in your language.Create a VSPackage to implement support for your MSBuild project within the IDE. This will allow Visual Studio to open/save/close project files with the extension you chose.
Create one or more "Project templates" to allow users to create a new project for your language within the IDE.
Create one or more "Project Item templates" to allow users to easily add files to the project.
This answer only skims the surface right now, but you've asked a very broad question and unfortunately I don't have time right now to go into detail on all aspects of this.
Edit: Regarding deployment - you can and should include your VSPackage inside of a VSIX. However, since your extension will need to install MSBuild extensions in a location that user projects have standard access to (C:\Program Files\MSBuild
or C:\Program Files (x86)\MSBuild
), you'll have to wrap the whole thing in an installer to provide a custom installation. I recommend using WiX for this; it's not trivial but it's free, works exceptionally and reliably well, and isn't too challenging to use once you get the hang of it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With