Background:
I am working on a SDK that allows its users to create custom plugins for an existing product. There is a bit of boilerplate code/file copy/COM DLL registration required for the plugin integration.To ease things for the plugin developer, I have written a Visual Studio custom project template that uses a IWizard to create a new solution, add couple of projects, generate a number of files containing the boilerplate code as well as some batch files that get executed as a post build event.
The wizard has a number of fields (such as the copyright header that needs to be inserted at the top of each generated file) that the user can edit to customize the generated code.
The Question
I'd like to persist some of the customizations and use it across multiple runs of the wizard. I also know the usual recommended places for individual applications to store their settings is under %APPDATA%. I'd like to know if there are any other places where specifically Visual Studio extensions can store their settings or I should just treat this as an standalone application and go with the %APPDATA% folder. The reason I ask is further down the line, I like to allow the plugin developers to share these settings via VS->Tools->Import & Export Settings
You have two options. You can use Visual Studio's DialogPage which will show up your configurations in Visual Studio's Options window. You can also use IProfileManager, if you do not want your preferences to show in Options window but you still want to persist them.
I have written blog post about both of these options. These posts contains complete details and code snippets.
Integration with Visual Studio Options Window using custom controls
Persisting settings without using Options dialog in Visual Studio
Related
I am trying to generate code scaffolding for an in-house API. I created a T4 template which includes several other templates for each code file to be generated. I then wrote a Visual Studio Extension (VSIX) with a WPF form to capture user input and initiate the transforming of the T4 template. I am doing all of this in Visual Studio Professional 2013.
This is what I followed to Invoke the Text Transformation in a VS Extension
https://msdn.microsoft.com/en-us/library/gg586947%28v=vs.120%29.aspx?f=255&MSPPError=-2147217396
When testing the templates locally using Run custom tool, everything works perfectly. However, when testing the VS extension in an Experimental Instance of Visual Studio, the problem I am having is that after the transformation has been invoked [calling ITextTemplating.ProcessTemplate], the generated files are not placed into my open project. I verified that they exist in their appropriate folders in File Explorer.
I have searched high & low and can't find anything that talks about this. Any ideas?
The custom tool is using the Visual Studio API (DTE object) to add the generated files to the projects. I built something very similar and that is what I had to do. This project is a bit old but it is a great starting point for seeing how this can be done.
Basically you need to get a reference to the folder you want to add the new item to and then call AddFromFile. Also don't forget to save the project after you add all the items.
I would like to create custom templates for c# files, unit test classes, .aspx.cs etc so that common items to all files are included once they are created eg file headers. I am working with visual studio 2010 and resharper 6. What is the easiest way to create these files and is it possible to be able to share them a team of developers easily? Appreciate any assistance or information as to how I might achieve this.
Visual Studio templates are simple enough to create - you can distribute them to your colleagues to setup in the same location on their computers (or even create an installer, if you want to makes things even easier).
See Creating Project and Item Templates and the Introduction to Visual Studio Templates on MSDN.
Contents of a Template
All project and item templates, whether installed together with Visual Studio or created by you, function by using the same principles and have similar contents. All templates contain the following items:
The files to be created when the template is used. This includes source code files, embedded resources, project files, and so on.
One .vstemplate file. This file contains the metadata that provides Visual Studio the information it needs to display the template in the New Project and Add New Item dialog boxes and create a project or item from the template. For more information about .vstemplate files, see Visual Studio Template Metadata Files.
When these files are compressed into a .zip file and put in the correct folder, Visual Studio automatically displays them in the My Templates section of the New Project and Add New Item dialog boxes. For more information about template folders, see How to: Locate and Organize Project and Item Templates.
You should open Templates Explorer from ReSharper | Templates Explorer. Then select the File Templates tab. There are default templates that comes with ReSharper. You can examine them and see how you can write your own. Here's the documentation and there's a question for useful examples.
i was in the process of evaluating different tools available for creating the setup package for a newly developed software. i came to know about the visual studio's setup project facility, but couldnt get much help on its capabilities.
Can someone tell me if this tool helps me achieve the below given features
copy/paste files and folders.
create a text file, and input certain values to it.
make/update entries to the registery
check for certain services running on the local/remote system
reading certain environment variables from the system.
running a third party application.
what script language does it support
Other than Visual Studio, I had evaluated InstallShield which does provide support for all the above mentioned actions. But Visual Studio is already available, I was curious to find if it matches InstallShield in capability?
Here is the Visual Studio support:
Supported
Not supported
Supported
Not supported
Not supported
Somewhat supported ( supports prerequisites )
No scripting support
What is not supported can be implemented through custom actions (custom code).
The custom code is in form of custom actions, which can be DLLs, batch files, executables or VBScripts, with DLLs being the method recommended by microsoft, written in C/C++.
Here is some more information on what custom actions are and how such custom actions are integrated with the installer:
Custom Actions
If you want an alternative, you can try Advanced Installer. It supports everything you need and it's cheaper than InstallShield.
I'm involved in many projects and each project has their own source control provider. Is there a way to configure Visual Studio 2010 to automatically select the right source control on a per project basis? Or is the Tools - Options - Source Control plug in per user level?
Let me clarify what is happening. I have a project using Vault. When I open it VS sets the Source Control to Vault. I then close the project (solution) and open another solution that uses Mercurial (VisualHG) I check the Source Control plugin and Vault is still selected. Why? Is it possible to automatically select the right source control?
In order to automatically load a proper source control provider the solution file must contain Scc bindings.
I don't know if VisualHG supports them or not.
But you can try HgSccPackage - another mercurial plugin for MS Visual Studio 2008/2010 which supports Scc bindings.
You can get it here: http://www.newsupaplex.pp.ru/hgscc_news_eng.html
If you want to add Scc bindings to an existing controlled solution, use Mercurial -> Change SCC bindings menu from the IDE. (This menu will be available when the HgSccPackage is active and you have loaded a controlled solution).
For new projects HgSccPackage automatically adds Scc bindings. It is configurable via options though, for thouse who don't like this behavior.
You might want to take a look at this question. It appears the answer is no, you have to select the correct provider for the project before working with the project, because only one source control provider can be active at a time.
There's an additional VS plugin called Scc Auto Switcher that can help automatically switch between SCM systems used by different projects, although the docs don't specifically mention Vault.
I'm trying to create a very basic "Setup and Deployment" project using Visual Studio.
What I would like is the ability to choose which components to install. Let's say that each component consists in the primary output of a single class library (i.e. each component is actually a single module or compiled assembly).
I haven't seen such an option in the standard set of available dialogs. But I have seen that with a little effort we can somehow create custom dialogs.
How can I programmatically detect which component are available as part of the setup and deployment project? (i.e. I would like the project to work even when adding or removing a component from the installation)
How do I extend or create a custom dialog that displays the list of available components?
How do I detect which components the end-user has choosen to install?
I'm somewhat familiar with Orca, the tool to manipulate .msi files as well as full blown installer applications like InstallShield, but I would like to make this using only raw Visual Studio and other available open-source tools.
Thanks for your help.
VDP (Visual studio Deployment Project) is not cut out for this kind of stuff (read: use Wix instead):
(I'm guessing you want this at runtime) You can use MsiQueryComponentState but for that you will need to pass the component GUID which in VDP you don't have control over.
This comes out of the box with everything other then VDP.
(I'm guessing you want this at setup time...) You can use Condition in order to execute custom action based upon Component Install State, in VDP you don't have control over the component id (not to be confused with the component guid) which is needed in order to preform component condition.