Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
589 views
in Technique[技术] by (71.8m points)

.net - How do you add references to locally created NON ASP.Net 5 dlls to an ASP.Net 5 project

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

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

1 Reply

0 votes
by (71.8m points)

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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...