none
Adding Project References - Copy to local needs

    Question

  • Hi,

    I have few questions regarding adding project references in visual studio and how it works with copy to local.

    Please help me to understand.

    1. Adding references to a project from solution sets copy to local as true by default. Is this mandatory?

    2. If I set copy to local as false what would be side effects?

    3. Will my deliverable work as expected if I set copy to local as false and take the deliverable out the machine in which I have code? 


    Tuesday, March 28, 2017 4:47 AM

Answers

  • If a main project (that will produce an .exe) references other projects (that will produce .dlls), it is mandatory Copy Local = True, so that when the referenced projects are built their output dlls are copied to the output folder of the .exe. Otherwise the .exe wouldn't find the dlls for running or debugging on your development machine.

    Apart from that, you have to deploy the .exe and .dlls to the the same folder on the end user's machine.



    My portal and blog about VSX: http://www.visualstudioextensibility.com; Twitter: https://twitter.com/VSExtensibility; MZ-Tools productivity extension for Visual Studio: https://www.mztools.com

    Tuesday, March 28, 2017 10:42 AM

All replies

  • You need to think when your app runs on the user's computer or on a server, rather than on your development machine, where the app will get the referenced assemblies from? For example:

    - If you are using references through NuGet, chances are that your setup will need to include the referenced DLLs, so it makes sense to copy them to the Output folder, to remind you that you need to ship them.

    - If you are referencing assemblies of .NET Framework, your setup doesn't have to include it, it just need to check .NET Framework as prerequisite on the target machine. Once installed, the .NET Framework provides its DLLs in the Global Assembly Cache (GAC).

    - If you are creating an extension for Visual Studio, you don't need to include the referenced assemblies of the Visual Studio SDK, because the target machine will have Visual Studio and the required DLLs.


    My portal and blog about VSX: http://www.visualstudioextensibility.com; Twitter: https://twitter.com/VSExtensibility; MZ-Tools productivity extension for Visual Studio: https://www.mztools.com

    Tuesday, March 28, 2017 8:26 AM
  • I have 4 projects.

    Pjt1 is a main project which is referring the other 3.

    Pjt1's output folder is deliverables.

    other three projects are added as a project reference with copy to local as false.

    if i simply copy deliverables folder into other machine (say some test vm) which have .net  framework run time is installed. 

    Will it work as expected!?

    Tuesday, March 28, 2017 8:46 AM
  • If a main project (that will produce an .exe) references other projects (that will produce .dlls), it is mandatory Copy Local = True, so that when the referenced projects are built their output dlls are copied to the output folder of the .exe. Otherwise the .exe wouldn't find the dlls for running or debugging on your development machine.

    Apart from that, you have to deploy the .exe and .dlls to the the same folder on the end user's machine.



    My portal and blog about VSX: http://www.visualstudioextensibility.com; Twitter: https://twitter.com/VSExtensibility; MZ-Tools productivity extension for Visual Studio: https://www.mztools.com

    Tuesday, March 28, 2017 10:42 AM