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:
authorLluis Sanchez <llsan@microsoft.com>2017-09-14 19:56:39 +0300
committerLluis Sanchez <llsan@microsoft.com>2017-09-14 20:09:03 +0300
commitf20c2a1e5593008318bc216de41338910a2818cf (patch)
treeb9198f152beda79b76fff0ad72e51cf9694f6ae1 /main/src/core/MonoDevelop.Projects.Formats.MSBuild
parent93199d71b5c3209cb5a3c76475b0fc398219f990 (diff)
Fixes performance issue running msbuild targets
The problem was that when a project is modified and then refreshed in the remote builder, the builder would unload not only the modified project, but all loaded projects. This issue was introduced in this commit: mono/monodevelop@ebf6c0a, when trying to fix another bug (23435). This fix was slowing down project loading because during source analysis, several projects were marked for refresh, which caused all loaded projects to be unloaded, so projects had to be loaded again and again. It was much worse when installing .NET Core 2.0 because for some reason, .NET Standard projects are much slower to evaluate when it is installed, (but that's a different issue), and Main.sln has one of such projects: RefactoringEssentials. The bug that the original commit was fixing was that target files imported by an msbuild project are not reloaded if they change in disk. This patch fixes this specific reloading problem, and then reverts the previous fix. Fixes bug #58586 - Evaluation is slow with .netcore 2.x installed
Diffstat (limited to 'main/src/core/MonoDevelop.Projects.Formats.MSBuild')
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.v4.0.cs31
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/ProjectBuilder.v4.0.cs31
2 files changed, 43 insertions, 19 deletions
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.v4.0.cs b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.v4.0.cs
index c65576afbf..9d97c3f9b5 100644
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.v4.0.cs
+++ b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.v4.0.cs
@@ -56,7 +56,7 @@ namespace MonoDevelop.Projects.MSBuild
public ProjectBuilder LoadProject (string file)
{
return new ProjectBuilder (this, engine, file);
- }
+ }
public void UnloadProject (ProjectBuilder pb)
{
@@ -79,17 +79,26 @@ namespace MonoDevelop.Projects.MSBuild
}
internal void UnloadProject (string file)
- {
- lock (unsavedProjects)
- unsavedProjects.Remove (file);
-
+ {
RunSTA (delegate
- {
- // Unloading the project file is not enough because the project
- // may be referencing other target files which may have
- // changed and which are cached.
- engine.UnloadAllProjects();
- });
+ {
+ // Unloading projects modifies the collection, so copy it
+ var loadedProjects = engine.GetLoadedProjects(file).ToArray();
+
+ if (loadedProjects.Length == 0)
+ return;
+
+ var rootElement = loadedProjects[0].Xml;
+
+ foreach (var p in loadedProjects)
+ engine.UnloadProject(p);
+
+ // Try to unload the projects' XML from the cache
+ // This could fail if something else is referencing the xml somehow.
+ // But not a big deal, it's just a cache.
+
+ engine.TryUnloadProject(rootElement);
+ });
}
}
} \ No newline at end of file
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/ProjectBuilder.v4.0.cs b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/ProjectBuilder.v4.0.cs
index e352ce770d..804fb76762 100644
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/ProjectBuilder.v4.0.cs
+++ b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/ProjectBuilder.v4.0.cs
@@ -136,7 +136,7 @@ namespace MonoDevelop.Projects.MSBuild
}
});
return result;
- }
+ }
Project SetupProject (ProjectConfigurationInfo[] configurations)
{
@@ -150,6 +150,13 @@ namespace MonoDevelop.Projects.MSBuild
project = p;
}
+ // Reload referenced projects if they have changed in disk. ProjectCollection doesn't do it automatically.
+
+ foreach (var p in project.Imports) {
+ if (p.ImportedProject.LastWriteTimeWhenRead != File.GetLastWriteTime (p.ImportedProject.FullPath))
+ p.ImportedProject.Reload (false);
+ }
+
var projectDir = Path.GetDirectoryName (file);
if (!string.IsNullOrEmpty (projectDir) && Directory.Exists (projectDir))
Environment.CurrentDirectory = projectDir;
@@ -169,7 +176,7 @@ namespace MonoDevelop.Projects.MSBuild
Directory.CreateDirectory (Path.Combine (projectDir, "obj"));
var content = buildEngine.GetUnsavedProjectContent (file);
- if (content == null)
+ if (content == null)
p = engine.LoadProject (file);
else {
if (!string.IsNullOrEmpty (projectDir) && Directory.Exists (projectDir))
@@ -184,12 +191,20 @@ namespace MonoDevelop.Projects.MSBuild
}
}
- p.SetGlobalProperty ("CurrentSolutionConfigurationContents", slnConfigContents);
- p.SetGlobalProperty ("Configuration", configuration);
- if (!string.IsNullOrEmpty (platform))
- p.SetGlobalProperty ("Platform", platform);
- else
- p.RemoveGlobalProperty ("Platform");
+ if (p.GetPropertyValue ("Configuration") != configuration || (p.GetPropertyValue ("Platform") ?? "") != (platform ?? "")) {
+ p.SetGlobalProperty ("Configuration", configuration);
+ if (!string.IsNullOrEmpty (platform))
+ p.SetGlobalProperty ("Platform", platform);
+ else
+ p.RemoveGlobalProperty ("Platform");
+
+ }
+
+ // The CurrentSolutionConfigurationContents property only needs to be set once
+ // for the project actually being built
+
+ if (this.file == file && p.GetPropertyValue ("CurrentSolutionConfigurationContents") != slnConfigContents)
+ p.SetGlobalProperty ("CurrentSolutionConfigurationContents", slnConfigContents);
p.ReevaluateIfNecessary ();