-
Notifications
You must be signed in to change notification settings - Fork 286
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
Upgraded nuget to 5.4 #740
Conversation
.LocalRepository | ||
.GetPackages() | ||
.ToArray(); | ||
IEnumerable<PackageIdentity> allInstalledPackages = this.manager.GetInstalledPackages(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetInstalledPackages relies on reading out the package.config file to see what packages are installed however duality also has logic for this already and iam not sure how to merge these in a clean way. @ilexp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I cannot simply remove that logic from the manager as that would break this code.
I think duality shouldn't have anything to do with reading out a package.config file and should just leave that to nuget and friends. Whenever it needs this info it should simply ask the manager for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I think that a installed package
does not mean that the package is registered in the package.config but that its actually restored to the source/packages folder.
However with the new nuget this doesn't happen anymore due to the global package folder and thus clashes a bit with this approach. Ofcourse one can still add this back in manually...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh yet again duality is removing packages that shouldn't be removed. That package that the error is complaining about is actually installed but then later on removed by duality.
@ilexp idk how to fix this, why is duality modifying the packages folder in the first place? That is nugets reponsibility and not duality. I feel duality is doing way too much and that is now all getting in the way of this upgrade.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only skimmed the above thread since I'm very low on time right now, but it seems like you might have gone off the wrong track somewhere, correct me if I misunderstood. Short version from what I gathered:
Nuget manages the packages folder (or global packages folder in v5.x)
That's already the case.
Nuget manages the packages.config
That's already the case as well.
Edit: If there is one, that is. Not sure, now that I think of it, I don't think a packages.config in the traditional .csproj sense is even used at all in the current implementation.
Duality manages the plugin and lib folders
And this one too!
The only way in which you could say that Duality handles the first two points is via the actual NuGet API. It's possible that this API no longer exists, or some of the concepts changed in newer NuGet, but it's not intention that Duality would do either of those - and as far as I remember, it shouldn't in the current implementation.
The outline of the current / old implementation that is probably related to some of the issues that arose:
- Duality has a list of (Duality-only!) packages in
PackageConfig.xml
. This is a letter of intent which (Duality only!) packages there should be. - Duality sets up NuGet with the local
Packages
folder and asks it which packages are currently installed. Internally, I assume NuGet figures that out by checking folders and files. - Duality then asks Nuget to remove those that aren't on the list, and to install those that are, in order to sync whatever state the NuGet stuff is in with the intended state that the Duality config specifies. Dependencies and everything are handled by NuGet, Duality has no knowledge of packages that wouldn't show up in its own package manager.
- To apply the package install to plugin and lib folders, Duality registers a NuGet event that fires when packages are installed or uninstalled, and uses the provided info to copy files as needed.
Side note: In the old NuGet at least, "install" meant the package is physically in the right place and extracted, not in some config list, and "uninstall" meant that it is physically removed from there.
To summarize, Duality has a list of its own packages it wants and uses NuGet API to make sure NuGet syncs that up, plus dependencies and whatever is needed. It also uses NuGet API to figure out where it put things and when they are added or removed to sync its own plugin / lib folder files.
Let me know if that helps, will try to check back soon-ish.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duality then asks Nuget to remove those that aren't on the list, and to install those that are, in order to sync whatever state the NuGet stuff is in with the intended state that the Duality config specifies. Dependencies and everything are handled by NuGet, Duality has no knowledge of packages that wouldn't show up in its own package manager.
So this is causing it to break atm since its removing packages that duality packages depend on that shouldnt be removed. I don't know how to fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, it shouldn't remove any non-Duality packages, and even if it removes a Duality package that later turns out to be a dependency of one that is needed, that should be fixed right after when it verifies that every expected package is installed. It's more of an edge case though that doesn't happen that often, so I'd guess it's some sort of a bug that the package is removed in the first place.
As soon as I manage to carve out some time, I'll have a look as well, see if I can help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm maybe I broke something in that area then
What about just ignore cleaning the package folder btw? I don't believe visual studio did that anyway. Besides this behavior is simply not compatible with the global nuget packages folder (which is why I make a copy of it...). Would be much nicer not having to copy that package over and just grab it from the global nuget packages folder I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about just ignore cleaning the package folder btw?
The reason it's doing that is not just cleaning the package folder, but a necessary step (for the current implementation anyway) to find out which actual files to remove from plugin and lib folders via the events that NuGet 2.x fires on uninstall, including dependencies.
For the current implementation, the packages folder isn't a side effect or cache we could just ignore, but NuGet's "working memory". From what I gather from your progress reports and comments, this is no longer the case anyway, so I assume some things on the implementation will change in that regard. What we still need is some automated uninstall of Duality packages (+ deps) that are no longer in the PackageConfig.xml
despite being previously installed - and vice versa, an auto-install for those that are in there, but not installed yet.
Use cases:
- Pull update from version control, run editor. It should match the local packages with what's checked in via
PackageConfig.xml
, i.e. account for added and removed ones. - User manually edits
PackageConfig.xml
, then starts the editor. - Something in the package manager goes really wrong and Duality crashes. A restart can bring packages back in order.
So, assuming the new NuGet doesn't have any equivalent to a local package folder / working memory, then the Duality package manager will need some way to find out
- Which files to copy or remove when a package is installed / uninstalled. (You probably got that figured out already)
- Which items in
PackageConfig.xml
are not currently present in the project and need an install. - Which packages that are currently present in the project are not in
PackageConfig.xml
and need an uninstall.
In other words, there needs to be a way to ask for the "status quo" of current package installs, so we can diff it with the "letter of intent" in the PackageConfig.xml
to find out what needs to be done. Previously, that was achieved via NuGet API (this.manager.LocalRepository
, which used the packages folder) and then encapsulated in Duality local setup data. Is there any equivalent in NuGet 5, which we can query for project "status quo"?
If there isn't, we could come up with something custom, like a second, internal package config representing the actual local setup, or similar.
If I understand correctly you want a list of all packages needed including all dependencies. Nuget provides a API for this and the I believe the nuget class we need for this is called DependencyResource or similar. |
Ah, no, not the needed ones - I might have explained it all a bit convoluted. I'll try again, in short. This is what we have now:
What we need now, since the packages folder no longer seems to play that role in NuGet:
That second |
Rebased on the latest master. Changes are now down from 39 to 9 files :) |
Isn't this something duality could provide based upon the files present in the plugin folder? Might need to split it up to prevent ambiguity between packages and dll's that were just copied there? Not depending on nuget for this would make future updates easier so design wise this be would be preferable. Nuget doesn't have logic for this anyway so the only way is to add another layer in between. |
In that case, I'd probably go with an I can look into this, provided I manage to carve out some time, fingers crossed 😄 |
Yup might be better that you look into this particular part. In the current commit of this PR there is still the package config on the nuget side that is not needed anymore I think btw. |
var nuGetFramework = NuGetFramework.Parse("net472"); | ||
var settings = NuGet.Configuration.Settings.LoadDefaultSettings(root: null); | ||
this.logger = new PackageManagerLogger(); | ||
this.manager = new NuGetTargetedPackageManager(nuGetFramework, this.logger, settings, this.env.RepositoryPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like the package repository URLs from the Duality PackageSetup
are currently ignored, which also breaks most of the package tests because they create a local repository to source from. How do we specify repository URLs with NuGet 5?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is possible and I think I saw the API somewhere but currently not at my pc to check this. Will check it later.
this._nuGetFramework = nuGetFramework; | ||
this._packagePathResolver = new PackagePathResolver(packagePath); | ||
var sourceRepositoryProvider = new SourceRepositoryProvider(this._settings, Repository.Provider.GetCoreV3()); | ||
this._repositories = sourceRepositoryProvider.GetRepositories().ToArray(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we have to modify this to define custom nuget repositories
Okay, so right now I'm the bottleneck for moving this forward, but I'll try to briefly summarize what I think needs to be done here before we can merge: ToDo
I'll report back with progress and help requests as soon as I get to it. |
@ilexp do you still have time to implement this? If not maybe we should make it clear that somebody else can take it over. Not that I have much time lately though... |
Good call - I'm honestly a bit overwhelmed with real life stuff lately and since I'm clearly the bottleneck here, I'd be happy to let someone take over, and try to help with advice. |
… relative path being passed to packagepathresolver
Upgraded to nuget 5.4 so we stay up to date. Currently working on getting the unit tests working properly again. Turns out we still referenced the old nuget 2.14 in the unit tests (FIXED). Also its currently not using the test repository that the unit tests sets up which breaks many tests. |
Seems like PackagePathResolver and PackageIdentity truncate the revision number. Meaning a version like 1.0.0.0 will end up as 1.0.0. Seems nuget doesnt want you to use 1.0.0.0? Needs some more research to be sure. EDIT: nuget is normalizing the version numbers: https://docs.microsoft.com/en-us/nuget/concepts/package-versioning#normalized-version-numbers |
Closing this as we have decided to take a different route in #786 |
Not ready to merge yet. Prerequisites: