简体   繁体   中英

Using reflection with class library exported as nuget asp.net core

I created a class library in .net core and and hosted class library on my local nuget server.Class library contains controllers and some other classes to be used by reflection.

I consumed this class library in my asp.net core MVC project.By installing it as nuget refrence. Now my MVC project builds well but at runtime I am not able to find my contoller or other classes defined in class library.

weird behavior when I copy dll of my class library to my MVC projects bin\\Debug\\netcoreapp1.1 directory, reflection starts working.

this is happening when i run my application in debug mode on IIS Express and I am using .net core 1.1 on Visual studio 2015

Question : Is there a way to extract nuget packages in to bin\\Debug\\netcoreapp1.1 on build. Question : Do I need to added some configuration so that Reflection look for dll in respective nuget package location.

Have a look at this answer, it might cover what you are looking for.

https://stackoverflow.com/a/38252635/138029

UPDATE: You could try adding a NuGet.config file to your project root.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <packageSources>
   <add key="AspNetVNext" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
   <add key="NuGet" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
   <add key="Local" value="[PATH_TO_YOUR_NUGET_PACKAGES]" />
  </packageSources>
</configuration>

As an aside, if the directory is local to the project root you can commit those local packages to the Source Control. This allows build tools like Visual Studio Team Services to reference them automatically when they build.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM