Browse Source

Project options page: allow choosing 3.0 and 3.5 as target framework.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2629 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
c784af0091
  1. 29
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AbstractBuildOptions.cs
  2. 7
      src/Main/Base/Project/Src/Project/AbstractProject.cs
  3. 5
      src/Main/Base/Project/Src/Project/IProject.cs
  4. 12
      src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs
  5. 16
      src/Main/Base/Project/Src/Project/Solution/Solution.cs
  6. 4
      src/Main/StartUp/Project/app.template.config

29
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AbstractBuildOptions.cs

@ -232,27 +232,38 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
ConfigurationGuiBinding targetFrameworkBinding; ConfigurationGuiBinding targetFrameworkBinding;
targetFrameworkBinding = helper.BindStringEnum("targetFrameworkComboBox", TargetFrameworkProperty, targetFrameworkBinding = helper.BindStringEnum("targetFrameworkComboBox", TargetFrameworkProperty,
"", "",
new StringPair("", "Default (.NET 2.0)"), new StringPair("", "C# 2.0 / .NET 2.0"),
// We do not support .NET 1.0 anymore - compiling would still work, new StringPair("v2.0", "C# 3.0 / .NET 2.0"),
// but debugging, unit testing etc. are not supported. new StringPair("v3.0", "C# 3.0 / .NET 3.0"),
//new StringPair("v1.0", ".NET Framework 1.0"), new StringPair("v3.5", "C# 3.0 / .NET 3.5"),
new StringPair("v1.1", ".NET Framework 1.1"),
new StringPair("v2.0", ".NET Framework 2.0"),
new StringPair("CF 1.0", "Compact Framework 1.0"), new StringPair("CF 1.0", "Compact Framework 1.0"),
new StringPair("CF 2.0", "Compact Framework 2.0"), new StringPair("CF 2.0", "Compact Framework 2.0"),
new StringPair("Mono v1.1", "Mono 1.1"), new StringPair("Mono v1.1", "Mono 1.1"),
new StringPair("Mono v2.0", "Mono 2.0")); new StringPair("Mono v2.0", "Mono 2.0"));
targetFrameworkBinding.CreateLocationButton("targetFrameworkLabel"); targetFrameworkBinding.CreateLocationButton("targetFrameworkLabel");
helper.Saved += delegate { helper.Saved += delegate {
// Test if SharpDevelop-Build extensions are needed
MSBuildBasedProject project = helper.Project; MSBuildBasedProject project = helper.Project;
// Test if SharpDevelop-Build extensions are needed
bool needExtensions = false; bool needExtensions = false;
// Test if MSBuild 3.5 is required
bool needMSBuild35 = false;
foreach (MSBuild.BuildProperty p in project.GetAllProperties(TargetFrameworkProperty)) { foreach (MSBuild.BuildProperty p in project.GetAllProperties(TargetFrameworkProperty)) {
if (p.IsImported == false && p.Value.Length > 0) { if (p.IsImported == false) {
if (p.Value.StartsWith("CF") || p.Value.StartsWith("Mono")) {
needExtensions = true; needExtensions = true;
break; } else if (p.Value.StartsWith("v")) {
needMSBuild35 = true;
} }
} }
}
string newToolsVersion = needMSBuild35 ? "3.5" : "2.0";
if (project.MSBuildProject.DefaultToolsVersion != newToolsVersion) {
project.MSBuildProject.DefaultToolsVersion = newToolsVersion;
project.ParentSolution.Save();
}
foreach (MSBuild.Import import in project.MSBuildProject.Imports) { foreach (MSBuild.Import import in project.MSBuildProject.Imports) {
if (needExtensions) { if (needExtensions) {
if (defaultTargets.Equals(import.ProjectPath, StringComparison.InvariantCultureIgnoreCase)) { if (defaultTargets.Equals(import.ProjectPath, StringComparison.InvariantCultureIgnoreCase)) {

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

@ -444,5 +444,12 @@ namespace ICSharpCode.SharpDevelop.Project
{ {
return ItemType.None; return ItemType.None;
} }
/// <summary>
/// Gets the minimum version the solution must have to support this project type.
/// </summary>
public virtual int MinimumSolutionVersion {
get { return 9; }
}
} }
} }

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

@ -211,6 +211,11 @@ namespace ICSharpCode.SharpDevelop.Project
/// Creates a new ProjectItem for the passed MSBuild item. /// Creates a new ProjectItem for the passed MSBuild item.
/// </summary> /// </summary>
ProjectItem CreateProjectItem(Microsoft.Build.BuildEngine.BuildItem item); ProjectItem CreateProjectItem(Microsoft.Build.BuildEngine.BuildItem item);
/// <summary>
/// Gets the minimum version the solution must have to support this project type.
/// </summary>
int MinimumSolutionVersion { get; }
} }
/// <summary> /// <summary>

12
src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs

@ -62,6 +62,18 @@ namespace ICSharpCode.SharpDevelop.Project
MSBuildInternals.EnsureCorrectTempProject(project, null, null, ref evaluatingTempProject); MSBuildInternals.EnsureCorrectTempProject(project, null, null, ref evaluatingTempProject);
} }
public override int MinimumSolutionVersion {
get {
if (string.IsNullOrEmpty(project.DefaultToolsVersion)
|| project.DefaultToolsVersion == "2.0")
{
return 9;
} else {
return 10;
}
}
}
#region CreateProjectItem #region CreateProjectItem
/// <summary> /// <summary>
/// Creates a new projectItem for the passed itemType /// Creates a new projectItem for the passed itemType

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

@ -30,11 +30,6 @@ namespace ICSharpCode.SharpDevelop.Project
/// <summary>contains <guid>, (IProject/ISolutionFolder) pairs.</summary> /// <summary>contains <guid>, (IProject/ISolutionFolder) pairs.</summary>
Dictionary<string, ISolutionFolder> guidDictionary = new Dictionary<string, ISolutionFolder>(); Dictionary<string, ISolutionFolder> guidDictionary = new Dictionary<string, ISolutionFolder>();
/// <summary>
/// The version number of the solution (9 = Whidbey, 10 = Orcas)
/// </summary>
int versionNumber = 9;
string fileName = String.Empty; string fileName = String.Empty;
bool readOnly = false; bool readOnly = false;
@ -357,9 +352,17 @@ namespace ICSharpCode.SharpDevelop.Project
// we need to specify UTF8 because MSBuild needs the BOM // we need to specify UTF8 because MSBuild needs the BOM
using (StreamWriter sw = new StreamWriter(fileName, false, Encoding.UTF8)) { using (StreamWriter sw = new StreamWriter(fileName, false, Encoding.UTF8)) {
sw.WriteLine(); sw.WriteLine();
int versionNumber = 9;
foreach (IProject p in this.Projects) {
if (p.MinimumSolutionVersion > versionNumber)
versionNumber = p.MinimumSolutionVersion;
}
sw.WriteLine("Microsoft Visual Studio Solution File, Format Version " + versionNumber + ".00"); sw.WriteLine("Microsoft Visual Studio Solution File, Format Version " + versionNumber + ".00");
if (versionNumber == 9) { if (versionNumber == 9) {
sw.WriteLine("# Visual Studio 2005"); sw.WriteLine("# Visual Studio 2005");
} else if (versionNumber == 10) {
sw.WriteLine("# Visual Studio 2008");
} }
sw.WriteLine("# SharpDevelop " + RevisionClass.FullVersion); sw.WriteLine("# SharpDevelop " + RevisionClass.FullVersion);
sw.Write(projectSection.ToString()); sw.Write(projectSection.ToString());
@ -472,10 +475,7 @@ namespace ICSharpCode.SharpDevelop.Project
} }
break; break;
case "9.00": case "9.00":
newSolution.versionNumber = 9;
break;
case "10.00": case "10.00":
newSolution.versionNumber = 10;
break; break;
default: default:
MessageService.ShowErrorFormatted("${res:SharpDevelop.Solution.UnknownSolutionVersion}", match.Result("${Version}")); MessageService.ShowErrorFormatted("${res:SharpDevelop.Solution.UnknownSolutionVersion}", match.Result("${Version}"));

4
src/Main/StartUp/Project/app.template.config

@ -43,10 +43,10 @@
<assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> <assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="3.5.0.0"/> <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="3.5.0.0"/>
</dependentAssembly> </dependentAssembly>
<dependentAssembly> <!--<dependentAssembly>
<assemblyIdentity name="Microsoft.CompactFramework.Build.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> <assemblyIdentity name="Microsoft.CompactFramework.Build.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="9.0.0.0"/> <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="9.0.0.0"/>
</dependentAssembly> </dependentAssembly>-->
<probing privatePath="Tools\NUnit"/> <probing privatePath="Tools\NUnit"/>
</assemblyBinding> </assemblyBinding>

Loading…
Cancel
Save