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

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.

Related

VSIX - include other application in package

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,

How to prevent Visual Studio 2010 SP1 from generating a bin folder during build?

I configured a project, right-click Properties, Compile tab, Build output path to a relative folder called Assemblies. I unchecked the option Generate XML documentation file. And still, a Bin folder is generated on the same level with my Assemblies folder, and the DLLs are generated in both places (Assemblies and Bin).
How can I prevent the Bin folder from being created and populated?

Copying Dlls to VS IDE Folder with VSIX

I`m creating VS2017 Extension, There some DLLs my Interface depends on, I would like to copy these DLLs to this folder:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE
I have the DLLs added to my project with IncludeInVsix set to true in the properties window.
I made sure of that by changing VSIX to ZIP and the DLLs are there. However they are not copied to the IDE folder, and though I have to copy them manually to get the extension to work.
Any idea how to accomplish this ?
Instead of copying dlls to VS IDE Folder, it is recommended to use ProvideBindingPath or ProvideCodeBase attributes to tell VS where to look for your dlls.

Indeterministic dll check in with TFS

All external libraries I use in my solutions are in the Lib folder of respective projects within a solution and all have their Build Action property set to 'Content' and Copy to Output Directory property set to 'Copy if newer'.
When I check in my solution into TFS, some dll files are copied to TFS and checked in with a blue lock appearing next to them, and some are not, prompting my team members to ask me for copies of these dll files in order to be able to build the solution...
If File Properties of all these dll files are the same and these are all .NET assemblies, what is it that determines if a dll will be checked in or not, and just what is the most appropriate Build Action for a dll library?
When you add a project or a folder to your source control, dolls and executables are ignored by default. you need to go to the exclusion tab and select the dlls you want to check in explicitly. that's why you have the seemingly random behavior.
What I discovered is that it depends on how you add the dll files to your solution.
If the dll file is first copied to your Lib folder and added to your project from there (copy/paste into Lib folder in Solution Explorer), it is not checked in and copied to the TFS.
If the dll file is added to your project (copy/paste into Lib folder in Solution Explorer) from its original location VS will copy the file to your Lib folder and check it into TFS.

Include GAC Assemblies in Bin

Any ideas how to force a GAC DLL into referenced?
Here is my issue, I constantly use a 3rd party DLL that registers itself into the GAC, and when I use it in my project, it reads it from the gac, and when I deploy, I'm always forgetting to add the DLLs since it is not located in the Bin/Referenced folder.
Anyway to force Visual Studio to add the DLL instead of from GAC?
Copy Local only works if the GAC'd assembly if one reference level deep. For instance, if you have a project that references the GAC'd assembly, and that project if referenced by your web project, then while yes, the GAC'd assembly will be copied to the first project's bin folder, but it won't be copied to your web project's bin folder.
The solution, then, is to directly set a reference in the web project to the GAC'd assembly, and specify Copy Local. Even though the web project doesn't directly use the reference in this case, it will copy it to the web application's bin folder.
Right click on the assembly reference, select properties, and change "Copy Local" to true. That will cause it to copy the assembly into the deployment directory
Select the dll in your references and set CopyLocal=true in the properties window.
Select the reference and set the Copy Local property to True

Resources