Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

The asp.net home wiki appears to indicate that one can add references to locally produced dlls (assemblies) via the "bin" wrapper. However, it appears that only one bin wrapper may be included in a project.json file. So, what is the correct way to add references to external class library dlls compiled against .net framework 4.6 and portable library .net framework 4.6?

BTW. These DLLs are not in the same solution as the ASP.Net project.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
564 views
Welcome To Ask or Share your Answers For Others

1 Answer

Here is the accurate location of "bin syntax" in wiki https://github.com/aspnet/Home/wiki/Project.json-file#bin-syntax-wrapping-a-dll

The wiki reads:

You can create an project that, instead of compiling, references an already compiled dll and generates a package containing that dll

Please note that, with the "bin syntax", you are creating a project that uses the wrapped dll as its output (instead of compiling some source code to get the output dll). You are NOT adding a dll as a reference of target project.json.

Here is an example of the correct way to use "bin syntax" when you want to add a reference to a dll:

Assume we have:

  • ASP.NET 5 project, ProjectA
  • ClassLibraryB.dll, which was produced by some other type of project

To add a reference from ProjectA to ClassLibraryB.dll, we need to create a wrapper project wrapping ClassLibraryB.dll:

  1. Create a folder ClassLibraryB
  2. Create a project.json in ClassLibraryB folder with the contents:

    {
      "frameworks": {
        "dnx451": {
          "bin": {
            "assembly": "<path to ClassLibraryB.dll>"
          }
        }
      }
    }
    
  3. ClassLibraryB is an ASP.NET 5 project, add a reference from ProjectA to it as usual.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...