I'm playing around with vNext in VS14, and have the need to reference an old (compiled against .net 4) DLL in my vNext console application. This package is not available on nuget. I've tried quite a lot of things, placing the dll within the root application
directory, app/packages, solution/packages, mimicking the structure of other packages, ie.
/packages/dllname.version/lib/net451/dllname.dll
and the same with /lib/k10, /lib/45, etc. and, of course, changing the project.json file accordingly as has been described in other threads. I know that would not be the correct way of doing it anyway, but I was just testing. None of the attempts have been
successful in getting the dll added to the project so that I can import it in code (and intellisense will pick it up).
My question is, how can I add a reference to a local dll file, not available via nuget, built with .net < 4.5.1 to a vNext project in the easiest way possible, like the right click -> add reference?
Ok, after a lot of fannying about, it seems that the way to do this is to create a nuget package using the DLL (i'll use Quartz version 2.2.4.400 as an example).
nb. placing the DLL outside of the lib directory will compile alright, but won't work with intellisense. If you are compiling with a specific version, then i'd put it in a net45, net451 or k10 folder; as i'm not, I didn't bother. my project.json then looks
like:
{
"dependencies": {
"Quartz" : "2.2.4.400"
},
"configurations" : {
"k10" : {
"dependencies": {
"System.Console": "4.0.0.0"
}
}
}
}
and then you can import it fine to a project. The issue I was having before was that the dependencies weren't being matched from the DLL name and version alone, but needed the .nupkg file to go along with it. This is kind of annoying, as looking at procmon,
it seems to recursively search the dll before the nupkg, and would indicate that you could store it in a number of locations (program files, packages, or anywhere within the project root), but practical testing showed that it had to be as above. I really hope
this is changed in the future to make the process a lot less painful; and I hope this helps someone else in the same situation.
None
0 Points
3 Posts
Adding a non-nuget reference to a vNext project
Aug 14, 2014 07:37 AM|Davies1|LINK
Hi all,
I'm playing around with vNext in VS14, and have the need to reference an old (compiled against .net 4) DLL in my vNext console application. This package is not available on nuget. I've tried quite a lot of things, placing the dll within the root application directory, app/packages, solution/packages, mimicking the structure of other packages, ie.
/packages/dllname.version/lib/net451/dllname.dll
and the same with /lib/k10, /lib/45, etc. and, of course, changing the project.json file accordingly as has been described in other threads. I know that would not be the correct way of doing it anyway, but I was just testing. None of the attempts have been successful in getting the dll added to the project so that I can import it in code (and intellisense will pick it up).
My question is, how can I add a reference to a local dll file, not available via nuget, built with .net < 4.5.1 to a vNext project in the easiest way possible, like the right click -> add reference?
Thanks
vNext
None
0 Points
3 Posts
Re: Adding a non-nuget reference to a vNext project
Aug 14, 2014 10:57 AM|Davies1|LINK
Ok, after a lot of fannying about, it seems that the way to do this is to create a nuget package using the DLL (i'll use Quartz version 2.2.4.400 as an example).
use http://docs.nuget.org/docs/creating-packages/using-a-gui-to-build-packages to build it. Drag and drop Quartz.dll into the right hand side (nb. it does need to be placed in the lib directory). File -> save as... save it in the following location:
projectRoot\packages\Quartz.2.2.4.400\Quartz.2.2.4.400.nupkg
With the dll in the following:
projectRoot\packages\Quartz.2.2.4.400\lib\Quartz.dll
nb. placing the DLL outside of the lib directory will compile alright, but won't work with intellisense. If you are compiling with a specific version, then i'd put it in a net45, net451 or k10 folder; as i'm not, I didn't bother. my project.json then looks like:
{
"dependencies": {
"Quartz" : "2.2.4.400"
},
"configurations" : {
"k10" : {
"dependencies": {
"System.Console": "4.0.0.0"
}
}
}
}
and then you can import it fine to a project. The issue I was having before was that the dependencies weren't being matched from the DLL name and version alone, but needed the .nupkg file to go along with it. This is kind of annoying, as looking at procmon, it seems to recursively search the dll before the nupkg, and would indicate that you could store it in a number of locations (program files, packages, or anywhere within the project root), but practical testing showed that it had to be as above. I really hope this is changed in the future to make the process a lot less painful; and I hope this helps someone else in the same situation.
Cheers
vNext
Contributor
2292 Points
908 Posts
Microsoft
Re: Adding a non-nuget reference to a vNext project
Aug 14, 2014 02:24 PM|davidfowl|LINK
Maybe, most of the world has moved on to NuGet packages and we'll likely support referencing an assembly but it won't be a first class experience.
vNext
Principal SDE, ASP.NET Team, Microsoft
None
0 Points
1 Post
Re: Adding a non-nuget reference to a vNext project
Aug 30, 2014 08:55 PM|Marceloveiera|LINK
You helped me a lot!
I am many hours trying to do this and now I got it.
Thank you very much!
vNext