VSIX - include other application in package - visual-studio

How can we include a separate .NET application inside a VSIX package? Preferably in a subdirectory so that it doesn't interfere with DLLs of the Visual Studio extension itself (different versions). The application is available in the same solution, but for the same reason I van also not add a reference to it in the main project.
The intention is to run that application as a separate process, started by the extension. The extension will then connect to that application through WCF.

I'm pretty certain you just need to include the .EXE in your .VSIX. A .VSIX is just a .zip file, and you can include additional files into it by simply adding them to your project and setting the Include in VSIX property to true.
To confirm, try downloading something like the Azure Data Lake and Stream Analytics Tools VSIX to disk. (I mention this one because I noticed it installed a number of .EXE's under my C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions directory).
Once you have the .VSIX on disk, rename it as a .zip file and unzip, or view its contents with the windows explorer. Note that the extensions.vsixmanifest file contained in that .zip has no references or entries for any of the .exe files installed by that .VSIX. Which means, all you really need to do is include it in the .zip file.
Add a subfolder to your .VSIX project, copy the .exe there, add it to your project, set the Include In VISX property to true, and I suspect you'll be all set.
Sincerely,

Related

Saving a program as a .exe file in Visual Studio 2017 with using no programs

I am trying to save a program in Visual Studio 2017 as a .exe file so I can send it by e-mail. You can save it as a .sln and as a .vb file (I'm using VB.NET) but I can't find any way to save it as a .exe file inside the program. I also don't want to use any downloadable programs that can do this.
Build the solution.
Open the folder that the solution is in.
Navigate to the Bin folder.
Under this folder there will likely be a folder called Debug (or a name that corresponds to your build configuration). In here will be your exe file if it built correctly and you have the correct type of visual studio project.

Visual Studio - Reference of dlls are automatically created at bin folder

I am using Visual Studio 2010 with MCV4 (Installed separately).
Some dlls are linked to the orignal path, and some are copied to the project.
I don't want them to be copied to the project.
i.e when building Web project (MCV4 -> Web API), I see several dlls, that automatically created:
Antlr3.Runtime.dll - created on project folder (and path is not the original folder).
also: EntityFramework.dll, System.Web.Optimization.dll and some more,
where system.web is on C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Web.dll folder.
Why the above dlls are copied to the project folder, and how can I enforce that they would be on the original one?
Thanks :)
If you rightclick each references assembly in your project there is a propery "Copy Local". For each reference you set Copy Local=true it will be copied into your output folder (\bin).
Unless the DLL is in the GAC (Global Assembly Cache), you will want to copy it locally as the application will not know where to load these DLLs from. By default when you add a reference, Copy Local will be true when the DLL is not in the GAC.
If the application can not find the DLL's it needs it will fail when the DLL is needed.
A .Net application can only load DLLs from the GAC or from your application path and subdirectories unless you employ your own Assembly.Load() code to do this.

How to include arbitrary files in a .NET setup project

We have a folder of text files that needs to be copied to the server whenever our application is deployed. Currently, we handle this by manually copying/pasting the folder's contents.
How can I include this as an automated step in the MSI?
I want the folder (and it's contents) to be included in the MSI. Then, on install, I want to the files in the MSI to overwrite the existing files (in a given local directory).
The files are in source control (TFS), but they are not part of any .NET project.
I've used the Nullsoft Installer before (among others), and that's basically all it does (you tell it what files to pull in and where to put that at install time). Visual Studio automates a lot of this... but I just can't see where to do the basic task.

Keep source files in an external directory in Visual Studio/C++

Is there any way to instruct Visual Studio 2010 to keep my .h files and .cpp files separate from the project files and databases that VS generates to manage the project? Specifically, I would like to have a set up where the project files are in the VS install folder and the source files are in a completely separate folder in my Dropbox, and monitored by git.
You can put the .cpp and .h files wherever you want. A project file just lists the locations of the source files. Create the .cpp and .h files where you want them, perhaps with Notepad, and then use "Add Existing File" to add them to the project. (Right-click on the project name in Solution Explorer and choose "Add Existing File".)
Source files are represented in the project file using relative paths, so if both the sources and the projects are on the same disk drive, the sources will be represented something like "..\..\..\..\MyFiles\work\SuperCalc\Input\parser.cpp". If they're on a different drive, then they'll use absolute paths like "D:\MyFiles\work\SuperCalc\Input\parser.cpp".
A detailed example of a source file and build file layout which uses this technique is presented in this StackOverflow response about organizing Visual C++ source files. You may find it helpful.
As an aside, if you really want to store your project files in the VS install folder, which is under C:\Program Files\Microsoft Visual Studio 10.0", then you'll need to run VS in Administrator mode, because C:\Program Files is a protected directory.

How to copy a file to an arbitrary location when installing a VSIX project?

I am developing a Visual Studio 2010 extension (VSIX project) to add some extra properties to the entities in the Entity Framework designer. In addition to registering the appropriate classes for MEF discovery, I would like a T4 include file to be copied to the %ProgramFiles%\
Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Entity
Framework Tools\Templates\Includes folder when the extension is installed, but I don't know how to do it and the VSIX properties page does not seem to show any option for this.
So my question is: is there any way to have a given file being copied to a given location when a VSIX project is installed?
Using VSIX only, no, there is not.
Whole contents of VSIX package are during installation simply unzipped into your local extensions directory - and that's END regarding file installations.
Whatever you want to copy anywhere, you must deal with it outside of the VSIX installer. For example - use different installer. Or, for another example, upon first-run of your plugin, somewhere in package.Initialize(), check whether the files in question exist in right places, and if not - copy them there.
Of course, if you want to write to the ProgramFiles directory, you have another barrier in front of you: the UAC protection. To write there, you will need an another executable that your plugin will run in elevation (and asking the user for permission during that, etc) and it only it will be able to copy the files there. Well, of course, unless you happily assume that everyone always run their VisualStudios "as administrator" and simply ignore the UAC and your users' tears.

Resources