-
Notifications
You must be signed in to change notification settings - Fork 329
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
Packages install path can again be edited from preferences window #619
Conversation
Thank you! You did a good job! It would be better to be more explicit or display a note in Preferences. |
Yes, you are right. Tomorrow I will remove that part and display an error message somewhere in the window. |
Do you plan to add something to explicitly generate a NuGetPackages folder? |
I was thinking to just display a message like "If you want install under Packages folder create a subfolder in it and select that one" if user just selects the Packages folder itself. I would not create NuGetPackages folder myself. |
I think the final goal should be support a Folder structure like:
There are multiple requests about how to get all the NuGetForUnity related files out of the
Eventually we can even ask for generating a This PR more or less is also a step into the direction or? What do you think about this? Do you see any potential issues? |
/// Gets or sets the incomplete path that is saved. The path is expanded and made public via the property above. | ||
/// </summary> | ||
[NotNull] | ||
public string RelativeRepositoryPath |
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.
public string RelativeRepositoryPath | |
internal string ConfiguredRepositoryPath |
The important part is that this ist the path that is stored inside the NuGet.config
, it can be absolute / relative / contain environment variables. Eventually there is a even better name.
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 think the original name "savedRepositoryPath" is not so bad.
This is what I wanted to do before my PR!
I didn't know them.😮
So it seemes that the folder and package.json.name should be something like |
Ok. I should change this but I don't think I can do it before my trip (I will be off from 14th to 28th February) so hopefully when I get back. What do we want to present in Preferences? Maybe something like this: Nuget Placement: <DropDown with options: "Custom within Assets" and "In Packages folder"> If |
I agree with you! Any progress? |
I had a number of issues to solve in moving files around but I think I got them all now. |
@igor84 But I found 2 non-serious problems.
|
I found followings can solve them. private NugetPreferences()
: base("Preferences/NuGet For Unity", SettingsScope.User)
{
shouldShowPackagesConfigPathWarning = !UnityPathHelper.IsPathInAssets(ConfigurationManager.NugetConfigFile.PackagesConfigDirectoryPath);
+ if (ConfigurationManager.NugetConfigFile.Placement == NugetPlacement.InPackagesFolder)
+ {
+ AssetDatabase.Refresh();
+ } var newPlacement = (NugetPlacement)EditorGUILayout.EnumPopup("Placement:", ConfigurationManager.NugetConfigFile.Placement);
if (newPlacement != ConfigurationManager.NugetConfigFile.Placement)
{
var oldRepoPath = ConfigurationManager.NugetConfigFile.RepositoryPath;
InstalledPackagesManager.UpdateInstalledPackages(); // Make sure it is initialized before we move files around
ConfigurationManager.MoveConfig(newPlacement);
var newRepoPath = ConfigurationManager.NugetConfigFile.RepositoryPath;
+ if (newPlacement == NugetPlacement.CustomWithinAssets)
+ {
+ shouldShowPackagesConfigPathWarning = !UnityPathHelper.IsPathInAssets(ConfigurationManager.NugetConfigFile.PackagesConfigDirectoryPath);
+ } |
You solution would execute AssetDatabase.Refresh every time preferences is opened once Placement is set to Packages folder. I found another solution but while experimenting I discovered that if you have a source package that doesn't have asmdef you will get errors like this from unity:
How should we handle this? Do nothing and let user handle that error when he sees it, write a warning about it to the user in prefs window or should we actually detect such packages and refuse the move to Packages in such cases? |
Oh, this change has caused DLL migration to fail. |
@@ -567,7 +553,8 @@ public override void OnGUI([CanBeNull] string searchContext) | |||
|
|||
if (needsAssetRefresh) | |||
{ | |||
AssetDatabase.Refresh(); | |||
// AssetDatabase.Refresh(); doesn't work when we move the files from Assets to Packages so we use this instead: |
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.
Doing both works well!
Erasing AssetDatabase.Refresh();
causes error.
I think it would be better to display the warning. |
Yes. Almost all internal packages in my company are source packages, they are not precompiled dlls. But they do currently all have asmdefs although we added them last year, before they didn't have asmdefs. |
I think that NuGetForUnity is used mostly to import packages from |
I think they will get the same error after installing source package as they will get when moving it. |
Yes but they wouldn't know how to solve them. |
I've been thinking about this. The solution is medium complexity but I feel there is a good chance this will not be a problem in practice. I would rather that we don't solve it unless we see it really is a problem. Like people opening issues regarding this. What do you think? |
Seems like a legit option. |
I have discovered that moving the .dll.meta file is the cause of the error that sometimes occurs when moving dll files. |
I've been testing moving packages with NewtonsoftJson dll installed the whole time and I never got any error. Do you have some specific package you want me to try this with? Without reproducing the issue I wouldn't do anything. |
@igor84 There's no error on version 2021.3.23. |
Unity also claims they fixed this issue in 2022.3.21 but I am still waiting to see if they can provide any kind of workaround for the versions where it doesn't work. |
Even if an error occurs, it can be fixed by restarting the editor or prevented by reinstalling the packages, so it may not be so bad that we have to wait for an official solution. A possible solution would be to temporarily evacuate the meta file to another location or rename it and overwrite the .dll.meta setting that was generated after the dll was successfully loaded. |
That would still cause the secondary recompile. Since it should be fixed in newer Unity I would leave it like this and only if they provide me with some workaround would I add that. |
I got this response from Unity:
Considering this I would say this is ok to be merged in this state. |
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.
the rest looks nice 👍
probably you can run the code formatter
|
It should work. How did you determine it is not working? |
When I run "dotnet nugetforunity restore" with the config file in the PackagesFolder, I get a message "No NuGet.config file found. Creating default at ~~~". |
#630 is not supported by Cli as well. |
This feature is not present in 4.0.2 which is latest on nuget.org. Does that mean you built nugetforunity yourself from the latest master? We are yet to release a new version with this and #630 feature. |
I apologize for my language, which was difficult to understand. |
No description provided.