Browse Source

Fixed solution configuration -> project configuration mapping.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@894 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
d7e895c4f8
  1. 1
      src/Main/Base/Project/Src/Commands/BuildCommands.cs
  2. 2
      src/Main/Base/Project/Src/Gui/AbstractBaseViewContent.cs
  3. 2
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/SolutionNodeCommands.cs
  4. 10
      src/Main/Base/Project/Src/Project/AbstractProject.cs
  5. 3
      src/Main/Base/Project/Src/Project/IProject.cs
  6. 7
      src/Main/Base/Project/Src/Project/MSBuildEngine.cs
  7. 79
      src/Main/Base/Project/Src/Project/Solution/Solution.cs
  8. 4
      src/Main/Base/Project/Src/Project/Solution/SolutionPreferences.cs
  9. 33
      src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs
  10. 2
      src/Main/Base/Project/Src/TextEditor/Bookmarks/ClassMemberBookmark.cs

1
src/Main/Base/Project/Src/Commands/BuildCommands.cs

@ -190,6 +190,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -190,6 +190,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
{
ToolStripMenuItem item = (ToolStripMenuItem)sender;
ProjectService.OpenSolution.Preferences.ActiveConfiguration = item.Text;
ProjectService.OpenSolution.ApplySolutionConfigurationToProjects();
}
}
}

2
src/Main/Base/Project/Src/Gui/AbstractBaseViewContent.cs

@ -53,7 +53,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -53,7 +53,7 @@ namespace ICSharpCode.SharpDevelop.Gui
public virtual void Dispose()
{
workbenchWindow = null;
//workbenchWindow = null;
}
protected virtual void OnWorkbenchWindowChanged(EventArgs e)

2
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/SolutionNodeCommands.cs

@ -60,6 +60,8 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -60,6 +60,8 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
solutionFolderNode.Container.AddFolder(newProject);
solutionFolderNode.Solution.FixSolutionConfiguration(new IProject[] { newProject });
NodeBuilders.AddProjectNode((TreeNode)solutionFolderNode, newProject).EnsureVisible();
solutionFolderNode.Solution.ApplySolutionConfigurationToProjects();
solutionFolderNode.Solution.ApplySolutionPlatformToProjects();
}
public override void Run()

10
src/Main/Base/Project/Src/Project/AbstractProject.cs

@ -209,13 +209,21 @@ namespace ICSharpCode.SharpDevelop.Project @@ -209,13 +209,21 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
string activeConfiguration, activePlatform;
string activeConfiguration = "Debug";
string activePlatform = "AnyCPU";
public string Platform {
get {
return activePlatform;
}
set {
if (value == "Any CPU") {
// This seems to be a special case in MSBuild
List<string> platformNames = GetPlatformNames();
if (!platformNames.Contains("Any CPU") && platformNames.Contains("AnyCPU")) {
value = "AnyCPU";
}
}
activePlatform = value;
}
}

3
src/Main/Base/Project/Src/Project/IProject.cs

@ -92,6 +92,9 @@ namespace ICSharpCode.SharpDevelop.Project @@ -92,6 +92,9 @@ namespace ICSharpCode.SharpDevelop.Project
set;
}
List<string> GetConfigurationNames();
List<string> GetPlatformNames();
bool CanCompile(string fileName);
void Save();

7
src/Main/Base/Project/Src/Project/MSBuildEngine.cs

@ -150,9 +150,10 @@ namespace ICSharpCode.SharpDevelop.Project @@ -150,9 +150,10 @@ namespace ICSharpCode.SharpDevelop.Project
SharpDevelopLogger logger = new SharpDevelopLogger(this.engine, results);
engine.RegisterLogger(logger);
// IMPORTANT: engine.GlobalProperties must be passed here.
// The properties must be available for both the scanning and building steps
engine.BuildProjectFile(buildFile, targets, engine.GlobalProperties);
Microsoft.Build.BuildEngine.Project project = engine.CreateNewProject();
project.Load(buildFile);
engine.BuildProject(project, targets);
LoggingService.Debug("MSBuild finished");
}

79
src/Main/Base/Project/Src/Project/Solution/Solution.cs

@ -483,32 +483,37 @@ namespace ICSharpCode.SharpDevelop.Project @@ -483,32 +483,37 @@ namespace ICSharpCode.SharpDevelop.Project
return true;
}
public const string SolutionPlatformsSectionName = "SolutionConfigurationPlatforms";
public const string ProjectConfigurationSectionName = "ProjectConfigurationPlatforms";
public ProjectSection GetSolutionConfigurationsSection()
{
foreach (ProjectSection sec in Sections) {
if (sec.Name == "SolutionConfigurationPlatforms")
return sec;
}
ProjectSection newSec = new ProjectSection("SolutionConfigurationPlatforms", "preSolution");
Sections.Insert(0, newSec);
return newSec;
}
public ProjectSection GetProjectConfigurationsSection()
{
foreach (ProjectSection sec in Sections) {
if (sec.Name == "ProjectConfigurationPlatforms")
return sec;
}
ProjectSection newSec = new ProjectSection("ProjectConfigurationPlatforms", "postSolution");
Sections.Add(newSec);
return newSec;
}
public bool FixSolutionConfiguration(IEnumerable<IProject> projects)
{
ProjectSection solSec = null;
ProjectSection prjSec = null;
ProjectSection solSec = GetSolutionConfigurationsSection();
ProjectSection prjSec = GetProjectConfigurationsSection();
bool changed = false;
foreach (ProjectSection sec in Sections) {
if (sec.Name == SolutionPlatformsSectionName)
solSec = sec;
else if (sec.Name == ProjectConfigurationSectionName)
prjSec = sec;
}
if (solSec == null) {
solSec = new ProjectSection(SolutionPlatformsSectionName, "preSolution");
Sections.Insert(0, solSec);
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 SolutionConfigurationPlatforms !!");
changed = true;
}
if (prjSec == null) {
prjSec = new ProjectSection(ProjectConfigurationSectionName, "postSolution");
Sections.Add(prjSec);
LoggingService.Warn("!! Inserted ProjectConfigurationPlatforms !!");
LoggingService.Warn("!! Inserted default SolutionConfigurationPlatforms !!");
changed = true;
}
foreach (IProject project in projects) {
@ -538,14 +543,10 @@ namespace ICSharpCode.SharpDevelop.Project @@ -538,14 +543,10 @@ namespace ICSharpCode.SharpDevelop.Project
public IList<string> GetConfigurationNames()
{
List<string> configurationNames = new List<string>();
foreach (ProjectSection sec in ProjectService.OpenSolution.Sections) {
if (sec.Name != SolutionPlatformsSectionName)
continue;
foreach (SolutionItem item in sec.Items) {
string name = AbstractProject.GetConfigurationNameFromKey(item.Name);
if (!configurationNames.Contains(name))
configurationNames.Add(name);
}
foreach (SolutionItem item in GetSolutionConfigurationsSection().Items) {
string name = AbstractProject.GetConfigurationNameFromKey(item.Name);
if (!configurationNames.Contains(name))
configurationNames.Add(name);
}
return configurationNames;
}
@ -553,31 +554,27 @@ namespace ICSharpCode.SharpDevelop.Project @@ -553,31 +554,27 @@ namespace ICSharpCode.SharpDevelop.Project
public IList<string> GetPlatformNames()
{
List<string> platformNames = new List<string>();
foreach (ProjectSection sec in ProjectService.OpenSolution.Sections) {
if (sec.Name != SolutionPlatformsSectionName)
continue;
foreach (SolutionItem item in sec.Items) {
string name = AbstractProject.GetPlatformNameFromKey(item.Name);
if (!platformNames.Contains(name))
platformNames.Add(name);
}
foreach (SolutionItem item in GetSolutionConfigurationsSection().Items) {
string name = AbstractProject.GetPlatformNameFromKey(item.Name);
if (!platformNames.Contains(name))
platformNames.Add(name);
}
return platformNames;
}
public void ApplySolutionConfigurationToProjects(string configuration)
public void ApplySolutionConfigurationToProjects()
{
// TODO: Use assignments from project configuration section
foreach (IProject p in Projects) {
p.Configuration = configuration;
p.Configuration = preferences.ActiveConfiguration;
}
}
public void ApplySolutionPlatformToProjects(string platform)
public void ApplySolutionPlatformToProjects()
{
// TODO: Use assignments from project configuration section
foreach (IProject p in Projects) {
p.Platform = platform;
p.Platform = preferences.ActivePlatform;
}
}
@ -595,7 +592,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -595,7 +592,7 @@ namespace ICSharpCode.SharpDevelop.Project
solutionBeingLoaded = newSolution;
newSolution.Name = Path.GetFileNameWithoutExtension(fileName);
string extension = Path.GetExtension(fileName).ToUpper();
string extension = Path.GetExtension(fileName).ToUpperInvariant();
if (extension == ".CMBX") {
if (!MessageService.AskQuestion("${res:SharpDevelop.Solution.ImportCmbx}")) {
return null;

4
src/Main/Base/Project/Src/Project/Solution/SolutionPreferences.cs

@ -16,7 +16,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -16,7 +16,7 @@ namespace ICSharpCode.SharpDevelop.Project
Solution solution;
string startupProject = "";
string activeConfiguration = "Debug";
string activePlatform = "AnyCPU";
string activePlatform = "Any CPU";
internal SolutionPreferences(Solution solution)
{
@ -45,7 +45,6 @@ namespace ICSharpCode.SharpDevelop.Project @@ -45,7 +45,6 @@ namespace ICSharpCode.SharpDevelop.Project
set {
if (value == null) throw new ArgumentNullException();
activeConfiguration = value;
solution.ApplySolutionConfigurationToProjects(value);
}
}
@ -56,7 +55,6 @@ namespace ICSharpCode.SharpDevelop.Project @@ -56,7 +55,6 @@ namespace ICSharpCode.SharpDevelop.Project
set {
if (value == null) throw new ArgumentNullException();
activePlatform = value;
solution.ApplySolutionPlatformToProjects(value);
}
}

33
src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs

@ -221,17 +221,24 @@ namespace ICSharpCode.SharpDevelop.Project @@ -221,17 +221,24 @@ namespace ICSharpCode.SharpDevelop.Project
if (FileUtility.IsValidFileName(file) && File.Exists(file)) {
openSolution.Preferences.SetMemento(Properties.Load(file));
}
foreach (IProject project in openSolution.Projects) {
file = GetPreferenceFileName(project.FileName);
if (FileUtility.IsValidFileName(file) && File.Exists(file)) {
project.SetMemento(Properties.Load(file));
}
}
ApplyConfigurationAndReadPreferences();
} catch (Exception ex) {
MessageService.ShowError(ex);
}
}
static void ApplyConfigurationAndReadPreferences()
{
openSolution.ApplySolutionConfigurationToProjects();
openSolution.ApplySolutionPlatformToProjects();
foreach (IProject project in openSolution.Projects) {
string file = GetPreferenceFileName(project.FileName);
if (FileUtility.IsValidFileName(file) && File.Exists(file)) {
project.SetMemento(Properties.Load(file));
}
}
}
/// <summary>
/// Load a single project as solution.
/// </summary>
@ -254,13 +261,19 @@ namespace ICSharpCode.SharpDevelop.Project @@ -254,13 +261,19 @@ namespace ICSharpCode.SharpDevelop.Project
return;
}
solution.AddFolder(project);
ProjectSection configSection = solution.GetSolutionConfigurationsSection();
foreach (string configuration in project.GetConfigurationNames()) {
foreach (string platform in project.GetPlatformNames()) {
string key = configuration + "|" + platform;
configSection.Items.Add(new SolutionItem(key, key));
}
}
solution.FixSolutionConfiguration(new IProject[] { project });
solution.Save(solutionFile);
openSolution = solution;
OnSolutionLoaded(new SolutionEventArgs(openSolution));
string file = GetPreferenceFileName(project.FileName);
if (FileUtility.IsValidFileName(file) && File.Exists(file)) {
project.SetMemento(Properties.Load(file));
}
ApplyConfigurationAndReadPreferences();
}
public static void SaveSolution()

2
src/Main/Base/Project/Src/TextEditor/Bookmarks/ClassMemberBookmark.cs

@ -70,7 +70,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks @@ -70,7 +70,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
}
public ClassBookmark(IDocument document, IClass @class)
: base(document, @class.Region.BeginLine - 1)
: base(document, Math.Max(@class.Region.BeginLine - 1, 0))
{
this.@class = @class;
}

Loading…
Cancel
Save