diff --git a/src/NuGetForUnity/Editor/NugetPackageInstaller.cs b/src/NuGetForUnity/Editor/NugetPackageInstaller.cs
index 25b07576..88267384 100644
--- a/src/NuGetForUnity/Editor/NugetPackageInstaller.cs
+++ b/src/NuGetForUnity/Editor/NugetPackageInstaller.cs
@@ -118,7 +118,7 @@ private static PackageInstallOperationResult Install(
installedPackage.Version,
package.Version,
package.Version);
- return NugetPackageUpdater.UpdateWithInformation(installedPackage, package, refreshAssets);
+ return NugetPackageUpdater.UpdateWithInformation(installedPackage, package, refreshAssets, isSlimRestoreInstall);
}
if (comparisonResult > 0)
@@ -131,7 +131,7 @@ private static PackageInstallOperationResult Install(
installedPackage.Id,
installedPackage.Version,
package.Version);
- return NugetPackageUpdater.UpdateWithInformation(installedPackage, package, refreshAssets);
+ return NugetPackageUpdater.UpdateWithInformation(installedPackage, package, refreshAssets, isSlimRestoreInstall);
}
NugetLogger.LogVerbose(
diff --git a/src/NuGetForUnity/Editor/NugetPackageUninstaller.cs b/src/NuGetForUnity/Editor/NugetPackageUninstaller.cs
index 826bffb7..a242b150 100644
--- a/src/NuGetForUnity/Editor/NugetPackageUninstaller.cs
+++ b/src/NuGetForUnity/Editor/NugetPackageUninstaller.cs
@@ -20,11 +20,12 @@ public static class NugetPackageUninstaller
/// The NugetPackage to uninstall.
/// The reason uninstall is being called.
/// True to force Unity to refresh its Assets folder. False to temporarily ignore the change. Defaults to true.
- public static void Uninstall([NotNull] INugetPackageIdentifier package, PackageUninstallReason uninstallReason, bool refreshAssets = true)
+ /// True if uninstall needs to be done as part of slim restore operation.
+ public static void Uninstall([NotNull] INugetPackageIdentifier package, PackageUninstallReason uninstallReason, bool refreshAssets = true, bool isSlimRestore = false)
{
// Checking for pre-imported packages also ensures that the pre-imported package list is up-to-date before we uninstall packages.
// Without this the pre-imported package list can contain the package as we delete the .dll before we call 'AssetDatabase.Refresh()'.
- if (UnityPreImportedLibraryResolver.IsAlreadyImportedInEngine(package.Id, false))
+ if (!isSlimRestore && UnityPreImportedLibraryResolver.IsAlreadyImportedInEngine(package.Id, false))
{
Debug.LogWarning($"Uninstalling {package} makes no sense because it is a package that is 'pre-imported' by Unity.");
}
@@ -44,7 +45,7 @@ public static void Uninstall([NotNull] INugetPackageIdentifier package, PackageU
PackageContentManager.DeletePackageContentPackage(foundPackage);
// Since uninstall all will remove all packages we don't have to handle dependencies here.
- if (uninstallReason != PackageUninstallReason.UninstallAll)
+ if (uninstallReason != PackageUninstallReason.UninstallAll && !isSlimRestore)
{
// uninstall all non manually installed dependencies that are not a dependency of another installed package
var frameworkDependencies = foundPackage.CurrentFrameworkDependencies;
diff --git a/src/NuGetForUnity/Editor/NugetPackageUpdater.cs b/src/NuGetForUnity/Editor/NugetPackageUpdater.cs
index f6ac22fa..eeb3ae0e 100644
--- a/src/NuGetForUnity/Editor/NugetPackageUpdater.cs
+++ b/src/NuGetForUnity/Editor/NugetPackageUpdater.cs
@@ -27,7 +27,7 @@ public static bool Update(
bool refreshAssets = true,
PackageUninstallReason uninstallReason = PackageUninstallReason.IndividualUpdate)
{
- var result = UpdateWithInformation(currentVersion, newVersion, refreshAssets, uninstallReason);
+ var result = UpdateWithInformation(currentVersion, newVersion, refreshAssets, false, uninstallReason);
return result.Successful;
}
@@ -73,18 +73,20 @@ public static void UpdateAll(
/// The current package to uninstall.
/// The package to install.
/// True to refresh the assets inside Unity. False to ignore them (for now). Defaults to true.
+ /// True if update needs to be done as part of slim restore operation.
/// The reason uninstall is being called.
/// The information about how the package has been installed.
internal static PackageInstallOperationResult UpdateWithInformation(
[NotNull] INugetPackageIdentifier currentVersion,
[NotNull] INugetPackage newVersion,
bool refreshAssets = true,
+ bool isSlimRestoreInstall = false,
PackageUninstallReason uninstallReason = PackageUninstallReason.IndividualUpdate)
{
NugetLogger.LogVerbose("Updating {0} {1} to {2}", currentVersion.Id, currentVersion.Version, newVersion.Version);
- NugetPackageUninstaller.Uninstall(currentVersion, uninstallReason, false);
+ NugetPackageUninstaller.Uninstall(currentVersion, uninstallReason, false, isSlimRestoreInstall);
newVersion.IsManuallyInstalled = newVersion.IsManuallyInstalled || currentVersion.IsManuallyInstalled;
- return NugetPackageInstaller.Install(newVersion, refreshAssets);
+ return NugetPackageInstaller.Install(newVersion, refreshAssets, isSlimRestoreInstall);
}
}
}