Deploy a VSPackage to create a new project type using Setup Project - visual-studio-2010

I create a new custom project type using a VSPackage project inheriting of MPF library (http://mpfproj11.codeplex.com/). As a result I obtain a .vsix but I need add this project type using a .msi. I'm using the Visual Studio 2010 Setup projet for it. In my setup project I add the content of the VS Package in the same directory where the .vsix put then, but I think Ineed to put in the registre the new type of project because when I use the setup , the project template does not come out in Visual Studio and when I give double click the file with extension of the type of new project and does not recognize it. When I look the registry after install the vsix, this was one of the things that I found diferent. I add this entries in my setup project but It's not working yet.I'm missing something else?
In the projecttemplatedir is the directory where I put the .dll of the project type, the vsixmifest and pkgdef. The project template is in [User]\Documents\Visual Studio 2013\Templates\ProjectTemplates\[Name of new Project Type]\[projecttemplate.zip]
Best Regards
PS: The project type is for VS 2013 but I'm using the VS 2010 Setup project ;)

OK, so first the "don't"s of doing this:
In general, if you are installing via MSI you shouldn't be doing anything user-specific -- no writing in HKEY_CURRENT_USER, nor writing within their Documents folder, LocalAppData, or Visual Studio folders, etc. If you see yourself writing files or registry keys in either of those places, that should be your hint that there's a better way to do what you're trying to do. For what you've shown so far, this raises more than a few red flags for me.
Second, don't ever go writing keys into 12.0_Config. That part of the hive is nothing more than a cache that's built up from other parts of the registry and on-disk .pkgdef files from extensions. It's rebuilt in any number of senarios, including installing new extensions. Any writes there you should presume will get blown away at any time. If you need to write things there you should either (a) write in HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\[version] and run devenv /setup or (2) [preferred] put your keys in a .pkgdef inside your extension which gets merged into 12.0_Config for you automatically.
Now the dos:
You said you already had a .vsix produced by the SDK: you can put project templates in there. You can then register those templates in the .vsixmanifest and those will pull in. That's far easier than mucking around with files in Documents -- that's the user's directory...don't go playing with that.
Once you have a .vsix that does most of what you need, you should simply take the files within that and install the files in a folder within C:\Program Files [(x86)]\Microsoft Visual Studio 12.0\Common7\IDE\Extensions. Even better, you might just want to WiX toolset to build your installer, since it has built-in support for installing extensions. It also has built-in support for invoking the "/setup" process if that's what you need to do as well. Visual Studio Setup projects are no longer supported in newer versions of Visual Studio, so you're better off starting with a technology that isn't already obsolete. WiX is even what we use at Microsoft to do the setup work for Visual Studio itself, so it's definitely up to the task.
Last point: almost everything when it comes to Visual Studio extensibility can be done with a VSIX directly, so presume there's a good way to do something that way before falling back to an MSI. Internally, we can register the entire C# and VB language services with just a VSIX -- they're quite powerful.

I found the answer in this link Registering Project and Item Templates. I set projecttemplatedir entry with
[User]\Documents\Visual Studio 2013\Templates\ProjectTemplates[Name of new Project Type][projecttemplate.zip] that is where i put the project template.

Related

Force extension installation in Visual Studio

We're working in quite a large project and is having a hard time getting people to configure their Visual Studio correct (tabs instead of spaces etc.). We found a great solution in using the EditorConfig extension for Visual Studio.
However there are still some developers that seems to ignore our request to install this extension to their Visual Studio and hence I'm wondering if there is any way to force an extension to be installed before a solution can be opened, maybe some setting in the .sln file?
No there is no such option built-in. If your machines are domain joined, you could push out the installer through System Center or domain logon scripts.
You could cheat and create a solution level pre-build step. Create a target file named: before.{solutionname.sln}.targets and store it next to your solution file. Check it into source control. In the targets file you can use standard MsBuild to see if the extension is installed (you'll need to check the file system probably) and if not present force the installation by calling vsixinstaller.exe to trigger the install.

Generated T4 Files Not Added to Project from Visual Studio Extension

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.

Is it possible to include a program project and a Wix project both in a Visual Studio Solution?

For example, I use Visual Studio to create a mono game project in the solution, and I add another wix project that
when I hit "build solution", the mono game project being build, and wix project build a installer directly afterward.
In this way, I don't need to separate my project everywhere, because I just want some more additional options with One-Click installer.
If I can use Wix, I can customize the installer, but how?
After search for some time, I found this
http://wixtoolset.org/documentation/manual/v3/votive/votive_project_references.html
But, I would like to put two projects in a same solution folder, rather than two separate solution folder. This way, if I change the path, will the link just broke up?
Yes, you can. Simply add a reference to the project from your WIX project.
Note that with project references, you can use variables in your wxs files. For example if your game project were DavidWong.MyGame:
<File Id="MyGame.exe"
Name="$(var.DavidWong.MyGame.TargetFileName)"
Source="$(var.DavidWong.MyGame.TargetPath)" KeyPath="yes" />
See the documentation for more info.
Yes, it can be done ( project reference and $(var.ProjectName.TargetDir) and so on ) but in my experience there are a few reasons not to:
1) When a new version of Visual Studio comes out you might be stuck if a new version of WiX is not yet released to support that version of Visual Studio. I've seen this several times and currently you'd have to run a beta build of WiX v3.10 if you wanted to support Visual Studio 2015.
2) All developers now have to install WiX or get error messages that some projects couldn't be loaded.
3) Some developers will complain that they don't want "setup" code in their .NET solution. I think this is a thin complaint but I kinda get it.
What I like to do is have an application solution and an installer solution. I use postbuild copy commands and MSBuild publish profiles to stage content in a "deploy" folder that models the deployed system and then use that reference that structure in my wix code.

Add reference deselected in visual studio 2010

I am trying to open a existing project in visual studio 2010 using
new->project from existing code
and selecting visual c# as the language. When I run it, I get errors. Later I heard from the person who created the project that I have to add few references, which are present in the references folder in the project itself. It comes in the side window - solution explorer.
However, when I right click on that folder to add as references, that option is 'greyed', or disabled. How Can I correct this?
The DLLs named freeglut.dll and glut32.dll are not COM or NET components. You cannot add them as references to your project (You have 4 solutions in your archive, I have choosen the one named fwa_annimate but I think the problem is the same).
The DLL named Tao.FreeGlut.dll needs these files in the same directory where you application run to work. So the easiest way to resolve your problem is to select the two DLLs inside Visual Studio and change the property Copy to Output Directory from Copy Never to Copy Always.
In this way, when you start to debug your app, the VS IDE will copy the two files to the BIN\DEBUG or BIN\RELEASE directory where you app runs when launched inside the VS IDE.
Of course, you need to deploy all these file when you distribute your application.
(By the way, I have no idea what is supposed to do)

How to include ignored files when using Publish tool in VS2010?

I have a directory /media/fonts in my asp.net mvc project which contains fonts for my website. When I use the "Publish" tool in Visual Studio this folder is ignored even though it is included in my project. Other folders /media/images and /media/css are included just fine.
Is there any way to tell Visual Studio to not ignore this folder on publish?
Select your font files and Change Build action as Content from Properties Window.
You can fix this permanently by modifying the default Build Action for font file extensions (.eot, .ttf, etc)
http://blog.andreloker.de/post/2010/07/02/Visual-Studio-default-build-action-for-non-default-file-types.aspx
The link has been assassinated by the cruel march of time, so here's a copy/paste of its contents:
The default build action of a file type can be configured in the registry. However, instead of hacking the registry manually, we use a much better approach: pkgdef files (a good article about pkgdef files). In essence, pkdef are configuration files similar to .reg files that define registry keys and values that are automatically merged into the correct location in the real registry. If the pkgfile is removed, the changes are automatically undone. Thus, you can safely modify the registry without the danger of breaking anything – or at least, it’s easy to undo the damage.
Finally, here’s an example of how to change the default build action of a file type:
[$RootKey$\Projects{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\FileExtensions.spark]
"DefaultBuildAction"="Content"
The Guid in the key refers to project type. In this case, {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} means “C# projects”. A rather comprehensive list of project type guids can be found here. Although it does not cover Visual Studio 2010 explicitly, the Guids apply to the current version as well. By the way, we can use C# as the project type here, because C# based MVC projects are in fact C# projects (and web application projects). For Visual Basic, you’d use {F184B08F-C81C-45F6-A57F-5ABD9991F28F} instead.
$RootKey$ is an abstraction of the real registry key that Visual Studio stores the configuration under:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0_Config
(Note: Do not try to manually edit anything under this key as it can be overwritten at any time by Visual Studio).
The rest should be self explanatory: this option sets the default build action of .spark files to “Content”, so those files are included in the publishing process.
All you need to do now is to put this piece of text into a file with the extension pkgdef, put it somewhere under
%PROGRAMFILES(x86)%\Microsoft Visual Studio 10.0\Common7\IDE\Extensions
(on 64-bit systems) or
%PROGRAMFILES(x86)%\Microsoft Visual Studio 10.0\Common7\IDE\Extensions
(on 32-bit systems) and Visual Studio will load and apply the settings automatically the next time it starts. To undo the changes, simply remove the files.
Visual Studio does publish font files. In a special case we renamed extensions from .ttf to .jpg and they got published.

Resources