Skip to content

Commit 181b65d

Browse files
authored
Save the project file after package operation in the PM UI (#6295)
* Save the project after package installation * Save project after uninstall * Save legacy project references
1 parent 139cef5 commit 181b65d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/ProjectServices/VsManagedLanguagesProjectSystemServices.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ private void AddOrUpdatePackageReference(string packageName, VersionRange packag
323323
packageVersion.OriginalString ?? packageVersion.ToShortString(),
324324
metadataElements,
325325
metadataValues);
326+
327+
_vsProject4.Project.Save();
326328
}
327329

328330
public async Task RemovePackageReferenceAsync(string packageName)
@@ -332,6 +334,7 @@ public async Task RemovePackageReferenceAsync(string packageName)
332334
await _threadingService.JoinableTaskFactory.SwitchToMainThreadAsync();
333335

334336
_vsProject4.PackageReferences.Remove(packageName);
337+
_vsProject4.Project.Save();
335338
}
336339

337340
private bool IsCentralPackageManagementVersionsEnabled()

src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/CpsPackageReferenceProject.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,12 @@ await SetPackagePropertyValueAsync(
346346
ProjectItemProperties.IncludeAssets,
347347
MSBuildStringUtility.Convert(LibraryIncludeFlagUtils.GetFlagString(installationContext.IncludeType)));
348348
}
349+
349350
}
350351

352+
// Save the project
353+
await _unconfiguredProject.SaveAsync();
354+
351355
return true;
352356
}
353357

@@ -400,6 +404,10 @@ public override async Task<bool> UninstallPackageAsync(string packageId, BuildIn
400404

401405
await configuredProject?.Services.PackageReferences.RemoveAsync(packageId);
402406
}
407+
408+
// Save the project
409+
await _unconfiguredProject.SaveAsync();
410+
403411
return true;
404412
}
405413

0 commit comments

Comments
 (0)