diff options
author | Mikayla Hutchinson <m.j.hutchinson@gmail.com> | 2018-04-13 01:47:10 +0300 |
---|---|---|
committer | Mikayla Hutchinson <m.j.hutchinson@gmail.com> | 2018-04-13 21:15:34 +0300 |
commit | 797e58a3997cc4a67966543bd1d33d1c29e54eeb (patch) | |
tree | 4184522a4a228aab4d638d4c11a0383fe1bfbd4c /main/src | |
parent | d555bbd497995cb053ba270ee3a2e75ac5e01187 (diff) |
[Core] Remove per-project MSBuild opt-out
There is no reason to do this any more, it just opens
up a way to break things.
Diffstat (limited to 'main/src')
12 files changed, 37 insertions, 167 deletions
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/PortableCSharpProjectFlavor.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/PortableCSharpProjectFlavor.cs index 51f262cd4b..c09638afc1 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/PortableCSharpProjectFlavor.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/PortableCSharpProjectFlavor.cs @@ -32,12 +32,6 @@ namespace MonoDevelop.CSharp.Project { class PortableCSharpProjectFlavor: PortableDotNetProjectFlavor { - protected override void Initialize () - { - base.Initialize (); - Project.UseMSBuildEngine = true; - } - protected override void OnGetDefaultImports (System.Collections.Generic.List<string> imports) { imports.Add ("$(MSBuildExtensionsPath32)\\Microsoft\\Portable\\$(TargetFrameworkVersion)\\Microsoft.Portable.CSharp.targets"); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Extensions/ProjectTypeNode.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Extensions/ProjectTypeNode.cs index ac579221a5..18d9d0e167 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Extensions/ProjectTypeNode.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Extensions/ProjectTypeNode.cs @@ -36,13 +36,8 @@ namespace MonoDevelop.Projects.Extensions [ExtensionNode (ExtensionAttributeType=typeof(ExportProjectTypeAttribute))] public class ProjectTypeNode: SolutionItemTypeNode { - [NodeAttribute ("msbuildSupport")] - public MSBuildSupport MSBuildSupport { get; set; } - - public ProjectTypeNode () - { - MSBuildSupport = MSBuildSupport.Supported; - } + [NodeAttribute ("msbuildSupport"), Obsolete] + public MSBuildSupport MSBuildSupport { get; set; } = MSBuildSupport.Supported; public override async Task<SolutionItem> CreateSolutionItem (ProgressMonitor monitor, SolutionLoadContext ctx, string fileName) { @@ -66,8 +61,10 @@ namespace MonoDevelop.Projects.Extensions return MSBuildProjectService.CreateUnknownSolutionItem (monitor, fileName, Guid, unsupporedFlavor, null); } - if (MSBuildSupport == MSBuildSupport.NotSupported || MSBuildProjectService.GetMSBuildSupportForFlavors (p.ProjectTypeGuids) == MSBuildSupport.NotSupported) - p.UseMSBuildEngine = false; + #pragma warning disable 612 + p.UseMSBuildEngine = MSBuildSupport != MSBuildSupport.NotSupported + && MSBuildProjectService.GetMSBuildSupportForFlavors (p.ProjectTypeGuids); + #pragma warning restore 612 // Evaluate the project now. If evaluation fails an exception will be thrown, and when that // happens the solution will create a placeholder project. diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Extensions/SolutionItemExtensionNode.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Extensions/SolutionItemExtensionNode.cs index 702a8fd453..dbc57c0eb4 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Extensions/SolutionItemExtensionNode.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Extensions/SolutionItemExtensionNode.cs @@ -53,8 +53,8 @@ namespace MonoDevelop.Projects.Extensions string migrationHandler; #pragma warning restore CS0649 - [NodeAttribute ("msbuildSupport")] - public MSBuildSupport MSBuildSupport { get; set; } + [NodeAttribute ("msbuildSupport"), Obsolete] + public MSBuildSupport MSBuildSupport { get; set; } = MSBuildSupport.Supported; ProjectMigrationHandler handler; @@ -64,10 +64,6 @@ namespace MonoDevelop.Projects.Extensions [NodeAttribute ("language", Description = "Language name of the extension (C#/F# etc.)")] public string LanguageName { get; set; } - public SolutionItemExtensionNode () - { - MSBuildSupport = MSBuildSupport.Supported; - } public bool IsMigrationRequired { get { return migrationRequired; } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProjectService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProjectService.cs index 865cf4ed3f..3f9e3d26c1 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProjectService.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProjectService.cs @@ -560,17 +560,19 @@ namespace MonoDevelop.Projects.MSBuild return copy ?? types; } - internal static MSBuildSupport GetMSBuildSupportForFlavors (IEnumerable<string> flavorGuids) + internal static bool GetMSBuildSupportForFlavors (IEnumerable<string> flavorGuids) { + #pragma warning disable 612 foreach (var fid in flavorGuids) { var node = WorkspaceObject.GetModelExtensions (null).OfType<SolutionItemExtensionNode> ().FirstOrDefault (n => n.Guid != null && n.Guid.Equals (fid, StringComparison.InvariantCultureIgnoreCase)); if (node != null) { - if (node.MSBuildSupport != MSBuildSupport.Supported) - return node.MSBuildSupport; + if (node.MSBuildSupport == MSBuildSupport.NotSupported) + return false; } else if (!IsKnownTypeGuid (fid)) throw new UnknownSolutionItemTypeException (fid); } - return MSBuildSupport.Supported; + return true; + #pragma warning restore 612 } internal static List<SolutionItemExtensionNode> GetMigrableFlavors (string[] flavorGuids) @@ -700,15 +702,10 @@ namespace MonoDevelop.Projects.MSBuild return null; } + [Obsolete] public static void CheckHandlerUsesMSBuildEngine (SolutionFolderItem item, out bool useByDefault, out bool require) { - var handler = item as Project; - if (handler == null) { - useByDefault = require = false; - return; - } - useByDefault = handler.MSBuildEngineSupport.HasFlag (MSBuildSupport.Supported); - require = handler.MSBuildEngineSupport.HasFlag (MSBuildSupport.Required); + useByDefault = require = item is Project proj && proj.MSBuildProject.UseMSBuildEngine; } static IEnumerable<SolutionItemTypeNode> GetItemTypeNodes () @@ -763,19 +760,21 @@ namespace MonoDevelop.Projects.MSBuild return GenericItemGuid; } - internal static MSBuildSupport GetMSBuildSupportForProject (Project project) + internal static bool UseMSBuildEngineForProject (Project project) { - if (project is UnknownProject) - return MSBuildSupport.NotSupported; + #pragma warning disable 612 + if (project is UnknownProject || project is GenericProject) + return false; foreach (var node in GetItemTypeNodes ().OfType<ProjectTypeNode> ()) { if (node.Guid.Equals (project.TypeGuid, StringComparison.OrdinalIgnoreCase)) { if (node.MSBuildSupport != MSBuildSupport.Supported) - return node.MSBuildSupport; + return false; return GetMSBuildSupportForFlavors (project.FlavorGuids); } } - return MSBuildSupport.NotSupported; + return false; + #pragma warning restore 612 } public static void RegisterGenericProjectType (string projectId, Type type) @@ -1219,7 +1218,9 @@ namespace MonoDevelop.Projects.MSBuild { Guid = MSBuildProjectService.GenericItemGuid; Extension = "mdproj"; + #pragma warning disable 612 MSBuildSupport = MSBuildSupport.NotSupported; + #pragma warning restore 612 TypeAlias = "GenericProject"; } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs index 07b2ca1735..e347cf50ee 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs @@ -910,7 +910,7 @@ namespace MonoDevelop.Projects internal protected virtual async Task<List<AssemblyReference>> OnGetReferencedAssemblies (ConfigurationSelector configuration) { List<AssemblyReference> result = new List<AssemblyReference> (); - if (CheckUseMSBuildEngine (configuration)) { + if (MSBuildProject.UseMSBuildEngine) { // Get the references list from the msbuild project using (Counters.ResolveMSBuildReferencesTimer.BeginTiming (GetProjectEventMetadata (configuration))) result.AddRange (await RunResolveAssemblyReferencesTarget (configuration)); @@ -1038,7 +1038,7 @@ namespace MonoDevelop.Projects internal protected virtual async Task<List<PackageDependency>> OnGetPackageDependencies (ConfigurationSelector configuration, CancellationToken cancellationToken) { var result = new List<PackageDependency> (); - if (CheckUseMSBuildEngine (configuration)) { + if (MSBuildProject.UseMSBuildEngine) { // Get the references list from the msbuild project using (Counters.ResolveMSBuildReferencesTimer.BeginTiming (GetProjectEventMetadata (configuration))) return await RunResolvePackageDependenciesTarget (configuration, cancellationToken); @@ -1300,7 +1300,7 @@ namespace MonoDevelop.Projects public FilePath GetAssemblyDebugInfoFile (ConfigurationSelector configuration, FilePath exeFile) { - if (CheckUseMSBuildEngine (configuration)) { + if (MSBuildProject.UseMSBuildEngine) { var mono = TargetRuntime as MonoTargetRuntime; if (mono != null) { var version = mono.MonoRuntimeInfo?.RuntimeVersion; diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/MSBuildSupport.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/MSBuildSupport.cs index ac942c6f2b..4edf09b049 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/MSBuildSupport.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/MSBuildSupport.cs @@ -27,7 +27,7 @@ using System; namespace MonoDevelop.Projects { - [Flags] + [Flags, Obsolete] public enum MSBuildSupport { /// <summary> diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs index 81781f78c8..a4e245a69a 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs @@ -228,7 +228,7 @@ namespace MonoDevelop.Projects if (creationContext != null && creationContext.Project != null) FileName = creationContext.Project.FileName; - MSBuildEngineSupport = MSBuildProjectService.GetMSBuildSupportForProject (this); + sourceProject.UseMSBuildEngine = MSBuildProjectService.UseMSBuildEngineForProject (this); InitFormatProperties (); } @@ -397,6 +397,7 @@ namespace MonoDevelop.Projects } } + [Obsolete] public MSBuildSupport MSBuildEngineSupport { get; private set; } protected override void OnModified (SolutionItemModifiedEventArgs args) @@ -419,8 +420,7 @@ namespace MonoDevelop.Projects { if (sourceProject == null || sourceProject.IsNewProject) { sourceProject = await MSBuildProject.LoadAsync (FileName).ConfigureAwait (false); - if (MSBuildEngineSupport == MSBuildSupport.NotSupported) - sourceProject.UseMSBuildEngine = false; + sourceProject.UseMSBuildEngine = MSBuildProjectService.UseMSBuildEngineForProject (this); sourceProject.Evaluate (); } @@ -1242,7 +1242,7 @@ namespace MonoDevelop.Projects async Task<TargetEvaluationResult> RunMSBuildTarget (ProgressMonitor monitor, string target, ConfigurationSelector configuration, TargetEvaluationContext context) { - if (CheckUseMSBuildEngine (configuration)) { + if (MSBuildProject.UseMSBuildEngine) { var includeReferencedProjects = context != null ? context.LoadReferencedProjects : false; var configs = GetConfigurations (configuration, includeReferencedProjects); @@ -1577,25 +1577,6 @@ namespace MonoDevelop.Projects #endregion - /// <summary>Whether to use the MSBuild engine for the specified item.</summary> - internal bool CheckUseMSBuildEngine (ConfigurationSelector sel, bool checkReferences = true) - { - // if the item mandates MSBuild, always use it - if (MSBuildEngineSupport.HasFlag (MSBuildSupport.Required)) - return true; - // if the user has set the option, use the setting - if (UseMSBuildEngine.HasValue) - return UseMSBuildEngine.Value; - - // If the item type defaults to using MSBuild, only use MSBuild if its direct references also use MSBuild. - // This prevents a not-uncommon common error referencing non-MSBuild projects from MSBuild projects - // NOTE: This adds about 11ms to the load/build/etc times of the MonoDevelop solution. Doing it recursively - // adds well over a second. - return MSBuildEngineSupport.HasFlag (MSBuildSupport.Supported) && ( - !checkReferences || GetReferencedItems (sel).OfType<Project>().All (i => i.CheckUseMSBuildEngine (sel, false)) - ); - } - bool requiresMicrosoftBuild; internal protected bool RequiresMicrosoftBuild { @@ -1751,13 +1732,6 @@ namespace MonoDevelop.Projects AddFile (newDir); return newDir; } - - //HACK: the build code is structured such that support file copying is in here instead of the item handler - //so in order to avoid doing them twice when using the msbuild engine, we special-case them - bool UsingMSBuildEngine (ConfigurationSelector sel) - { - return CheckUseMSBuildEngine (sel); - } protected override async Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { @@ -1776,7 +1750,7 @@ namespace MonoDevelop.Projects StringParserService.Properties["Project"] = Name; - if (UsingMSBuildEngine (configuration)) { + if (MSBuildProject.UseMSBuildEngine) { // Build is always a long operation. Make sure we build the project in the right builder. context.BuilderQueue = BuilderQueue.LongOperations; var result = await RunMSBuildTarget (monitor, "Build", configuration, context); @@ -2142,7 +2116,7 @@ namespace MonoDevelop.Projects return new TargetEvaluationResult (BuildResult.CreateSuccess ()); } - if (UsingMSBuildEngine (configuration)) { + if (MSBuildProject.UseMSBuildEngine) { // Clean is considered a long operation. Make sure we build the project in the right builder. context.BuilderQueue = BuilderQueue.LongOperations; return await RunMSBuildTarget (monitor, "Clean", configuration, context); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionFolderItem.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionFolderItem.cs index 58eb5625b2..43236d1f17 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionFolderItem.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionFolderItem.cs @@ -51,6 +51,7 @@ namespace MonoDevelop.Projects [ItemProperty ("Policies", IsExternal = true, SkipEmpty = true)] PolicyBag policies; + [Obsolete("This property no longer has any effect")] [ItemProperty ("UseMSBuildEngine", DefaultValue = null)] public bool? UseMSBuildEngine { get; set; } diff --git a/main/src/core/MonoDevelop.Ide/ExtensionModel/ItemOptionPanels.addin.xml b/main/src/core/MonoDevelop.Ide/ExtensionModel/ItemOptionPanels.addin.xml index f0286b7e9d..97fd4bbe4d 100644 --- a/main/src/core/MonoDevelop.Ide/ExtensionModel/ItemOptionPanels.addin.xml +++ b/main/src/core/MonoDevelop.Ide/ExtensionModel/ItemOptionPanels.addin.xml @@ -53,9 +53,6 @@ <Condition id="ItemType" value="Solution"> <Panel id = "SolutionGeneral" _label = "Build" class = "MonoDevelop.Ide.Projects.OptionPanels.CombineBuildOptions"/> </Condition> - <Condition id="ItemType" value="DotNetProject"> - <Panel id = "MSBuildOptionsPanel" _label = "Build" class = "MonoDevelop.Ide.Projects.OptionPanels.CombineMSBuildOptions"/> - </Condition> </Section> <Condition id="ItemType" value="SolutionItem"> <Section id = "CustomCommands" _label = "Custom Commands" fill = "true" class = "MonoDevelop.Ide.Projects.OptionPanels.BuildCustomCommandPanel" icon = "md-prefs-generic" /> diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CustomTools/CustomToolService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CustomTools/CustomToolService.cs index ce79239d01..898dc52b5c 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CustomTools/CustomToolService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CustomTools/CustomToolService.cs @@ -168,13 +168,7 @@ namespace MonoDevelop.Ide.CustomTools //we could emit a warning but this would get very annoying for Xamarin Forms + SAP //in future we could consider running the MSBuild generator in context of every referencing project if (tool is MSBuildCustomTool) { - if (!project.SupportsBuild ()) { - return false; - } - bool byDefault, require; - MonoDevelop.Projects.MSBuild.MSBuildProjectService.CheckHandlerUsesMSBuildEngine (project, out byDefault, out require); - var usesMSBuild = require || (project.UseMSBuildEngine ?? byDefault); - if (!usesMSBuild) { + if (!project.SupportsBuild () || !project.MSBuildProject.UseMSBuildEngine) { return false; } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CombineMSBuildOptions.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CombineMSBuildOptions.cs deleted file mode 100644 index f07659dd82..0000000000 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CombineMSBuildOptions.cs +++ /dev/null @@ -1,83 +0,0 @@ -//
-// CombineMSBuildWidget.cs
-//
-// Author:
-// Marius Ungureanu <marius.ungureanu@xamarin.com>
-//
-// Copyright (c) 2013 Marius Ungureanu
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using MonoDevelop.Ide.Gui.Dialogs;
-using MonoDevelop.Projects.MSBuild;
-using MonoDevelop.Core;
-using MonoDevelop.Components;
-
-namespace MonoDevelop.Ide.Projects.OptionPanels
-{
- class CombineMSBuildOptions : ItemOptionsPanel
- {
- Xwt.CheckBox checkMSBuild;
-
- public override Control CreatePanelWidget ()
- {
- bool byDefault, require;
- MSBuildProjectService.CheckHandlerUsesMSBuildEngine (ConfiguredProject, out byDefault, out require);
- if (require)
- return null;
-
- var box = new Xwt.VBox {
- Spacing = 6,
- Margin = 12
- };
-
- box.PackStart (new Xwt.Label {
- Markup = "<b>Build Engine</b>"
- });
-
- checkMSBuild = new Xwt.CheckBox (byDefault ?
- GettextCatalog.GetString ("Use MSBuild build engine (recommended for this project type)") :
- GettextCatalog.GetString ("Use MSBuild build engine (unsupported for this project type)")) {
- Active = ConfiguredProject.UseMSBuildEngine ?? byDefault
- };
- var hbox = new Xwt.HBox {
- MarginLeft = 18,
- Spacing = 6
- };
- hbox.PackStart (checkMSBuild);
- box.PackStart (hbox);
- box.Show ();
- return box.ToGtkWidget ();
- }
-
- public override void ApplyChanges ()
- {
- bool byDefault, require;
- MSBuildProjectService.CheckHandlerUsesMSBuildEngine (ConfiguredProject, out byDefault, out require);
- if (!require) {
- var active = checkMSBuild.Active;
- if (active == byDefault)
- ConfiguredProject.UseMSBuildEngine = null;
- else
- ConfiguredProject.UseMSBuildEngine = active;
- }
- }
- }
-}
-
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj index 9e0e188fb6..b21db9d955 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj @@ -9193,7 +9193,6 @@ <Compile Include="MonoDevelop.Ide.Gui.Pads.ProjectPad\ImplicitFrameworkAssemblyReferenceNodeBuilder.cs" /> <Compile Include="MonoDevelop.Ide.Gui.Pads.ProjectPad\PortableFrameworkSubsetNodeBuilder.cs" /> <Compile Include="MonoDevelop.Components.MainToolbar\SearchInSolutionSearchCategory.cs" /> - <Compile Include="MonoDevelop.Ide.Projects.OptionPanels\CombineMSBuildOptions.cs" /> <Compile Include="MonoDevelop.Ide.Gui\PadCollection.cs" /> <Compile Include="MonoDevelop.Ide.Extensions\IdeCustomizer.cs" /> <Compile Include="MonoDevelop.Components\ExtendedTitleBarWindow.cs" /> |