Dependencies and references - What exactly should I reference?

前端 未结 3 576
长情又很酷
长情又很酷 2021-01-13 03:02

I am wondering what to include when building my project. I have a library I need to reference for my project to build but that library has 10 dependencies itself. Should I r

相关标签:
3条回答
  • 2021-01-13 03:27

    It's just opinion. Either way will work.

    Personally I hate post-build BAT files, so I would include the dependencies to get them copied to the output directory.

    Another option is to put a link to them in your project - like in a resources directory. Have this set to BuildAction=None, and CopyToOutputDirectory=CopyIfNewer

    0 讨论(0)
  • 2021-01-13 03:37

    You only need to add references that are directly used by your project.

    For private assemblies (those not in the GAC) Visual Studio will, by default, copy referenced assemblies (and their dependencies) to your project's output directory.

    For assemblies in the GAC Visual Studio doesn't copy the referenced assembly to your project's output directory by default.

    In both cases you can change the behavior by changing the "Copy Local" reference property.

    IMHO, it's a nifty feature of the build environment. In the unmanaged world it's up to you to keep track of your dependencies' dependencies (usually through pre or post build events).

    0 讨论(0)
  • 2021-01-13 03:47

    I suppose you are working in Visual Studio.

    The short answer is to include only the assemblies needed for your project to compile.

    Referencing more assemblies should not cause any problems, for your application will load assemblies when needed at run time, but having a long list of references can get confusing and messy.

    Your list of references should tell about what your program does and what functions it uses.

    0 讨论(0)
提交回复
热议问题