Example #1
0
 /// <summary>
 /// Changes all instances of a property in the <paramref name="project"/> by applying a method to its value.
 /// </summary>
 protected void FixProperty(MSBuildBasedProject project, string propertyName, Converter <string, string> method)
 {
     lock (project.SyncRoot) {
         foreach (MSBuild.BuildProperty p in project.GetAllProperties(propertyName))
         {
             p.Value = method(p.Value);
         }
     }
 }
        protected void InitTargetFramework(string defaultTargets, string extendedTargets)
        {
            const string            TargetFrameworkProperty = "TargetFrameworkVersion";
            ConfigurationGuiBinding targetFrameworkBinding;

            targetFrameworkBinding = helper.BindStringEnum("targetFrameworkComboBox", TargetFrameworkProperty,
                                                           "",
                                                           new StringPair("", "Default (.NET 2.0)"),
                                                           // We do not support .NET 1.0 anymore - compiling would still work,
                                                           // but debugging, unit testing etc. are not supported.
                                                           //new StringPair("v1.0", ".NET Framework 1.0"),
                                                           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 2.0", "Compact Framework 2.0"),
                                                           new StringPair("Mono v1.1", "Mono 1.1"),
                                                           new StringPair("Mono v2.0", "Mono 2.0"));
            targetFrameworkBinding.CreateLocationButton("targetFrameworkLabel");
            helper.Saved += delegate {
                // Test if SharpDevelop-Build extensions are needed
                MSBuildBasedProject project = helper.Project;
                bool needExtensions         = false;
                foreach (MSBuild.BuildProperty p in project.GetAllProperties(TargetFrameworkProperty))
                {
                    if (p.IsImported == false && p.Value.Length > 0)
                    {
                        needExtensions = true;
                        break;
                    }
                }
                foreach (MSBuild.Import import in project.MSBuildProject.Imports)
                {
                    if (needExtensions)
                    {
                        if (defaultTargets.Equals(import.ProjectPath, StringComparison.InvariantCultureIgnoreCase))
                        {
                            //import.ProjectPath = extendedTargets;
                            MSBuildInternals.SetImportProjectPath(project, import, extendedTargets);
                            break;
                        }
                    }
                    else
                    {
                        if (extendedTargets.Equals(import.ProjectPath, StringComparison.InvariantCultureIgnoreCase))
                        {
                            //import.ProjectPath = defaultTargets;
                            MSBuildInternals.SetImportProjectPath(project, import, defaultTargets);
                            break;
                        }
                    }
                }
            };
        }
		/// <summary>
		/// Changes all instances of a property in the <paramref name="project"/> by applying a method to its value.
		/// </summary>
		protected void FixProperty(MSBuildBasedProject project, string propertyName, Converter<string, string> method)
		{
			lock (project.SyncRoot) {
				foreach (MSBuild.BuildProperty p in project.GetAllProperties(propertyName)) {
					p.Value = method(p.Value);
				}
			}
		}