diff --git a/data/resources/StringResources.pl.resources b/data/resources/StringResources.pl.resources index 9a69dc622d..334fd183da 100644 Binary files a/data/resources/StringResources.pl.resources and b/data/resources/StringResources.pl.resources differ diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/CPP-Mode.xshd b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/CPP-Mode.xshd index 06ebd52f6d..3995b7fa89 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/CPP-Mode.xshd +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/CPP-Mode.xshd @@ -1,5 +1,6 @@ - + @@ -85,6 +86,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectCreateInformation.cs b/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectCreateInformation.cs index 80b693c4b3..f3b4de9042 100644 --- a/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectCreateInformation.cs +++ b/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectCreateInformation.cs @@ -24,11 +24,16 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates { internal List createdProjects = new List(); + public ProjectCreateInformation() { + Platform = "AnyCPU"; + } + public ReadOnlyCollection CreatedProjects { get { return createdProjects.AsReadOnly(); } } public string OutputProjectFileName { get; set; } + public string Platform { get; set; } public string ProjectName { get; set; } public string SolutionName { get; set; } public string RootNamespace { get; set; } diff --git a/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectTemplate.cs b/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectTemplate.cs index 601b1c3234..54d2156ac9 100644 --- a/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectTemplate.cs +++ b/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectTemplate.cs @@ -376,6 +376,7 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates string solutionLocation = projectCreateInformation.Solution.FileName; if (createNewSolution) { projectCreateInformation.Solution.AddFolder(project); + projectCreateInformation.Solution.FixSolutionConfiguration(new IProject[] {project}); projectCreateInformation.Solution.Save(); ProjectService.OnSolutionCreated(new SolutionEventArgs(projectCreateInformation.Solution)); projectCreateInformation.Solution.Dispose(); diff --git a/src/Main/Base/Project/Src/Project/CompilableProject.cs b/src/Main/Base/Project/Src/Project/CompilableProject.cs index 833ddb0128..78fd5a588d 100644 --- a/src/Main/Base/Project/Src/Project/CompilableProject.cs +++ b/src/Main/Base/Project/Src/Project/CompilableProject.cs @@ -185,7 +185,7 @@ namespace ICSharpCode.SharpDevelop.Project public OutputType OutputType { get { try { - return (OutputType)Enum.Parse(typeof(OutputType), GetEvaluatedProperty("OutputType") ?? "Exe"); + return (OutputType)Enum.Parse(typeof(OutputType), GetEvaluatedProperty("OutputType") ?? "Exe", true); } catch (ArgumentException) { return OutputType.Exe; } diff --git a/src/Main/Base/Project/Src/Project/Items/ItemType.cs b/src/Main/Base/Project/Src/Project/Items/ItemType.cs index 6dd95726dc..d55a31f781 100644 --- a/src/Main/Base/Project/Src/Project/Items/ItemType.cs +++ b/src/Main/Base/Project/Src/Project/Items/ItemType.cs @@ -42,6 +42,10 @@ namespace ICSharpCode.SharpDevelop.Project public static readonly ItemType BootstrapperFile = new ItemType("BootstrapperFile"); public static readonly ItemType Header = new ItemType("Header"); + // vcxproj-only (c++ project) items + public static readonly ItemType ClCompile = new ItemType("ClCompile"); + public static readonly ItemType ClInclude = new ItemType("ClInclude"); + /// /// Gets a collection of item types that are used for files. /// diff --git a/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs b/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs index a5fda64ca4..0db125989b 100644 --- a/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs +++ b/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs @@ -178,6 +178,7 @@ namespace ICSharpCode.SharpDevelop.Project this.projectCollection = information.Solution.MSBuildProjectCollection; this.projectFile = ProjectRootElement.Create(projectCollection); this.userProjectFile = ProjectRootElement.Create(projectCollection); + this.ActivePlatform = information.Platform; Name = information.ProjectName; FileName = information.OutputProjectFileName; @@ -190,10 +191,10 @@ namespace ICSharpCode.SharpDevelop.Project base.IdGuid = "{" + Guid.NewGuid().ToString().ToUpperInvariant() + "}"; projectFile.AddProperty(ProjectGuidPropertyName, IdGuid); AddGuardedProperty("Configuration", "Debug"); - AddGuardedProperty("Platform", "AnyCPU"); + AddGuardedProperty("Platform", information.Platform); this.ActiveConfiguration = "Debug"; - this.ActivePlatform = "AnyCPU"; + this.ActivePlatform = information.Platform; } /// @@ -394,7 +395,10 @@ namespace ICSharpCode.SharpDevelop.Project Dictionary globalProps = new Dictionary(); InitializeMSBuildProjectProperties(globalProps); globalProps["Configuration"] = configuration; - globalProps["Platform"] = platform; + + //HACK: the ActivePlatform property should be set properly before entering here, but sometimes it does not + if (platform != null) + globalProps["Platform"] = platform; MSBuild.Project project = MSBuildInternals.LoadProject(projectCollection, projectFile, globalProps); if (openCurrentConfiguration) currentlyOpenProject = project; @@ -1101,6 +1105,7 @@ namespace ICSharpCode.SharpDevelop.Project { this.projectCollection = loadInformation.ParentSolution.MSBuildProjectCollection; this.FileName = loadInformation.FileName; + this.ActivePlatform = loadInformation.Platform; //try { projectFile = ProjectRootElement.Open(loadInformation.FileName, projectCollection); diff --git a/src/Main/Base/Project/Src/Project/ProjectLoadInformation.cs b/src/Main/Base/Project/Src/Project/ProjectLoadInformation.cs index 54dc2e1174..7e50a39c45 100644 --- a/src/Main/Base/Project/Src/Project/ProjectLoadInformation.cs +++ b/src/Main/Base/Project/Src/Project/ProjectLoadInformation.cs @@ -17,8 +17,10 @@ namespace ICSharpCode.SharpDevelop.Project { public Solution ParentSolution { get; private set; } public string FileName { get; private set; } + public string Platform { get; internal set; } public string ProjectName { get; private set; } public string TypeGuid { get; set; } + internal string Guid { get; set; } public Gui.IProgressMonitor ProgressMonitor { get; set; } public ProjectLoadInformation(Solution parentSolution, string fileName, string projectName) diff --git a/src/Main/Base/Project/Src/Project/Solution/Solution.cs b/src/Main/Base/Project/Src/Project/Solution/Solution.cs index b85d35248d..0889596ec0 100644 --- a/src/Main/Base/Project/Src/Project/Solution/Solution.cs +++ b/src/Main/Base/Project/Src/Project/Solution/Solution.cs @@ -508,6 +508,10 @@ namespace ICSharpCode.SharpDevelop.Project string solutionDirectory = Path.GetDirectoryName(newSolution.FileName); ProjectSection nestedProjectsSection = null; + IList projectsToLoad = new List(); + IList> readProjectSections = new List>(); + + // process the solution file contents while (true) { string line = sr.ReadLine(); @@ -531,11 +535,16 @@ namespace ICSharpCode.SharpDevelop.Project } else { ProjectLoadInformation loadInfo = new ProjectLoadInformation(newSolution, location, title); loadInfo.TypeGuid = projectGuid; - loadInfo.ProgressMonitor = progressMonitor; - IProject newProject = LanguageBindingService.LoadProject(loadInfo); - ReadProjectSections(sr, newProject.ProjectSections); - newProject.IdGuid = guid; - newSolution.AddFolder(newProject); + loadInfo.Guid = guid; +// loadInfo.ProgressMonitor = progressMonitor; +// IProject newProject = LanguageBindingService.LoadProject(loadInfo); +// newProject.IdGuid = guid; + projectsToLoad.Add(loadInfo); + IList currentProjectSections = new List(); + ReadProjectSections(sr, currentProjectSections); + readProjectSections.Add(currentProjectSections); +// newSolution.AddFolder(newProject); + } match = match.NextMatch(); } else { @@ -553,6 +562,21 @@ namespace ICSharpCode.SharpDevelop.Project } } } + // load projects + for(int i=0; i projectSections = readProjectSections[i]; + + // set the target platform + SolutionItem projectConfig = newSolution.GetProjectConfiguration(loadInfo.Guid); + loadInfo.Platform = AbstractProject.GetPlatformNameFromKey(projectConfig.Location); + + loadInfo.ProgressMonitor = progressMonitor; + IProject newProject = LanguageBindingService.LoadProject(loadInfo); + newProject.IdGuid = loadInfo.Guid; + newProject.ProjectSections.AddRange(projectSections); + newSolution.AddFolder(newProject); + } return nestedProjectsSection; } #endregion @@ -636,39 +660,50 @@ namespace ICSharpCode.SharpDevelop.Project return newSec; } + public SolutionItem GetProjectConfiguration(string guid) { + ProjectSection projectConfigSection = GetProjectConfigurationsSection(); + SolutionItem foundItem = projectConfigSection.Items.Find(item => item.Name.StartsWith(guid)); + if (foundItem != null) + return foundItem; + LoggingService.Warn("No configuration for project "+guid + "using default."); + return new SolutionItem("Debug|Any CPU", "Debug|Any CPU"); + } + public bool FixSolutionConfiguration(IEnumerable projects) { ProjectSection solSec = GetSolutionConfigurationsSection(); ProjectSection prjSec = GetProjectConfigurationsSection(); bool changed = false; - if (solSec.Items.Count == 0) { - solSec.Items.Add(new SolutionItem("Debug|Any CPU", "Debug|Any CPU")); - solSec.Items.Add(new SolutionItem("Release|Any CPU", "Release|Any CPU")); - LoggingService.Warn("!! Inserted default SolutionConfigurationPlatforms !!"); - changed = true; - } + Set configurations = new Set(); + foreach (IProject project in projects) { string guid = project.IdGuid.ToUpperInvariant(); - foreach (SolutionItem configuration in solSec.Items) { - string searchKey = guid + "." + configuration.Name + ".Build.0"; - if (!prjSec.Items.Exists(delegate (SolutionItem item) { - return item.Name == searchKey; - })) - { - prjSec.Items.Add(new SolutionItem(searchKey, configuration.Location)); + string platform = FixPlatformNameForSolution(project.ActivePlatform); + foreach (string configuration in new string[]{"Debug", "Release"}) { + string key = configuration + "|" + platform; + configurations.Add(key); + + string searchKey = guid + "." + key + ".Build.0"; + if (!prjSec.Items.Exists(item => item.Name == searchKey)) { + prjSec.Items.Add(new SolutionItem(searchKey, key)); changed = true; } - searchKey = guid + "." + configuration.Name + ".ActiveCfg"; - if (!prjSec.Items.Exists(delegate (SolutionItem item) { - return item.Name == searchKey; - })) - { - prjSec.Items.Add(new SolutionItem(searchKey, configuration.Location)); + + searchKey = guid + "." + key + ".ActiveCfg"; + if (!prjSec.Items.Exists(item => item.Name == searchKey)) { + prjSec.Items.Add(new SolutionItem(searchKey, key)); changed = true; } } } + foreach (string key in configurations) { + if (!solSec.Items.Exists(item => item.Location == key && item.Name == key)) { + solSec.Items.Add(new SolutionItem(key, key)); + changed = true; + } + } + // remove all configuration entries belonging to removed projects prjSec.Items.RemoveAll( item => { diff --git a/src/Main/StartUp/Project/Resources/StringResources.resources b/src/Main/StartUp/Project/Resources/StringResources.resources index 72c112acc1..f2e9448b39 100644 Binary files a/src/Main/StartUp/Project/Resources/StringResources.resources and b/src/Main/StartUp/Project/Resources/StringResources.resources differ