Reputation: 7669
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.
Upvotes: 2
Views: 2857
Reputation: 1607
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.
Upvotes: 2
Reputation: 17424
check the "Produce outputs on build" checkbox will copy build outputs to artifacts\bin\[CONFIGURATION]\[FRAMEWORK]
folder
then you can reference this dll
Upvotes: 4