Project Reference Vs File Reference?

前端 未结 11 1716
一向
一向 2020-12-02 18:36

References can be added in two ways in a project.

  1. Project Reference.
  2. File Reference.

But, When to use Project and when to use File refe

11条回答
  •  独厮守ぢ
    2020-12-02 19:27

    You didn't specify but I'm guessing you're referring to Visual Studio?

    The main difference between a project reference and a file reference is whether or not live updates are available. In a project reference you will be able to see the effects of edits in one project immediately in the other project via items like Intellisense. So if you for instance add class named Foo, this this type will show up in intellisense immediately in any project which has a project reference on that project.

    File references on the other hand can only see changes that are present on disk. A compilation must be performed and bits written to disk in order to see the changes.

    In general, it's best to use a project reference.

    Another angle that needs to be considered is the relative languages of the projects. Project to Project references are maximally useful if the language in both projects are the same. If the languages are different they tend to be treated more like file references than project references.

提交回复
热议问题