-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nuget Restore Circular Dependency #1428
Comments
The though here is that project names and packages name are interchangeable. So Project to Project references are treated the same as package dependencies. This is not yet a common pattern in nuget, and more so in DNX. But this is the path going forward |
Project to Project references make sense when you are referencing a different project. That behavior is pretty useful. A project should never reference itself though, so my thought is why does the current project satisfy the dependency? |
These are plans to let you specify the ID of the package in project.json but the behavior would be the same in either case. The project itself is part of your dependency graph. |
I appreciate the quick responses! I am working through this issue currently. Specifying the ID of the package would be very useful as a workaround to this issue. Is this implemented or still planned? In what situation though should the project currently being restored be used to satisfy a dependency? I don't think I understand the whole picture here. I think the core of my question is why is the current project a part of the dependency graph? |
Because projects and packages are going to be interchangeable in this new world. The entire idea is that nuget is fully integrated into the workflow (not an addon). With project.json NuGet understands the full P2P graph as well as the package dependencies that go into it. If you're using project.json with a csproj, it's conceivable that we can name things based on the csproj instead of the folder, xproj has this current limitation however |
I'm with @brthor on this one -- the current project should never be part of a dependency graph for the project you are building -- E.g. in this case, if you're building "Foo" and you have "Foo" in your project.json, the default behavior should be to ignore the project references (where projectname being built == reference name) and go straight to package resolution... In other words it should be a special case that excludes the current project from the list of potential project references |
@davidfowl Even though projects and packages are interchangeable, adding the current project to the dependency graph only seems to enable the scenario where a project references itself. The only other scenario I can think of is when Project A references Project B which references Project A, but this is a circular dependency and isn't supported anyways. @mcse3010 This is exactly along the lines I am thinking. Are there scenarios that break from introducing the special case as @mcse3010 detailed? |
I still don't get why we should add it with any urgency and why would you name your project system.console? Special cases add complexity and we should be very careful with them. We do want to detect and for id circular dependencies which is what this code does. |
System.Console was purely an example. I could see this being an issue for any package authors who unwittingly create directory structures with the names of their package(s). In my particular case, we had a large number of directory structures created in such a way to trigger this behavior. It took quite some time to figure out what was happening. The most perplexing part is that it seems to pick the current project over the package even though the current project does not meet the version requirements. I can see how this is important for identifying circular dependencies though. Removing the current project from the graph entirely would break circular dependency detection, but simply ignoring the current project as a potential project reference should not. |
Package authors would/should never name another one of their projects as the package name. This will be the package project itself. Not against fixing it, it is just very low priority. From: Bryan Thornburymailto:notifications@github.com System.Console was purely an example. I could see this being an issue for any package authors who unwittingly create directory structures with the names of their package(s). In my particular case, we had a large number of directory structures created in such a way to trigger this behavior. It took quite some time to figure out what was happening. The most perplexing part is that it seems to pick the current project over the package even though the current project does not meet the version requirements. I can see how this is important for identifying circular dependencies though. Removing the current project from the graph entirely would break circular dependency detection, but simply ignoring the current project as a potential project reference should not. — |
I certainly did not mean to imply any urgency -- it is definitely an edge |
Fair enough. Only a small number of people should hit this and the workaround is as simple as renaming your parent directory, so I agree this is not particularly urgent. |
I am experiencing this problem with a directory structure like this (In a dotnet core project) /src/Company.Project/project.json If i rename |
Some of my solutions consist of a lot of projects (500+, many of which are non open source), and include a fair number of third-party components. While converting to MVC6, I experienced an odd error message:
This happened while converting our Softelvdm.Twilio package to MVC6. It's a YetaWF package that implements sending SMS (text messages) using Twilio's service. The project is aptly named Twilio in our solution. It has been named that for a long time (in Visual Studio 2013, 2015, 2017) while using MVC5. The NuGet package is also named Twilio. So now with the great and improved ASP.NET Core MVC and the updated Visual Studio tooling, NuGet packages used in any solution pollute the solution's project name space. So when I reference the Twilio NuGet package it was in conflict with my own project named Twilio. The decision to elevate referenced packages to "solution projects" (or make all projects NuGet packages) in the same namespace, has a direct impact on non-trivial solutions and is an unnecessary complication. Given that there is no way to specify the source of the package (Nuget vs. Solution) in project.json, I have to assume this ship has sailed and we chalk this up to another unfortunate decision made in designing the new and improved way of doing things. Wouldn't life be sweet if I could do this to disambiguate the reference (notice "nuget:"):
Renaming my project is not sufficient as I then get this:
I also have to rename the folder to the new name. Someone suggested this will only hit a "small number of people". True. But, for the chosen few, it may cause a significant amount of work. Changing a project and folder name in my case forces updates in customer facing documentation, recreating old (MVC5) packages to match, and probably the occasional phone call explaining that the project name and folders have changed. Thank you for letting me vent. |
Package-Project duality is where NuGet has migrated since the packages.config world. Closing this as won't fix. |
We are running into this. We've had many packages created the same way (for months) and all of a sudden our latest package is complaining about this issue, stating that it is referencing itself. It seems like this is an issue that shouldn't go unresolved. In our case, it has a nasty cascading effect on all of our users and documentation. You claim that it will only affect a "small number of people" - the issue is bigger than the number of packages it affects. It is the cascading issue that is the problem. I don't think moving forward with such a design flaw is a wise move. What can be done to correct this? BTW - we used built in project templates to create our projects in our solution and then used the built-in packaging options in the project (.NET Standard) to create this package. This shouldn't just be broken out of the box like this! |
@nkolev92 Don't you think it is extreme to just close this as "won't fix" (you are committing to NEVER fixing a problem that you may not know how much impact it really has). It would be better to just leave it open and say it currently isn't a priority. Instead you are saying you choose to leave the flaw, because that's how you roll (that leaves a bad taste in the mouth). Who else can we include in this conversation to really discuss the direction that these packages are going? To be clear: this issue is showing up in situations that it shouldn't (e.g. We have project folder names that just CONTAIN the name of the package, and that's an issue too). Isn't Microsoft developing out in the open now? I fail to see how this was any kind of collaboration. I think there are pockets like this, where the developers are being mistreated and overlooked (which gives Microsoft a bad name), while other projects by Microsoft are being very collaborative and cooperative with the community. Your built-in tooling creates the issue for people (out of the box). That should be addressed. |
https://yetawf.com/BlogEntry/Title/Project%20Names%20and%20NuGet%20Package%20Names/?BlogEntry=1007 Quote from this URL:
|
One last thing to vent on (I promise) - I sent an email to 'support@nuget.org' We described our issue in detail and provided the xml for the project file and have had ZERO response. Yet, this email is posted on the nuget.org site for people to request support. |
I've run into an issue where having a directory containing a project.json and named the same as one of the dependencies causes a Circular Dependency.
To repro create a directory structure like so:
System.Console (directory)
-> project.json
Then put System.Console as a dependency in the project.json:
Running "nuget.exe restore ./project.json" on this will cause the following error:
This behavior is perplexing, and the cause is very difficult to track down from the error message. Is there a reason this behavior exists or is it a bug?
I'm using nuget.exe 3.2.0.10516
The text was updated successfully, but these errors were encountered: