Reputation: 2464
As per my knowledge, Visual Studio 2015 has some update and we can't add DLLs in asp.net 5 application any more, if we need to add then we need to make NuGet package and then install it.
Now my Questions are:-
1) If I have one project with two class libraries then how can i add that class library's reference (DLL) in my asp.net 5 application?
2) If a class library is also in development mode then how to update that DLL in asp.net 5 application if that DLL install via NuGet, because every time for publish on NuGet and get latest take more time.
3) Suppose if we need to add all DLLs using NuGet then what about private DLLs?
4) Is there any way without NuGet package manager to handle this?
Upvotes: 14
Views: 10939
Reputation: 6977
You can add old class library Foo.csproj to Bar.xproj as reference but not directly, see instructions below. It can be done without uploading packages in Beta8.
dnv wrap Foo.csproj
.Foo/wrap/Foo/project.json
. Go to your solution in Visual Studio, Add -> Existing project -> project.json
.Foo.xproj
which is available in Visual Studio solution, but it does not build.dnu restore
.dnu restore
.I really hope that this will be easier in final version.
Upvotes: 3
Reputation: 1107
You need to create a project.json for your assembly. you can use the command :
kpm wrap "c:\path\to.csproj"
This will create a "wrap" folder in the solution root folder. Then you must be able to add reference to your project. If it don't work, try to move the project.json in the project directory.
To use kpm(K Package Manager), you need to have installed the "k" and "dnx" tools and have a active version installed.
If kpm command don't work, folow this:
1) Open PowerShell as admin and type this command to allow the powershel to download and install the package:
Set-ExecutionPolicy RemoteSigned
2) Open a cmd with admin right and enter the folowing command to install the package:
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}"
3) In cmd, you can update and set the environement varriables with the foloing command:
dnvm upgrade
then try again the "kpm wrap" command
After that, you will be able to add a reference to your project. But i thing it will not work with core. if you have problem, try use an other dnvm version (like beta2 or "2 1.0.0-beta5") with the command dnvm install like this:
dnvm install 1.0.0-beta4-11566
Upvotes: 1
Reputation: 1123
I have edited my previous answer to point you to the following answer on StackOverflow:
Issue adding reference to class library project in ASP.NET 5 (Core)
I can verify the answer there works if your front-end project, the one from which you need to reference other class libraries, is ASP.NET 5 MVC 6 beta6.
Upvotes: 2
Reputation: 2940
Quick answer - you don't need NuGet packages for that and yes, it's possible to refer your own libs.
Two ways:
By adding it into root level "dependecies" object in your project.json. Be aware that this action will add reference into every target framework listed in the "frameworks" section, therefore if you adding reference to the old-type class library it would not work with new DNXCore 5.0
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Library": "1.0.0-*"
By adding it for specific framework version. Which is more flexible as you can use old-type libs for DNX451 and new vNext Class Libraries for DNXCore 5.0
"frameworks": {
"dnx451": {
"dependencies": {
"ClassicLib": "1.0.0-*",
"vNextLib": "1.0.0-*",
}
},
"dnxcore50" : {
"dependencies": {
"vNextLib": "1.0.0-*"
}
}
} ....
All samples I've checked on Visual Studio 2015 RC.
Upvotes: 6