2

I want to add reference to ASP.NET 5 Class Library project from regular Framework 4.5 Class Library Project. I cannot do it. Is there some workaround and will this be supported? I have tried to add dependency to framework 4.5 in project.json like this:

 "frameworks": { "net451": { "dependencies": { "System.Data.Common": "1.0.0-beta1", "System.Data.SqlClient": "1.0.0-beta1" }, "frameworkAssemblies": { } }, 

And after this add reference to this ASP.NET 5 Class Library project but without success.

5
  • Your class library is build in the artifacts\bin\[CONFIGURATION]\[FRAMEWORK] by VS, then you can add a reference from this build output I guess Commented Mar 31, 2015 at 12:56
  • @aguafrommars I cannot see any dll-s in artifacts folders. All folders are empty. Commented Mar 31, 2015 at 13:32
  • oh yes, excuse me, it is by publishing, not a simple build Commented Mar 31, 2015 at 14:19
  • maybe a kvm build in a post build event can do the trick Commented Mar 31, 2015 at 14:52
  • oups we don't have post build event in ASP.Net Class Library, but we have "Produce outputs on build", it can do the trick as well. that push dll into the artifacts folder Commented Mar 31, 2015 at 14:55

2 Answers 2

4

check the "Produce outputs on build" checkbox will copy build outputs to artifacts\bin\[CONFIGURATION]\[FRAMEWORK] folder

enter image description here

then you can reference this dll

Sign up to request clarification or add additional context in comments.

1 Comment

I have just referenced dll in Framework4.5 folder from old project type and it just works. Thanks
2

You can do it! First we need to understand that "old-style" projects output and reference DLLs. The ASP.NET 5 projects output and reference NuGet packages.

First set up a local nuget repository. Luckily this can be a folder. Then add that to folder NuGet.Config file.

<config> <add key="localrepo" value="C:\Temp" /> <the rest of your file /> </config> 

You can also do this through the Tools -> Options -> NuGet Package Manager -> Package Sources window in Visual Studio.

Then navigate your commandline to the ASP.NET 5 class library you want to reference. Drag down the dependencies with

kpm restore 

Then build and pack it and output the result to your local repository folder.

kpm pack --out C:\Temp 

Now you should be able to add the nupkg from kpm pack as a nuget reference in your "old style" project. Use your normal way of Managing NuGet Packages from Visual Studio if you wish.

Note: Your ASP.NET 5 class library needs to target net45 for this to work. Make sure this is in the framework section of your project.json

... "frameworks": { "net45": {}, // Other frameworks } ... 

Alternatively: If you want to do it quick and dirty you can run

kpm build 

, and add a direct DLL reference. The DLLs location should be listen in the output from kpm build.

2 Comments

Sounds pretty complicated to do simple project reference. I was thinking that I just need to add framework - > net45 section in project.json in vNext class library and when I build project it will also output old style DLL-s which can be referenced...
Yeah it's not pretty. If you want to do it quick and dirty you can run kpm build, and add a direct DLL reference. The DLLs location should be listen in the output from kpm build. Hopefully these nice to have tooling features will make it smoother and smoother as we get closer to release.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.