-
Notifications
You must be signed in to change notification settings - Fork 124
Add Reference to .NET 4.5.1 class library project from ASP.NET 5 web app not working #45
Comments
Can you show your solution layout? From the error, it looks like it can't figure out what kind of reference Recipe05.Dal is. What does the ICON show in visual studio? Is it yellow? |
You missed my first question. what is your solution layout. Do you have more than one global.json in your project structure? It looks like things were adding in the wrong place and the ASP.NET 5 project can't figure out the project references. |
There is two global.json files but only one appeared in the solution explorer. The one in the class library project only had: Interesting, if I create the ASP.NET 5 project first, then create a NEW class library project as part of the ASP.NET solution it seems to work fine. If I include an existing library created as part of another solution, I run into issues. Does not seem to matter where the location of the referenced class library is. Seems like in the latter case the wrap command is adding a global.json file to the class library project. This could be because I am adding a reference to a project that was created in another solution. Wrap command sees a solution folder without a global.json so it adds one. |
That project is where on disk? On again, can you post the solution layout at each step? I'd like to be able to reproduce this but the steps still look too vague. |
Here is another way to make it fail. :-)
In this case, since you started with an empty solution, you do not get a global.json file at all. The work around is to remove the reference, manually delete the generated wrap directory in class library project folder and then manually create a global.json file. After that, you can add the reference and it will get you past the issue of not being able to find the package. Even after this fix, there are other issues such as what lucamorelli mentioned in issue #8 where you get Entityframework 7 beta 4 rather then EntitityFramework 6.x. Seems like the only way to make it work is to manually add "bin": {
"assembly": "../../../packages/EntityFramework.6.1.3/lib/net45/EntityFramework.SqlServer.dll"
} To the web project's project.json file. I think maybe you should rethink how the wrap command works for Visual Studio. Maybe you can add an option to the command line interface that would tell wrap to modify a specified project.json file rather then creating the wrap directory as it does today. |
In #8 he Luca was referencing EF7 and EF6 |
I have this situation.
|
I can't get this to work even how hard I try. Issue is reproduced by the following steps:
Tree: |
This issue is pretty old. We have worked on improving the Add Reference support. We still have some issues related to wrap but I think the basic scenarios should work. I'm going to close this, but if you are still having issues you can either re-open this or open a new issue with steps to reproduce. |
So how is this supposed to work? I am running into some of the same problems here. I have an existing Solution with projects A, B,C,D in it and I created a new Asp.Net 5 Solution with 4 new projects and everything working fine. I added the 4 existing projects to the Solution and saw that a project.json file was added for each of them in a /wrap folder. I then tried to reference to projects A-> D to one of the Asp.Net projects and am now getting an error. How do I work around this error? |
I tried this and many other things. Nothing works. Why is it so hard to add a class library and reference it from the asp.net 5 project? |
Even if you can reference it, it breaks within a short time. For instance I checked that I could reference a class called Class1.cs from the class library in the asp.net 5 project. But then after a short while, it is like the link breaks, And the only file you can now reference in the asp.net 5 library is that Class1.cs class. No other class you add is can be referencing. Really weird and frustrating. |
Experiencing a similar issue - got a pretty small asp.net 5 app, pull some of my older Class Library .csproj files into the solution, try to Add Reference > Projects... so I can use those assemblies, and am getting error project.json(35,43,35,43): DNX 4.5.1 error NU1001: The dependency MyClassLib >= 1.0.0-* could not be resolved. Pretty much everything I google for to try to learn more (like trying to figure out how the "wrap" stuff is supposed to be set up) shows this thread as a top link. :) |
We probably need to test this and open a new ticket if it doesn't work inside the dotnetcli repo as dnx is dead and this may not even work the same in RC2. |
I can confirm the issue @nigel-dewar and @pettys have experienced. I experience this issue too in a brand new solution. |
Experiencing the same issue. I building a test Service Fabric App with a stateful service backend and an ASP.NET 5 web front end. I added a proj reference from the Web project to a common interfaces project I was building which defined the contract to the back end services. The solution was created for the service fabric and then web project was added to that dir structure. Initially the project seems to work, but when I make changes to the interface in the contracts project the new contracts do not become available to the web project. Interestingly enough, it appears at design time to work; there are no syntax errors or indication that the method doesn't exist. At build time, however the output clearly show that it can't find the method and the build fails. Directory structure: |
Similar issue, trying to add a Nuget package written in a 4.6 class library, adding it as a reference adds it to the project json but says it can't resolve it. I understand ASP.NET 5 is the new and shiny but seriously this is the first thing people will be doing to port their projects - add references to their existing ones. |
Same Problem, I can't add my own .NET 4.5.1 DLL as a reference to my ASP.NET 5 Project. It works if I make the following changes: Exists for that a gobal Setting or can i remove the DNX Core Features ??? |
I think that this issue is related with #245 |
Same Problem not able to add my class library as reference. |
I noticed it's setting the following in project.json even though I had .NET Framework 4.6.1 selected when I created the ASP.NET 5 Web project. "frameworks": { I changed it to "dnx461". I was able to add the reference. However, the project won't build. It says a dependency to the library that I added couldn't be resolved. Honestly, I have no idea what is going on with ASP.NET anymore. Why is MVC 5 not the default in Visual Studio 2015? I had to install a separate download to get the templates for it. Defaulting to beta software is not a good idea. I know you guys want to push everyone into using the latest and greatest code, but, this is ridiculous. I think you should just outright call it something else and not ASP.NET. Everything is different now. It used to be the case that one could work productively in ASP.NET. It is clear that that is all changing now. You may as well use Ruby On Rails now. It has to be better than this garbage. Adding a library should be a no brainer. Yet Microsoft has convinced itself that it needs to make everything cross platform. Now there are 10 different types of libraries. This is Silverlight all over again. I don't even think Microsoft cares about it's existing developer base. All they care about is parrotting all the other open source projects. Sorry for the rant, but, I don't see how this is an improvement. It doesn't help when it comes to getting real work done as opposed to constantly shuffling the deck chairs on the Titanic. This is exactly why I always liked .NET over Java. It was a productive environment. Now we are entering the days of Maven hell on .NET. |
Besides that, according to https://blogs.msdn.microsoft.com/dotnet/2015/12/09/support-ending-for-the-net-framework-4-4-5-and-4-5-1/. Support for .NET 4.5.1 is ending (already has). I have no idea why it is defaulting to that. Probably Microsoft isn't evening bothering to test on the full .NET Framework. |
Yeah this is pretty much a dead thread as so much of this changes with RC2 as it will no longer be using DNX at all and will be running on the .Net CLI |
We are redoing p2p references to standard c# projects. We will no longer be using wrap, we will replace it with something else. |
@sayedihashimi when do you think it will be released? |
👍 |
I believe I only did the manual restore after the creating the reference and that is what I think fixed it. I didn't close VS and reopen it and I don't think I did any saves either but I'm less certain about that. I have tried this many times over the past few days and the issue is easy to reproduce on my setup. It happens every time with these steps:
Now the project.json section looks like:
And the error appears. I can send you whatever you want at any step. |
Just tried your steps. After i add csproj reference in step 6. , auto restore happens and everything is resolved. Does auto-restore happen for you in step 6? Could you please do you repro steps again and see the error. After that zip whole solution with all projects and their lock and *.dg files and share with me? |
I just did the repo steps again and in step 5 when I save the project.json file I was mistaken, the auto restore does not happen, I have to do it manually. I guess this kinda explains why the auto-restore does not occur when I add the reference. I guess the thing that had me stumped is that it never occurred to me to force a Restore Packages manually when I got the error "The dependency ExampleLib could not be resolved" since its a local project in the solution. I'd be happy to zip up the whole solution and send it to you. Where should I send it? |
you can send it to my email anton.piskunov@microsoft.com. Now let's figure out why you don't have auto restore. Could you please double check your Nuget settings under Tools\Options\NuGet Package Manager. See if you have two check boxes on top checked: "Allow NuGet to download missing packages" and "Automatically check for missing packages ...". |
Both check boxes were unchecked which may have been something stupid I did long ago when working with RC1 before I understood much about NuGet. I have now checked them. abpiskunov you have been extremely helpful. Thank You! |
Can anyone comment on whether I can reference a compiled .dll in my project.json like so: "frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50",
"bin": {
"assembly": "Moserware.Skills.dll"
}
}
} I'm running the latest RC2 in OS X. When I try to reference the namespace it pulls the good ole are you missing an assembly reference? |
@jreeter Supposedly and assuming this assembly is at root with the project I personally wasn't able to make it work. But then again I wasn't using "netcoreapp1.0" for framework |
Hi , i am trying to update my project.json to use RC2, but i am not able to add the GAC assembly reference for net451 target framework . Can you please let me know how to add gac assemblies in project.json in RC2 ? |
@PrashanthIBM if you want to use gac assemblies then take a look at the ASP.NET Core Web (.NET Framework) template. Your |
@sayedihashimi or @davidfowl any ETA on when this critical issue will be fixed yet? |
@sayedihashimi i looked at it, but it is not able to refer the assemblies from GAC . |
This is a triple whammy:
The only way I've been able to get it to work is to point the dependant project to the .dll from the xproj after editing the project.json to include .NET 45 as well and then send the build dependency accordingly. Then it will work as a reference in the ASP NET CORE project AND will work in .NET 4.6 projects. Please get at least xproj with .NET Standard (without special target for .NET 4.6) loading as dependancies in .NET 4.6 project and compiling without any additional runtimes or anything required. I'm OK with converting to an xproj, but using the .dll isn't kosher for me and shouldn't be required. |
A lot of the issues are now fixed and this is a long thread. Please try with the latest build - https://github.com/aspnet/tooling/#pre-release-builds and open new issues. Thanks! |
I just installed Update 3 RC and .NET Core 1.0.0. RC3 - VS 2015 Tooling Preview 2 (Nightly - 6/17) and I could not reference dll within Asp.Net Core app. Really hoping it will be resolved in RTM. |
Same issue with Release Update3 and release core. Tooling preview 2 |
If that's true, that's completely pathetic. How do you have a release version of anything if something as basic as library references don't work. I ran into a separate issue where it appears that EF Core 1.0 RTM appears not to work with the full .NET Framework 4.6.1 and an ASP.NET Web Forms application. At first, I thought the problem was that I was upgrading from a previous version. Then, created a brand new project and reverse engineered the database following the instructions. Still the same problem. A version conflict on the System.Collections.Immutable library. Why even pretend this is RTM. Apparently, quality control went out the window with the switch to making everything run on Linux. |
"even to this day its still not working 12/07/2016" this does need resolving the idea of RC2 and RTM was to start being able to build production grade software with the new release, we cannot build production grade software when we cannot even reference a library outside of nuget, there are 2 other threads for this issue and many more on forums, stackoverflow etc, if you would look at it, this seems to be being put on the back bone yet its something which is critically required and to be quite frank is not really giving developers confidence in migrating to your new software, you would think some form of communication to the community about issues and time scales on resolution or even acknowledgement about the issues would be wise at this point. |
Maybe they solved it. (15/07/2016) |
@veljkocasa You don't mention how you were able to add the reference, but when I try through the GUI, Visual Studio gives the following message: So, I don't think this was addressed. Though I don't remember that error message before. Maybe that was added? |
There is a difference in referencing a "project" (as in a Library Project that resides in the same solution as the aspnet site) and referencing already compiled DLLs. Cross Project References always worked. |
No, referencing library projects did not originally work. I have no idea if it works now or not. At the moment, I don't have time to beta test alleged release software. |
Sorry, I've meant on cross project referencing, and for me it not working... |
FYI, you cannot add a .NET standard 1.x project as a reference to a .NET 4.6.1 project. It still fails to compile properly and intellisense doesn't work. The only way to do this is to link to the resulting DLL from the bin folder of the .NET standard project which of course causes issues. It will add it, it just wont' work right which is kind of embarrassing that this is still broken given how key to the whole "Universal" .NET core thing this is. |
This is very frustrating! Created WebApi .NetCoreApp, Version=1.0. Cannot reference libraries 4.6.1. The only way is to directly reference the assembly in the bin/debug folder. This won't work well for CI builds. I've read many things on this topic and its continuously clear a Mud!. So I created .NetCore SelfHost WebApi. Have an older 4.6.1 and cannot use it in the WebApi. This is great! The thing is, it builds with no error and the reference is added...but I cannot access it's objects from the WebApi. Here is the project.json "tools": { "frameworks": { "buildOptions": { "runtimeOptions": { "publishOptions": { "scripts": { |
Hi |
I think it will be fixed after .csproj/MSBuild will be able to build .net core/project.json/xproj directly According to (https://blogs.msdn.microsoft.com/dotnet/2016/07/15/net-core-roadmap/) - Q4 2016 / Q1 2017 |
I am running the RC of Visual Studio Enterprise on a Windows Server 2012 R2 Virtual Machine. Folder that solution is added to is part of a git repo.
Steps to reproduce:
Results:
"frameworks": {
"dnx451": {
"dependencies": {
"Recipe05.Dal": "1.0.0-*"
}
}
each folder has it's own project.json file with a bin configuration
"bin": {
"assembly": "../../obj/{configuration}/Recipe05.Dal.dll",
"pdb": "../../obj/{configuration}/Recipe05.Dal.pdb"
}
Error NuGet Package Restore failed for one or more packages. See details in the Output window.
Restoring packages for C:\MVC6Recipes\MVC6Recipes\Chapter06\Recipe05\src\Recipe05.Dal\wrap\Recipe05.Dal\project.json
GET https://www.nuget.org/api/v2/FindPackagesById()?Id='Recipe05.Dal'.
OK https://www.nuget.org/api/v2/FindPackagesById()?Id='Recipe05.Dal' 1081ms
Unable to locate Recipe05.Dal >= 1.0.0
The text was updated successfully, but these errors were encountered: