Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
Referencing Library in ASP.NET Core 1.0 (vNext)

I am learning ASP.NET Core 1.0 (vNext). With that in mind, I have a solution that is structured like this:

MySolution
  src
    MyLibrary
      MyClass.cs
      project.json
    MyWebSite
      Startup.cs
      project.json

I am successfully compiling MyLibrary from the command-line using dnu build. I ran dnu pack which generated MyLibrary.1.0.0.nupkg. There are also two folders: dnx451 and dnxcore50 which both contain MyLibrary.1.0.0.dll. I want to use MyLibrary in MyWebSite, however, I'm confused.

  1. How do I "include" MyLibrary into MyWebSite? Do I manually copy over the .dll file? If so, which one? Should I use the nupkg file instead? This is a private assembly, I do not want to publish it globally via NuGet.
  2. What do I put in MyWebSite/project.json to reference the MyLibrary assembly?
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Are you using Visual Studio 2015 RC? If so then follow these steps:

  1. Expand your web project in the Solution Explorer
  2. Right click on References
  3. Click on Add Reference... from the context menu
  4. Select Projects from the Reference Manager
  5. Tick the checkbox next to MyLibrary
  6. Click OK
  7. Profit

If you are not using visual studio then this can be achieved by updated the project.json file in your web project.

If you created a "vNext class library project" then add this to the dependencies property on the json object:

"dependencies": {
      "MyLibrary": "1.0.0-*"
   }
over 4 years ago · Santiago Trujillo Report

0

You don't have to publish the package to NuGet if you don't want to share it with other people/projects outside of your solution. You can just reference the package directly from source.

However, if that still doesn't work for you then you have three options:

  1. Internalize using Roslyn. Example: project.json and the actual code
  2. You can reference the sources directly. Example project.json
  3. Create a build time dependency. Example project.json and actual code for the package
over 4 years ago · Santiago Trujillo Report

0

  1. Several questions marked in bold.

(How do I "include" MyLibrary into MyWebSite?) In MyWebSite/project.json: Add the reference like this (don't worry about the version number not showing up). Add VS2015RC class library reference

(Do I manually copy over the .dll file?)

No

(This is a private assembly, I do not want to publish it globally via NuGet.)

Then don't do that :)

Referencing your class library from your web application will make sure it is included when building the web application. Then you should copy your web application files to an application server able to run it. I think you should try to publish your web application to an Azure Web app and then use server explorer to look at what the files on the server looks like after publishing. Or did you already know there is no reason to make a package before using it in you web app?

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!