Creating Visual Studio project system with MEF and VSIX - c#

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?

There is no MEF support/API for implementing support for a new project system. There are two ways you could go about implementing support.
Implement the Visual Studio API directly. This option is extremely complicated, but does not limit you to a particular build system or file format. If you choose this, you are basically on your own.
Use the Managed Package Framework (MPF) library as a starting point. This option is much easier, as long as you are restricted to using MSBuild for your project format and build system.
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.
Create a project file.
Create one or more MSBuild *.targets necessary for building projects in your language.
This will likely involve creating an assembly to hold custom build tasks as well.
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.

Unfortunately, Visual Studio API is really ugly. If you’ll make a deep integration with internal mechanisms of Visual Studio, you’ll have to use “hideous COM”. Directly or through managed wrappers (Interop Assemblies). To avoid confusion I try to explain concepts of Visual Studio Extensibility and post useful links to documentation. Hope it will help you.
You can extend Visual Studio by using macros, add-ins, VSPackages, and Managed Extensibility Framework (MEF) extensions. Starting with Visual Studio 2012, Visual Studio Extensions no longer supports macros! However, use VSPackages provide more opportunities. For more details see
MSDN: Walkthrough: Creating a VSPackage
MSDN: Creating Add-ins and Wizards
MSDN: Get Started with Extending Visual Studio
MSDN: Inside the Visual Studio SDK
MSDN: Developing Visual Studio Extensions
Starting with Visual Studio 2010, you can use MEF to customize the Visual Studio editor only. However, you can combine a MEF extension with a VSPackage. How to do it you can read the following links.
MSDN: Getting Started with Editor Extensions
MSDN: Managed Extensibility Framework in the Editor
In my opinion the use of MEF has minor advantages.
To create a custom project type for Visual Studio you should use Visual Studio Templates. This is technology separate from VSPackage and another extended methods. It allow Visual Studio to support new type of projects and add new project wizard.
MSDN: Creating Visual Studio Templates
CodePlex: Multi-Project Templates with Wizard: Visual Studio 2010 Sample
To distribute the package you can use VSIX or MSI files. Any of them can contain VSPackage, Visual Studio Templates, dependent libraries, icons, configuration files, etc. VSIX and MSI installers supported visualstudiogallery portal. However, Visual Studio can automatically update only VSIX file from the visualstudiogallery.
Visual Studio Blog: VSIX and MSI
MSDN: VSIX Deployment
MSDN: How to: Prepare Extensions for Windows Installer Deployment
Visual Studio Blog: VSIX Best Practices
By default, VSIX (as deployment package) and VSPackage (as start point of plugin) are in the same project, but you can divide into different projects or use msi instead vsix.

Related

How to create a setup for c# program?

I have read similar questions on SO and other forums but can't what I want. I have obfuscated my binaries using 3rd party tools, and want to use these binaries in the setup.
Visual Studio Installer lets us choose the projects we want to deploy, and creates the installer using the outputs of those projects.
WiX creates a setup using the files I want but does not have an option to install .NET framework, if it doesn't already exists.
Is there a way I can use my own assemblies in Visual Studio Installer ? Or a similar alternative ?
EDIT:
I have already packed all dependencies in the binary. I don't want the installer to find the dependencies for linking them. I just want it to install .net (if not already installed) and place the binaries in a directory.
Not exactly the answer you'd hope for, but you mentioned WIX and dependency to .net framework. For that reason people write bootstrappers (i.e. a binary compiled to native win32) using something like Autoit which makes sure of the framework. All you may have to do is read registry key of corresponding framework and if required it pull down the file and install. Then execute the msi !
You can use the good old Visual Studio Setup Project (Installer Project) template.
To do so, you need to download the Microsoft Visual Studio Installer Projects depending to your VS version from one of the following links:
Microsoft Visual Studio Installer Projects 2013
Microsoft Visual Studio Installer Projects 2015
Microsoft Visual Studio Installer Projects 2017 and 2019
Microsoft Visual Studio Installer Projects 2022
The project could be used to deploy anything, including your project or instead of adding Project Output you can simply right click on your setup project node in solution explorer and under Add menu, add File or Assembly.
Then all dependencies will be added automatically. You can also add other files and artifacts that you need to be installed on target machine.

How to create Setup file of windows application without using InstallShield in visual studio 2013?

I have developed a windows application (one type of CRM System) but now I want to create its setup file so it can be easily installed on client's machine. I have searched online and found out the way using InstallShield. But it is giving the free trial and then it is offering the paid version. Is there any other way to create Setup file without using InstallShield?
You can use the extension Visual Studio Installer Projects Extension: VSI_Bundle.
See the The Visual Studio Blog
It worked good for me.
See my answer in this post: https://stackoverflow.com/a/28029063/200824
You can use visual studio 2015 and install installer projects extension.
You should also take a look at https://wixtoolset.org. A lot of new, helpful elements (grammar is XML) were added to simplify development. So while it's not drag-and-drop design, it's fairly easy to use and 3.x builds MSIs that are still the mainstay on Windows. 4.x pre-releases can also build other formats such as AppX (though, that is only supported on Windows 10 to install).

Use WIX without visual studio

I am trying to create installer of my c# application.
I found that installer can be created using Visual Studio but not using express edition.
So i wanted some free tool.
So i tried to use WIX but i found it also needed to integrate with visual studio and visual studio 2010 express do not allow to extend it.
I found following link but unable to work because i am having visual studio 2010 express.
http://wixtoolset.org/documentation/manual/v3/votive/authoring_first_votive_project.html
So is there any way how to use WIX without visual studio?
And directions how to use WIX?
I am creating installer first time so i am new to this.
Thanks for support.
You don't need Visual Studio to create Wix projects you can use any editor (Notepad) of your choice it's just that you will miss IntelliSense and building from within VS. I believe you can still use VS to edit .wxs/.wxi (xml) files.
To build you just need Wix Toolset and MSbuild (.net).
Working with MSBuild documentation: http://wixtoolset.org/documentation/manual/v3/msbuild/
See if WiX edit works for you:
http://wixedit.sourceforge.net/
and WiXAware may be an option, if it's still available, do your research first:
http://www.installaware.com/news-installaware-wixaware-200.htm
SharpDevelop is an IDE that supports WiX projects in a way similar to Visual Studio.
Ultimately, WiX source files are schema-validated XML so any good XML editor with syntax highlighting and schema-based editing assistance would work. WiX tools can be run directly on the command-line but WiX projects are generally more convenient. WiX projects are Visual Studio projects that are MSBuild projects. As with WiX source files, MSBuild project files are XML. The WiX installer and/or zip distribution provides MSBuild targets and tasks that call the WiX tools during a build with MSBuild, Visual Studio or SharpDevelop.
When learning WiX, do keep in mind that it is a tool to build Windows Installer packages from an abstract declaration. Go to the Windows Installer documentation for conceptual information and WiX documentation for how to implement the concepts. You'll then see how much simpler WiX is. However, compared to other installer tools, WiX is not simple-but it doesn't limit you, either.

MSI upgrade using Visual Studio 2010

I have a solution with .NET projects and a setup project(Visual Studio Installer 2010). My previous version of the same project was 1.7.9 and the new version is 1.8.4. I also create a shortcut on the desktop to one application in my MSI. I changed all the versions in the assemblyinfo.cs and also changed the product version in the Setup Project, the product code got changed automatically and the upgrade code is the same. The problem I'm facing is that the Targetdir is updated with 1.8.4 files. But on the desktop I see 2 shortcuts (1.7.9 & 1.8.4) and in control panel I see two versions of the same application. I have set the RemovePreviousVersion flag to true and also set the DetectNewerVersion to true. Can someone please help me out with this? After changing the assemblyinfo file why isn't it upgrading properly?
Visual Studio Setup Projects are a deprecated feature that hasn't seen any love since before Visual Studio 2008 was released. I understand it's a feature that ships with Visual Studio all the way up to 2010, but it's probably a much better idea to switch to another product, such as WiX (free and open source), NullSoft Installer a 3rd party commercial solution.
From what I gather, you did the correct things building your installer and setting up the configuration. You might want to check that the previous installer really has the same GUID you're expecting it to have.

Turning a Visual Studio C# Project into a setup file

I have a program written in c# using visual studio 2010 ultimate, and I want to be able to deploy the program into a setup file, or an installer file.
I need the setup file such that I can run and install my program on any windows machine, just like any other piece of software.
How do I go about building/deploying the project in this manner??
If you want to create a MSI install package, you can do so using a Setup Project. See this overview for various walkthroughs how to create/configure the project for different scenarios.
The Setup project works for simple install scenarios, but is not fit for more advanced tasks. If your needs exceeds the capabilities of a set up project, you can look at WiX.
Or, you might want to take a look at NSIS - it's easier on the beginners, and has a lot of great tutorials and examples.
For the ultimate control and generation of MSI install packages, you might want to take a look at WiX - it has a far greater functionality than Visual Studio's Setup Projects.
Another approach is to use the native tool for Visual Studio 2010: ClickOnce

Categories

Resources