Browse Source

Don't add duplicate references specified in project template (new project instances might come with predefined reference items)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1311 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
8bcb176c75
  1. 17
      src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs
  2. 15
      src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs

17
src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs

@ -256,23 +256,6 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
return true; return true;
} }
public void SaveFile(IProject project, string filename, string content, bool showFile)
{
FileProjectItem newItem = new FileProjectItem(project, ItemType.Compile);
newItem.Include = filename;
ProjectService.AddProjectItem(project, newItem);
StreamWriter sr = File.CreateText(filename);
sr.Write(StringParser.Parse(content, new string[,] { {"PROJECT", ((TextBox)ControlDictionary["nameTextBox"]).Text}, {"FILE", Path.GetFileName(filename)}}));
sr.Close();
if (showFile) {
string longfilename = Path.Combine(ProjectSolution, StringParser.Parse(filename, new string[,] { {"PROJECT", ((TextBox)ControlDictionary["nameTextBox"]).Text}}));
FileService.OpenFile(longfilename);
}
}
public string NewProjectLocation; public string NewProjectLocation;
public string NewCombineLocation; public string NewCombineLocation;

15
src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs

@ -142,8 +142,19 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
StringParser.Properties["StandardNamespace"] = project.RootNamespace; StringParser.Properties["StandardNamespace"] = project.RootNamespace;
// Add Project items // Add Project items
foreach (ProjectItem projectItem in projectItems) { foreach (ProjectItem projectItem in projectItems) {
projectItem.Project = project; bool itemFound = false;
project.Items.Add(projectItem); foreach (ProjectItem existingItem in project.Items) {
if (existingItem.ItemType == projectItem.ItemType
&& existingItem.Include == projectItem.Include)
{
itemFound = true;
break;
}
}
if (!itemFound) {
projectItem.Project = project;
project.Items.Add(projectItem);
}
} }
// Add Imports // Add Imports

Loading…
Cancel
Save