Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Ward <matt.ward@microsoft.com>2018-03-28 18:20:48 +0300
committerMatt Ward <matt.ward@microsoft.com>2018-03-28 18:20:48 +0300
commitc507df018a57327200fc447c530489cab0c2dade (patch)
treeee8b0db262a2444684986e36424b1700379c47ef /main/src/core
parentc096a1571ea6843dd0e852b71c886b146d6a523f (diff)
[Core] Fix references not saved on installing NuGet packages
The fix applied in commit c459d3c6388d667be6aaf10d466d3367a95555bd now means that Project.ReevaluateProject can be called at the same time as NuGet packages are being installed if those NuGet packages contains MSBuild imports. When creating a new Xamarin.Forms project references are added to the Android project at the same time that the ReevaluateProject method is called, indirectly when the type system calls GetSourceFilesAsync and causes the CoreCompileDependsOn targets to be run. During the call to MSBuildProject.EvaluateAsync, which the ReevaluateProject method awaits on, the UI thread can be used to add a new reference to the project. If the project is not saved the MSBuildProject is not updated so the LoadProjectItems was removing the references added to the project since they do not exist in the evaluated items. When the project is then saved by the NuGet addin the reference is not in the .csproj file. Now items added to the project whilst MSBuildProject.EvaluateAsync is called in ReevaluteProject are captured and LoadProjectItems takes these into account to ensure they are not lost. Fixes VSTS #586393 Getting multiple errors on building Forms App
Diffstat (limited to 'main/src/core')
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs30
1 files changed, 28 insertions, 2 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs
index ff4e9112c5..141ebcaedc 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs
@@ -2326,6 +2326,12 @@ namespace MonoDevelop.Projects
throw new InvalidOperationException (it.GetType ().Name + " already belongs to a project");
it.Project = this;
}
+
+ if (monitorItemsModifiedDuringReevaluation) {
+ if (itemsAddedDuringReevaluation == null)
+ itemsAddedDuringReevaluation = ImmutableList.CreateBuilder<ProjectItem> ();
+ itemsAddedDuringReevaluation.AddRange (objs);
+ }
NotifyModified ("Items");
if (ProjectItemAdded != null)
@@ -2346,6 +2352,9 @@ namespace MonoDevelop.Projects
NotifyFileRemovedFromProject (objs.OfType<ProjectFile> ());
}
+ bool monitorItemsModifiedDuringReevaluation;
+ internal ImmutableList<ProjectItem>.Builder itemsAddedDuringReevaluation;
+
internal void NotifyFileChangedInProject (ProjectFile file)
{
OnFileChangedInProject (new ProjectFileEventArgs (this, file));
@@ -2955,9 +2964,16 @@ namespace MonoDevelop.Projects
}
}
}
- if (IsReevaluating)
+ if (IsReevaluating) {
+ if (itemsAddedDuringReevaluation != null) {
+ // Handle new items added whilst re-evaluating the MSBuildProject.
+ foreach (var item in itemsAddedDuringReevaluation) {
+ unusedItems.Remove (item);
+ localItems.Add (item);
+ }
+ }
Items.SetItems (localItems, newItems, unusedItems);
- else
+ } else
Items.AddRange (localItems);
}
@@ -4012,6 +4028,12 @@ namespace MonoDevelop.Projects
{
return BindTask (ct => Runtime.RunInMainThread (async () => {
using (await writeProjectLock.EnterAsync ()) {
+
+ if (modifiedInMemory) {
+ await Task.Run (() => WriteProject (monitor));
+ modifiedInMemory = false;
+ }
+
var oldCapabilities = new HashSet<string> (projectCapabilities);
bool oldSupportsExecute = SupportsExecute ();
@@ -4019,7 +4041,9 @@ namespace MonoDevelop.Projects
IsReevaluating = true;
// Reevaluate the msbuild project
+ monitorItemsModifiedDuringReevaluation = true;
await sourceProject.EvaluateAsync ();
+ monitorItemsModifiedDuringReevaluation = false;
// Loads minimal data required to instantiate extensions and prepare for project loading
InitBeforeProjectExtensionLoad ();
@@ -4031,6 +4055,8 @@ namespace MonoDevelop.Projects
} finally {
IsReevaluating = false;
+ monitorItemsModifiedDuringReevaluation = false;
+ itemsAddedDuringReevaluation = null;
}
if (resetCachedCompileItems)