public void Constructors() { BuildProperty p1 = new BuildProperty("name", "value", PropertyType.NormalProperty); Assertion.AssertEquals("", p1.Name, "name"); Assertion.AssertEquals("", p1.Value, "value"); BuildProperty p2 = new BuildProperty("name", "value"); Assertion.AssertEquals("", p2.Name, "name"); Assertion.AssertEquals("", p2.Value, "value"); BuildProperty p3 = new BuildProperty(new XmlDocument(), "name", "value", PropertyType.NormalProperty); Assertion.AssertEquals("", p3.Name, "name"); Assertion.AssertEquals("", p3.Value, "value"); BuildProperty p4 = new BuildProperty(null, "name", "value", PropertyType.NormalProperty); Assertion.AssertEquals("", p4.Name, "name"); Assertion.AssertEquals("", p4.Value, "value"); XmlDocument xmldoc = new XmlDocument(); XmlElement xmlel = xmldoc.CreateElement("name"); xmlel.InnerXml = "value"; BuildProperty p5 = new BuildProperty(xmlel, PropertyType.NormalProperty); Assertion.AssertEquals("", p5.Name, "name"); Assertion.AssertEquals("", p5.Value, "value"); }
public void SetValueForPropertyInXMLDoc() { XmlDocument xmldoc = new XmlDocument(); XmlElement xmlel = xmldoc.CreateElement("name"); xmlel.InnerXml = "value"; BuildProperty p1 = new BuildProperty(xmlel, PropertyType.NormalProperty); Assertion.AssertEquals("", p1.Value, "value"); p1.Value = "modified value"; Assertion.AssertEquals("", p1.Value, "modified value"); Assertion.AssertEquals("", xmlel.InnerXml, "modified value"); Assertion.AssertEquals("", xmlel.InnerText, "modified value"); p1.Value = "modified <value/>"; Assertion.AssertEquals("", p1.Value, "modified <value />"); Assertion.AssertEquals("", xmlel.InnerXml, "modified <value />"); Assertion.AssertEquals("", xmlel.InnerText, "modified "); p1.Value = "modified & value"; Assertion.AssertEquals("", p1.Value, "modified & value"); Assertion.AssertEquals("", xmlel.InnerXml, "modified & value"); Assertion.AssertEquals("", xmlel.InnerText, "modified & value"); p1.Value = "modified <value/>"; Assertion.AssertEquals("", p1.Value, "modified <value/>"); Assertion.AssertEquals("", xmlel.InnerXml, "modified &lt;value/&gt;"); Assertion.AssertEquals("", xmlel.InnerText, "modified <value/>"); }
public void ConstructWithSimpleStringNameAndValue() { BuildProperty property = new BuildProperty("n", "v"); Assertion.AssertEquals("n", property.Name); Assertion.AssertEquals("v", property.Value); }
public void ConstructWithSimpleStringNameAndEmptyStringValue() { BuildProperty property = new BuildProperty("n", String.Empty); Assertion.AssertEquals("n", property.Name); Assertion.AssertEquals(String.Empty, property.Value); }
public void TestCtor1 () { string name = "name"; string value = "value"; bp = new BuildProperty (name, value); Assert.AreEqual (name, bp.Name, "A1"); Assert.AreEqual (value, bp.Value, "A2"); Assert.AreEqual (String.Empty, bp.Condition, "A3"); Assert.AreEqual (value, bp.FinalValue, "A4"); Assert.AreEqual (false, bp.IsImported, "A5"); Assert.AreEqual (value, bp.ToString (), "A6"); name = "name"; value = "$(AnotherProperty)"; bp = new BuildProperty (name, value); Assert.AreEqual (name, bp.Name, "A7"); Assert.AreEqual (value, bp.Value, "A8"); Assert.AreEqual (String.Empty, bp.Condition, "A9"); Assert.AreEqual (value, bp.FinalValue, "A10"); Assert.AreEqual (false, bp.IsImported, "A11"); Assert.AreEqual (value, bp.ToString (), "A12"); }
public void CantModifyThroughEnumerator() { BuildPropertyGroup pg = new BuildPropertyGroup(); // Only NormalProperties are modifiable anyway BuildProperty p1 = new BuildProperty("name1", "value1", PropertyType.NormalProperty); pg.SetProperty(p1); BuildPropertyGroupProxy proxy = new BuildPropertyGroupProxy(pg); Hashtable list = new Hashtable(StringComparer.OrdinalIgnoreCase); // Get the one property foreach (DictionaryEntry prop in proxy) { list.Add(prop.Key, prop.Value); } // Change the property Assertion.Assert((string)list["name1"] == "value1"); list["name1"] = "newValue"; Assertion.Assert((string)list["name1"] == "newValue"); // Get the property again list = new Hashtable(StringComparer.OrdinalIgnoreCase); foreach (DictionaryEntry prop in proxy) { list.Add(prop.Key, prop.Value); } // Property value hasn't changed Assertion.Assert((string)list["name1"] == "value1"); }
protected virtual void CopyProperties(IProject sourceProject, IProject targetProject) { MSBuildBasedProject sp = sourceProject as MSBuildBasedProject; MSBuildBasedProject tp = targetProject as MSBuildBasedProject; if (sp != null && tp != null) { lock (sp.SyncRoot) { lock (tp.SyncRoot) { tp.MSBuildProject.RemoveAllPropertyGroups(); foreach (MSBuild.BuildPropertyGroup spg in sp.MSBuildProject.PropertyGroups) { if (spg.IsImported) { continue; } MSBuild.BuildPropertyGroup tpg = tp.MSBuildProject.AddNewPropertyGroup(false); tpg.Condition = spg.Condition; foreach (MSBuild.BuildProperty sprop in spg) { MSBuild.BuildProperty tprop = tpg.AddNewProperty(sprop.Name, sprop.Value); tprop.Condition = sprop.Condition; } } // use the newly created IdGuid instead of the copied one tp.SetProperty(MSBuildBasedProject.ProjectGuidPropertyName, tp.IdGuid); } } } }
internal BuildPropertyGroup (XmlElement xmlElement, Project project, ImportedProject importedProject, bool readOnly, bool isDynamic) { this.importedProject = importedProject; this.parentCollection = null; this.parentProject = project; this.propertyGroup = xmlElement; this.read_only = readOnly; this.isDynamic = isDynamic; if (FromXml) { this.properties = new List <BuildProperty> (); foreach (XmlNode xn in propertyGroup.ChildNodes) { if (!(xn is XmlElement)) continue; XmlElement xe = (XmlElement) xn; BuildProperty bp = new BuildProperty (parentProject, xe); AddProperty (bp); } } else this.propertiesByName = new Dictionary <string, BuildProperty> (StringComparer.OrdinalIgnoreCase); DefinedInFileName = importedProject != null ? importedProject.FullFileName : (project != null ? project.FullFileName : null); }
public void SetValueForPropertyWithoutXMLDoc() { BuildProperty p1 = new BuildProperty("name", "value"); Assertion.AssertEquals("", p1.Value, "value"); p1.Value = "modified value"; Assertion.AssertEquals("", p1.Value, "modified value"); }
BuildProperty [] GetProperties (BuildPropertyGroup bpg) { BuildProperty [] arr = new BuildProperty [bpg.Count]; int i = 0; foreach (BuildProperty bp in bpg) arr [i++] = bp; return arr; }
public string Map(IDictionary<string, string> extras, BuildProperty p, string value) { if (!value.Contains(property)) return value; var thisFile = map(GetThisFilePath(p)); var thisFileProp = "__" + PathToProperty.Replace(thisFile, "") + suffix + "__"; extras[thisFileProp] = thisFile; return value.Replace(property, thisFileProp); }
public virtual string GetConfigurationProperty(string propertyName, bool resetCache) { MSBuild.BuildProperty property = GetMsBuildProperty(propertyName, resetCache); if (property == null) { return(null); } return(property.FinalValue); }
/// <summary> /// Gets the MSBuild build property with the specified name from the WixProject. /// </summary> MSBuild.BuildProperty GetMSBuildProperty(string name) { MSBuild.Project msbuildProject = project.MSBuildProject; foreach (MSBuild.BuildPropertyGroup g in msbuildProject.PropertyGroups.Cast <MSBuild.BuildPropertyGroup>().ToList()) { if (!g.IsImported) { MSBuild.BuildProperty property = MSBuildInternals.GetProperty(g, name); if (property != null) { return(property); } } } return(null); }
public void BasicProxying() { BuildPropertyGroup pg = new BuildPropertyGroup(); BuildProperty p1 = new BuildProperty("name1", "value1", PropertyType.EnvironmentProperty); BuildProperty p2 = new BuildProperty("name2", "value2", PropertyType.GlobalProperty); pg.SetProperty(p1); pg.SetProperty(p2); BuildPropertyGroupProxy proxy = new BuildPropertyGroupProxy(pg); Hashtable list = new Hashtable(StringComparer.OrdinalIgnoreCase); foreach (DictionaryEntry prop in proxy) { list.Add(prop.Key, prop.Value); } Assertion.Assert(list.Count == 2); Assertion.Assert((string)list["name1"] == "value1"); Assertion.Assert((string)list["name2"] == "value2"); }
public void TestConstructor1andProperties() { int nodeProxyId = 1; string projectFileName = "ProjectFileName"; string[] targetNames = new string[] { "Build" }; BuildPropertyGroup globalProperties = null; int requestId = 1; BuildRequest firstConstructorRequest = new BuildRequest(nodeProxyId, projectFileName, targetNames, globalProperties, null, requestId, false, false); Assert.AreEqual(1, firstConstructorRequest.HandleId, "Expected firstConstructorRequest.NodeProxyId to be 1"); firstConstructorRequest.HandleId = 2; Assert.AreEqual(2, firstConstructorRequest.HandleId, "Expected firstConstructorRequest.NodeProxyId to be 2"); Assert.AreEqual(1, firstConstructorRequest.RequestId, "Expected firstConstructorRequest.RequestId to be 1"); firstConstructorRequest.RequestId = 2; Assert.AreEqual(2, firstConstructorRequest.RequestId, "Expected firstConstructorRequest.RequestId to be 2"); Assert.IsNull(firstConstructorRequest.GlobalProperties, "Expected firstConstructorRequest.GlobalProperties to be null"); firstConstructorRequest.GlobalProperties = new BuildPropertyGroup(); Assert.IsNotNull(firstConstructorRequest.GlobalProperties, "Expected firstConstructorRequest.GlobalProperties to not be null"); Assert.IsTrue((firstConstructorRequest.TargetNames.Length == 1) && (string.Compare("Build", firstConstructorRequest.TargetNames[0], StringComparison.OrdinalIgnoreCase) == 0), "Expected to have one target with a value of Build in firstConstructorRequest.TargetNames"); Assert.IsTrue(string.Compare("ProjectFileName", firstConstructorRequest.ProjectFileName, StringComparison.OrdinalIgnoreCase) == 0, "Expected firstConstructorRequest.ProjectFileName to be called ProjecFileName"); globalProperties = new BuildPropertyGroup(); BuildProperty propertyToAdd = new BuildProperty("PropertyName", "Value"); globalProperties.SetProperty(propertyToAdd); firstConstructorRequest = new BuildRequest(nodeProxyId, projectFileName, targetNames, globalProperties, null, requestId, false, false); Assert.IsNotNull(firstConstructorRequest.GlobalPropertiesPassedByTask, "Expected GlobalPropertiesPassedByTask to not be null"); Assert.IsNotNull(firstConstructorRequest.GlobalProperties, "Expected GlobalPropertiesPassedByTask to not be null"); Assert.IsTrue(string.Compare(firstConstructorRequest.GlobalProperties["PropertyName"].Value, "Value", StringComparison.OrdinalIgnoreCase) == 0, "Expected GlobalProperties, propertyname to be equal to value"); string buildProperty = ((Hashtable)firstConstructorRequest.GlobalPropertiesPassedByTask)["PropertyName"] as string; Assert.IsTrue(string.Compare(buildProperty, "Value", StringComparison.OrdinalIgnoreCase) == 0, "Expected hashtable to contain a property group with a value of value"); Assert.IsTrue((firstConstructorRequest.TargetNames.Length == 1) && (string.Compare("Build", firstConstructorRequest.TargetNames[0], StringComparison.OrdinalIgnoreCase) == 0), "Expected to have one target with a value of Build"); Assert.IsTrue(string.Compare("ProjectFileName", firstConstructorRequest.ProjectFileName, StringComparison.OrdinalIgnoreCase) == 0, "Expected project file to be called ProjecFileName"); }
public void TestToString () { bp = new BuildProperty ("name", "a;b"); Assert.AreEqual ("a;b", bp.ToString ()); }
public string GetValue(Project project) { BuildProperty bp = project.EvaluatedProperties [name]; return(bp == null ? String.Empty : bp.Value); }
public void TestCondition2 () { BuildProperty a = new BuildProperty ("name", "value"); a.Condition = "true"; }
public void TestOpExplicit1 () { bp = new BuildProperty ("name", "value"); Assert.AreEqual ("value", (string) bp, "A1"); }
public override void Execute() { if (!(hostContext.Data["EnabledRenderers"] as StringCollection).Contains(this.Identifier)) { return; } // Get parameters Dictionary <String, StringCollection> parameters = hostContext.Data["CommandParameters"] as Dictionary <String, StringCollection>; System.Diagnostics.Trace.WriteLine("\r\nStarting RIMBA Renderer", "information"); StringCollection genFormatters = new StringCollection(); bool makeWP7Proj = false; if (hostContext.Mode == Pipeline.OperationModeType.Quirks) { System.Diagnostics.Trace.WriteLine("--- WARNING ---\r\n Host context is operating in Quirks mode, GPMR cannot guarantee output will be accurate\r\n--- WARNING ---"); } #region Validate all parameters // Validate parameters if (!parameters.ContainsKey("rimbapi-api-ns")) { parameters.Add("rimbapi-api-ns", new StringCollection()); parameters["rimbapi-api-ns"].Add("MARC.Everest"); } if (!parameters.ContainsKey("rimbapi-target-ns")) { parameters.Add("rimbapi-target-ns", new StringCollection()); parameters["rimbapi-target-ns"].Add("output"); } if (parameters.ContainsKey("rimbapi-root-class")) { RootClass = parameters["rimbapi-root-class"][0]; } if (parameters.ContainsKey("rimbapi-gen-vocab")) { GenerateVocab = Convert.ToBoolean(parameters["rimbapi-gen-vocab"][0]); } if (parameters.ContainsKey("rimbapi-gen-rim")) { GenerateRim = Convert.ToBoolean(parameters["rimbapi-gen-rim"][0]); } if (parameters.ContainsKey("rimbapi-profileid")) { InteractionRenderer.profileId = parameters["rimbapi-profileid"][0]; } if (parameters.ContainsKey("rimbapi-oid-profileid")) { InteractionRenderer.profileIdOid = parameters["rimbapi-oid-profileid"][0]; } if (parameters.ContainsKey("rimbapi-oid-interactionid")) { InteractionRenderer.interactionIdOid = parameters["rimbapi-oid-interactionid"][0]; } if (parameters.ContainsKey("rimbapi-oid-triggerevent")) { InteractionRenderer.triggerEventOid = parameters["rimbapi-oid-triggerevent"][0]; } if (parameters.ContainsKey("rimbapi-gen-its")) { genFormatters = parameters["rimbapi-gen-its"]; } if (parameters.ContainsKey("rimbapi-phone")) { makeWP7Proj = bool.Parse(parameters["rimbapi-phone"][0]); } #endregion // Initialize Heuristics MohawkCollege.EHR.gpmr.Pipeline.Renderer.RimbaCS.HeuristicEngine.Datatypes.Initialize(parameters["rimbapi-api-ns"][0]); MohawkCollege.EHR.gpmr.Pipeline.Renderer.RimbaCS.HeuristicEngine.Interfaces.Initialize(parameters["rimbapi-api-ns"][0]); // Get our repository ready ClassRepository classRep = hostContext.Data["SourceCR"] as ClassRepository; string ProjectFileName = "output.csproj"; // Set the output file name if (parameters.ContainsKey("rimbapi-target-ns")) { ProjectFileName = parameters["rimbapi-target-ns"][0]; } if (parameters.ContainsKey("rimbapi-partials")) { RenderPartials = Boolean.Parse(parameters["rimbapi-partials"][0]); } if (parameters.ContainsKey("rimbapi-realm-pref")) { prefRealm = parameters["rimbapi-realm-pref"][0]; } if (parameters.ContainsKey("rimbapi-max-literals")) { MaxLiterals = Int32.Parse(parameters["rimbapi-max-literals"][0]); } if (parameters.ContainsKey("rimbapi-suppress-doc")) { SuppressDoc = Boolean.Parse(parameters["rimbapi-suppress-doc"][0]); } // Setup the template parameters string[][] templateFields = new string[][] { new string[] { "$license$", parameters.ContainsKey("rimbapi-license") ? Licenses.ResourceManager.GetString(parameters["rimbapi-license"][0].ToUpper()) : "" }, new string[] { "$org$", parameters.ContainsKey("rimbapi-org") ? parameters["rimbapi-org"][0] : "" }, new string[] { "$date$", DateTime.Now.ToString("yyyy-MM-dd") }, new string[] { "$clrversion$", Environment.Version.ToString() }, new string[] { "$time$", DateTime.Now.ToString("HH:mm:ss") }, new string[] { "$author$", SystemInformation.UserName }, new string[] { "$year$", DateTime.Now.Year.ToString() }, new string[] { "$version$", Assembly.GetEntryAssembly().GetName().Version.ToString() }, new string[] { "$guid$", Guid.NewGuid().ToString() }, new string[] { "$name$", ProjectFileName }, new string[] { "$mrversion$", InteractionRenderer.profileId ?? "" } }; // Now we want to scan our assembly for FeatureRenderers List <KeyValuePair <FeatureRendererAttribute, IFeatureRenderer> > renderers = new List <KeyValuePair <FeatureRendererAttribute, IFeatureRenderer> >(); foreach (Type t in this.GetType().Assembly.GetTypes()) { if (t.GetInterface("MohawkCollege.EHR.gpmr.Pipeline.Renderer.RimbaCS.Interfaces.IFeatureRenderer") != null && t.GetCustomAttributes(typeof(FeatureRendererAttribute), true).Length > 0) { foreach (FeatureRendererAttribute feature in (t.GetCustomAttributes(typeof(FeatureRendererAttribute), true))) { // Only one feature renderer per feature, so if the dictionary throws an exception // on the add it is ok renderers.Add(new KeyValuePair <FeatureRendererAttribute, IFeatureRenderer>(feature, (IFeatureRenderer)t.Assembly.CreateInstance(t.FullName))); } } } #region Setup the project // Create engine reference Microsoft.Build.BuildEngine.Engine engine = new Microsoft.Build.BuildEngine.Engine( Path.Combine(Path.Combine(Path.Combine(System.Environment.SystemDirectory, "..\\Microsoft.NET"), "Framework"), "v3.5")), phoneEngine = new Microsoft.Build.BuildEngine.Engine( Path.Combine(Path.Combine(Path.Combine(System.Environment.SystemDirectory, "..\\Microsoft.NET"), "Framework"), "v4.0.30319")); // Create MSPROJ Microsoft.Build.BuildEngine.Project project = new Microsoft.Build.BuildEngine.Project(engine), phoneProj = new Project(phoneEngine, "4.0"); phoneProj.DefaultTargets = project.DefaultTargets = "Build"; // Setup project attributes Microsoft.Build.BuildEngine.BuildPropertyGroup pg = project.AddNewPropertyGroup(false); Microsoft.Build.BuildEngine.BuildProperty property = pg.AddNewProperty("Configuration", "Release"); property.Condition = "'$(Configuration)' == ''"; property = pg.AddNewProperty("Platform", "AnyCPU"); property.Condition = "'$(Platform)' == ''"; pg.AddNewProperty("ProductVersion", "10.0.20506"); pg.AddNewProperty("SchemaVersion", "2.0"); pg.AddNewProperty("ProjectGuid", Guid.NewGuid().ToString()); pg.AddNewProperty("OutputType", "Library"); pg.AddNewProperty("AppDesignerFolder", "Properties"); pg.AddNewProperty("RootNamespace", parameters["rimbapi-target-ns"][0]); pg.AddNewProperty("AssemblyName", parameters["rimbapi-target-ns"][0]); // Release AnyCPU pg = project.AddNewPropertyGroup(false); pg.Condition = "'$(Configuration)|$(Platform)' == 'Release|AnyCPU'"; pg.AddNewProperty("DebugType", "pdbonly"); pg.AddNewProperty("Optimize", "true"); pg.AddNewProperty("OutputPath", "bin\\release"); pg.AddNewProperty("DefineConstants", "TRACE"); pg.AddNewProperty("ErrorReport", "prompt"); pg.AddNewProperty("WarningLevel", "4"); pg.AddNewProperty("DocumentationFile", "bin\\release\\" + parameters["rimbapi-target-ns"][0] + ".xml"); // Create Dir Structure Directory.CreateDirectory(Path.Combine(hostContext.Output, "bin")); Directory.CreateDirectory(Path.Combine(hostContext.Output, "lib")); Directory.CreateDirectory(Path.Combine(hostContext.Output, "Properties")); Directory.CreateDirectory(Path.Combine(hostContext.Output, "Vocabulary")); Directory.CreateDirectory(Path.Combine(hostContext.Output, "Interaction")); // Add reference structure Microsoft.Build.BuildEngine.BuildItemGroup refItemGroup = project.AddNewItemGroup(); // Add References File.Copy(Path.Combine(System.Windows.Forms.Application.StartupPath, "MARC.Everest.dll"), Path.Combine(Path.Combine(hostContext.Output, "lib"), "MARC.Everest.dll"), true); if (makeWP7Proj) { File.Copy(Path.Combine(Path.Combine(System.Windows.Forms.Application.StartupPath, "lib"), "MARC.Everest.Phone.dll"), Path.Combine(Path.Combine(hostContext.Output, "lib"), "MARC.Everest.Phone.dll"), true); } File.Copy(Path.Combine(System.Windows.Forms.Application.StartupPath, "MARC.Everest.xml"), Path.Combine(Path.Combine(hostContext.Output, "lib"), "MARC.Everest.xml"), true); refItemGroup.AddNewItem("Reference", "System"); refItemGroup.AddNewItem("Reference", "System.Drawing"); refItemGroup.AddNewItem("Reference", "System.Xml"); Microsoft.Build.BuildEngine.BuildItem buildItem = refItemGroup.AddNewItem("Reference", @"MARC.Everest"); buildItem.SetMetadata("SpecificVersion", "false"); buildItem.SetMetadata("HintPath", "lib\\MARC.Everest.dll"); project.AddNewImport("$(MSBuildBinPath)\\Microsoft.CSharp.targets", null); Microsoft.Build.BuildEngine.BuildItemGroup fileItemGroup = project.AddNewItemGroup(), phoneFileItemGroup = phoneProj.AddNewItemGroup(); #region Assembly Info try { TextWriter tw = File.CreateText(Path.Combine(Path.Combine(hostContext.Output, "Properties"), "AssemblyInfo.cs")); try { string Header = Template.AssemblyInfo; // Set the header to the default // Populate template fields foreach (String[] st in templateFields) { Header = Header.Replace(st[0], st[1]); } // Write header tw.Write(Header); } finally { tw.Close(); } fileItemGroup.AddNewItem("Compile", Path.Combine("Properties", "AssemblyInfo.cs")); phoneFileItemGroup.AddNewItem("Compile", Path.Combine("Properties", "AssemblyInfo.cs")); } catch (Exception) { System.Diagnostics.Trace.WriteLine("Couldn't generate the AssemblyInfo.cs file for this project", "warn"); } #endregion #endregion #region Code Create // Convert class rep to list List <Feature> features = new List <Feature>(); foreach (KeyValuePair <String, Feature> kv in classRep) { features.Add(kv.Value); } // Sort so classes are processed first features.Sort(delegate(Feature a, Feature b) { if ((a is SubSystem) && !(b is SubSystem)) { return(-1); } else if ((b is SubSystem) && !(a is SubSystem)) { return(1); } else { return(a.GetType().Name.CompareTo(b.GetType().Name)); } }); RenderFeatureList(features, templateFields, renderers, fileItemGroup, phoneFileItemGroup, parameters); // Any added features? // HACK: This should be fixed soon, but meh... I'll get around to it List <Feature> addlFeatures = new List <Feature>(); foreach (KeyValuePair <String, Feature> kv in classRep) { if (!features.Contains(kv.Value)) { addlFeatures.Add(kv.Value); } } RenderFeatureList(addlFeatures, templateFields, renderers, fileItemGroup, phoneFileItemGroup, parameters); // Save the project project.Save(Path.Combine(hostContext.Output, ProjectFileName) + ".csproj"); #endregion // Compile? #region Compile this project // Does the user want to compile? if (parameters.ContainsKey("rimbapi-compile") && Convert.ToBoolean(parameters["rimbapi-compile"][0])) { string logPath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); // Create log Microsoft.Build.BuildEngine.FileLogger logger = new Microsoft.Build.BuildEngine.FileLogger(); logger.Parameters = "logfile=" + logPath; engine.RegisterLogger(logger); System.Diagnostics.Trace.Write(String.Format("Compiling project (Build log {0})...", logPath), "information"); // Compile if (engine.BuildProject(project)) { System.Diagnostics.Trace.WriteLine("Success!", "information"); } else { System.Diagnostics.Trace.WriteLine("Fail", "information"); throw new InvalidOperationException("Failed compilation, operation cannot continue"); } engine.UnregisterAllLoggers(); } #endregion #region Windows Phone if (makeWP7Proj) { // Setup project attributes pg = phoneProj.AddNewPropertyGroup(false); property = pg.AddNewProperty("Configuration", "Release"); property.Condition = "'$(Configuration)' == ''"; property = pg.AddNewProperty("Platform", "AnyCPU"); property.Condition = "'$(Platform)' == ''"; pg.AddNewProperty("ProductVersion", "10.0.20506"); pg.AddNewProperty("SchemaVersion", "2.0"); pg.AddNewProperty("ProjectGuid", Guid.NewGuid().ToString()); pg.AddNewProperty("OutputType", "Library"); pg.AddNewProperty("AppDesignerFolder", "Properties"); pg.AddNewProperty("RootNamespace", parameters["rimbapi-target-ns"][0]); pg.AddNewProperty("AssemblyName", parameters["rimbapi-target-ns"][0] + ".Phone"); pg.AddNewProperty("ProjectTypeGuids", "{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}"); pg.AddNewProperty("TargetFrameworkVersion", "v4.0"); pg.AddNewProperty("SilverlightVersion", "$(TargetFrameworkVersion)"); pg.AddNewProperty("TargetFrameworkProfile", "WindowsPhone71"); pg.AddNewProperty("TargetFrameworkIdentifier", "Silverlight"); pg.AddNewProperty("SilverlightApplication", "false"); pg.AddNewProperty("ValidateXaml", "true"); pg.AddNewProperty("ThrowErrorsInValidation", "true"); // Release AnyCPU pg = phoneProj.AddNewPropertyGroup(false); pg.Condition = "'$(Configuration)|$(Platform)' == 'Release|AnyCPU'"; pg.AddNewProperty("DebugType", "pdbonly"); pg.AddNewProperty("Optimize", "true"); pg.AddNewProperty("OutputPath", "bin\\release"); pg.AddNewProperty("DefineConstants", "TRACE;SILVERLIGHT;WINDOWS_PHONE"); pg.AddNewProperty("ErrorReport", "prompt"); pg.AddNewProperty("NoStdLib", "true"); pg.AddNewProperty("NoConfig", "true"); pg.AddNewProperty("WarningLevel", "4"); pg.AddNewProperty("DocumentationFile", "bin\\release\\" + parameters["rimbapi-target-ns"][0] + ".Phone.xml"); // Add reference structure refItemGroup = phoneProj.AddNewItemGroup(); refItemGroup.AddNewItem("Reference", "System"); refItemGroup.AddNewItem("Reference", "System.Xml"); BuildItem evReference = refItemGroup.AddNewItem("Reference", @"MARC.Everest.Phone"); evReference.SetMetadata("SpecificVersion", "false"); evReference.SetMetadata("HintPath", "lib\\MARC.Everest.Phone.dll"); // Add WP7 Imports phoneProj.AddNewImport(@"$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets", null); phoneProj.AddNewImport(@"$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets", null); // HACK: Add tools version string fileName = Path.Combine(hostContext.Output, ProjectFileName) + ".Phone.csproj"; phoneProj.Save(fileName); XmlDocument doc = new XmlDocument(); doc.Load(fileName); doc.DocumentElement.Attributes.Append(doc.CreateAttribute("ToolsVersion")); doc.DocumentElement.Attributes["ToolsVersion"].Value = "4.0"; doc.Save(fileName); if (parameters.ContainsKey("rimbapi-compile") && Convert.ToBoolean(parameters["rimbapi-compile"][0])) { System.Diagnostics.Trace.Write(String.Format("Compiling phone project..."), "information"); // Compile if (phoneEngine.BuildProjectFile(fileName)) { System.Diagnostics.Trace.WriteLine("Success!", "information"); } else { System.Diagnostics.Trace.WriteLine("Fail", "information"); throw new InvalidOperationException("Failed compilation, operation cannot continue"); } } } #endregion #region Generate Formatter Assemblies // Generate the formatter assemblies if (genFormatters.Count > 0 && parameters.ContainsKey("rimbapi-compile") && Convert.ToBoolean(parameters["rimbapi-compile"][0])) { AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); Trace.WriteLine("Generating ITS Formatter Types:", "information"); // Load the assembly Assembly genAsm = Assembly.LoadFile(Path.Combine(Path.Combine(Path.Combine(hostContext.Output, "bin"), "release"), ProjectFileName + ".dll")); foreach (string s in genFormatters) { GenerateFormatterAssembly(s, genAsm, InteractionRenderer.profileId ?? "formatter"); } // Assembly resolve AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(CurrentDomain_AssemblyResolve); } else if (genFormatters.Count > 0) { Trace.WriteLine("Can't use --rimbapi-gen-its when --rimbapi-compile is not true, skipping ITS generation", "warn"); } #endregion // Does the user only want asm? #region dllonly if (parameters.ContainsKey("rimbapi-dllonly") && parameters.ContainsKey("rimbapi-compile") && Convert.ToBoolean(parameters["rimbapi-dllonly"][0])) { try { // Move the assemblies up to root foreach (string file in Directory.GetFiles(Path.Combine(Path.Combine(hostContext.Output, "bin"), "release"))) { if (File.Exists(Path.Combine(hostContext.Output, Path.GetFileName(file)))) { File.Delete(Path.Combine(hostContext.Output, Path.GetFileName(file))); } File.Move(file, Path.Combine(hostContext.Output, Path.GetFileName(file))); } // Clean all in the projects and remove all directories List <String> directories = new List <string>(new string[] { Path.Combine(Path.Combine(hostContext.Output, "bin"), "release"), Path.Combine(hostContext.Output, "bin"), Path.Combine(hostContext.Output, "lib"), Path.Combine(hostContext.Output, "Vocabulary"), Path.Combine(hostContext.Output, "Interaction"), Path.Combine(hostContext.Output, "obj") }); // Gather files and clean foreach (Microsoft.Build.BuildEngine.BuildItem fi in fileItemGroup) { // Add directory on the "to be deleted" string dirName = Path.GetDirectoryName(Path.Combine(hostContext.Output, fi.Include)); if (!directories.Contains(dirName)) { directories.Add(dirName); } Trace.WriteLine(String.Format("Deleting {0}...", fi.Include), "debug"); File.Delete(Path.Combine(hostContext.Output, fi.Include)); } // Clean dirs foreach (string s in directories) { Directory.Delete(s, true); } File.Delete(project.FullFileName); } catch (Exception) { System.Diagnostics.Trace.WriteLine("Could not clean working files!", "warn"); } } #endregion }
public void RemoveProperty (BuildProperty propertyToRemove) { if (propertyToRemove == null) throw new ArgumentNullException ("propertyToRemove"); if (FromXml) { if (!propertyToRemove.FromXml) throw new InvalidOperationException ("The specified property does not belong to the current property group."); propertyToRemove.XmlElement.ParentNode.RemoveChild (propertyToRemove.XmlElement); properties.Remove (propertyToRemove); } else propertiesByName.Remove (propertyToRemove.Name); }
internal static BuildProperty CreateFromStream(BinaryReader reader) { string name = reader.ReadString(); string value = Intern(reader.ReadString()); byte marker = reader.ReadByte(); string finalValueEscaped; if (marker == (byte)1) { finalValueEscaped = value; } else { finalValueEscaped = Intern(reader.ReadString()); } PropertyType type = (PropertyType)reader.ReadInt32(); BuildProperty property = new BuildProperty(name, value, type); property.finalValueEscaped = finalValueEscaped; return property; }
public void TestCtor3 () { bp = new BuildProperty ("name", null); }
public virtual int AddCfgsOfCfgName(string name, string cloneName, int fPrivate) { // First create the condition that represent the configuration we want to clone string condition = String.Format(CultureInfo.InvariantCulture, configString, cloneName).Trim(); // Get all configs MSBuild.BuildPropertyGroupCollection configGroup = this.project.BuildProject.PropertyGroups; MSBuild.BuildPropertyGroup configToClone = null; if (cloneName != null) { // Find the configuration to clone foreach (MSBuild.BuildPropertyGroup currentConfig in configGroup) { // Only care about conditional property groups if (currentConfig.Condition == null || currentConfig.Condition.Length == 0) { continue; } // Skip if it isn't the group we want if (String.Compare(currentConfig.Condition.Trim(), condition, StringComparison.OrdinalIgnoreCase) != 0) { continue; } configToClone = currentConfig; } } MSBuild.BuildPropertyGroup newConfig = null; if (configToClone != null) { // Clone the configuration settings newConfig = this.project.ClonePropertyGroup(configToClone); //Will be added later with the new values to the path newConfig.RemoveProperty("OutputPath"); } else { // no source to clone from, lets just create a new empty config newConfig = this.project.BuildProject.AddNewPropertyGroup(false); // Get the list of property name, condition value from the config provider IList <KeyValuePair <KeyValuePair <string, string>, string> > propVals = this.NewConfigProperties; foreach (KeyValuePair <KeyValuePair <string, string>, string> data in propVals) { KeyValuePair <string, string> propData = data.Key; string value = data.Value; MSBuild.BuildProperty newProperty = newConfig.AddNewProperty(propData.Key, value); if (!String.IsNullOrEmpty(propData.Value)) { newProperty.Condition = propData.Value; } } } //add the output path string outputBasePath = this.ProjectMgr.OutputBaseRelativePath; if (outputBasePath.EndsWith(Path.DirectorySeparatorChar.ToString())) { outputBasePath = Path.GetDirectoryName(outputBasePath); } newConfig.AddNewProperty("OutputPath", Path.Combine(outputBasePath, name) + Path.DirectorySeparatorChar.ToString()); // Set the condition that will define the new configuration string newCondition = String.Format(CultureInfo.InvariantCulture, configString, name); newConfig.Condition = newCondition; NotifyOnCfgNameAdded(name); return(VSConstants.S_OK); }
public BuildPropertyShim(BuildProperty property) { _property = property; }
/// <summary> /// Adds batchable parameters from a property element into the list. If the property element was /// a task, these would be its raw parameter values. /// </summary> private void GetBatchableValuesFromProperty(List <string> parameterValues, BuildProperty property) { AddIfNotEmptyString(parameterValues, property.Value); AddIfNotEmptyString(parameterValues, property.Condition); }
private static void processProperty(ProjectDigest projectDigest, BuildProperty buildProperty) { if ("RootNameSpace".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.RootNamespace = buildProperty.Value; } else if ("AssemblyName".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.AssemblyName = buildProperty.Value; } else if ("Name".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.Name = buildProperty.Value; } else if ("StartupObject".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.StartupObject = buildProperty.Value; } else if ("OutputType".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.OutputType = buildProperty.Value; } else if ("HostInBrowser".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.HostInBrowser = bool.Parse(buildProperty.Value); } else if ("SilverlightVersion".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.SilverlightVersion = buildProperty.Value.Replace("$(TargetFrameworkVersion)", projectDigest.TargetFrameworkVersion); // BusinessApplication template doesn't set the target framework identifier, which we need to find the right things later projectDigest.TargetFrameworkIdentifier = "Silverlight"; } else if ("SilverlightApplication".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.SilverlightApplication = bool.Parse(buildProperty.Value); } else if ("SilverlightApplicationList".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.SilverlightApplicationList = SilverlightApplicationReference.parseApplicationList(buildProperty.Value); } else if ("RoleType".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.RoleType = buildProperty.Value; } else if ("SignAssembly".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.SignAssembly = buildProperty.Value; } else if ("AssemblyOriginatorKeyFile".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.AssemblyOriginatorKeyFile = buildProperty.Value; } else if ("DelaySign".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.DelaySign = buildProperty.Value; } else if ("Optimize".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.Optimize = buildProperty.Value; } else if ("AllowUnsafeBlocks".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.AllowUnsafeBlocks = buildProperty.Value; } else if ("DefineConstants".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.DefineConstants = buildProperty.Value; } else if ("ApplicationIcon".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.ApplicationIcon = buildProperty.Value; } else if ("Win32Resource".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.Win32Resource = buildProperty.Value; } else if ("ProjectGuid".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.ProjectGuid = buildProperty.Value; } else if ("Configuration".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.Configuration = buildProperty.Value; } else if ("BaseIntermediateOutputPath".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.BaseIntermediateOutputPath = buildProperty.Value; } else if ("OutputPath".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.OutputPath = buildProperty.Value; } else if ("TreatWarningsAsErrors".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.TreatWarningsAsErrors = buildProperty.Value; } else if ("Platform".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.Platform = buildProperty.Value; } else if ("ProductVersion".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.ProductVersion = buildProperty.Value; } else if ("SchemaVersion".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.SchemaVersion = buildProperty.Value; } else if ("TargetFrameworkIdentifier".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.TargetFrameworkIdentifier = buildProperty.Value; } else if ("TargetFrameworkProfile".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.TargetFrameworkProfile = buildProperty.Value; } else if ("TargetFrameworkVersion".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase) && projectDigest.TargetFramework == null) { // Raw value from project projectDigest.TargetFrameworkVersion = buildProperty.Value; // changed the version to the more specific version string frameworkVersion = buildProperty.Value.Substring(1); if ("2.0".Equals(frameworkVersion)) { frameworkVersion = "2.0.50727"; } projectDigest.TargetFramework = frameworkVersion; } else if ("AppDesignerFolder".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.AppDesignerFolder = buildProperty.Value; } else if ("DebugSymbols".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.DebugSymbols = buildProperty.Value; } else if ("DebugType".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.DebugType = buildProperty.Value; } else if ("ErrorReport".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.ErrorReport = buildProperty.Value; } else if ("WarningLevel".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.WarningLevel = buildProperty.Value; } else if ("DocumentationFile".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.DocumentationFile = buildProperty.Value; } else if ("PostBuildEvent".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.PostBuildEvent = buildProperty.Value; } else if ("PublishUrl".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.PublishUrl = buildProperty.Value; } else if ("Install".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.Install = buildProperty.Value; } else if ("InstallFrom".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.InstallFrom = buildProperty.Value; } else if ("UpdateEnabled".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.UpdateEnabled = buildProperty.Value; } else if ("UpdateMode".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.UpdateMode = buildProperty.Value; } else if ("UpdateInterval".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.UpdateInterval = buildProperty.Value; } else if ("UpdateIntervalUnits".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.UpdateIntervalUnits = buildProperty.Value; } else if ("UpdatePeriodically".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.UpdatePeriodically = buildProperty.Value; } else if ("UpdateRequired".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.UpdateRequired = buildProperty.Value; } else if ("MapFileExtensions".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.MapFileExtensions = buildProperty.Value; } else if ("ApplicationVersion".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.ApplicationVersion = buildProperty.Value; } else if ("IsWebBootstrapper".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.IsWebBootstrapper = buildProperty.Value; } else if ("BootstrapperEnabled".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.BootstrapperEnabled = buildProperty.Value; } else if ("PreBuildEvent".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.PreBuildEvent = buildProperty.Value; } else if ("MyType".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.MyType = buildProperty.Value; } else if ("DefineDebug".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.DefineDebug = buildProperty.Value; } else if ("DefineTrace".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.DefineTrace = buildProperty.Value; } else if ("NoWarn".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.NoWarn = buildProperty.Value; } else if ("WarningsAsErrors".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { projectDigest.WarningsAsErrors = buildProperty.Value; } else if ("ProjectTypeGuids".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase)) { if (!string.IsNullOrEmpty(buildProperty.Value)) { projectDigest.ProjectType = VisualStudioProjectType.GetVisualStudioProjectType(buildProperty.Value); } } else { log.Debug("Unhandled Property:" + buildProperty.Name); } }
public void SetProperty (string propertyName, string propertyValue, bool treatPropertyValueAsLiteral) { if (read_only) return; if (FromXml) throw new InvalidOperationException ( "This method is only valid for virtual property groups, not <PropertyGroup> elements."); if (treatPropertyValueAsLiteral) propertyValue = Utilities.Escape (propertyValue); if (propertiesByName.ContainsKey (propertyName)) propertiesByName.Remove (propertyName); BuildProperty bp = new BuildProperty (propertyName, propertyValue); if (Char.IsDigit (propertyName [0])) throw new ArgumentException (String.Format ( "The name \"{0}\" contains an invalid character \"{1}\".", propertyName, propertyName [0])); AddProperty (bp); if (IsGlobal) parentProject.NeedToReevaluate (); }
public void WixToolPathCondition() { MSBuild.BuildProperty property = GetMSBuildProperty("WixToolPath"); Assert.AreEqual(" '$(WixToolPath)' == '' ", property.Condition); }
/// <summary> /// Creates a shallow or deep clone of this BuildProperty object. /// /// A shallow clone points at the same XML element as the original, so /// that modifications to the name or value will be reflected in both /// copies. However, the two copies could have different a finalValue. /// /// A deep clone actually clones the XML element as well, so that the /// two copies are completely independent of each other. /// </summary> /// <param name="deepClone"></param> /// <returns></returns> /// <owner>rgoel</owner> public BuildProperty Clone ( bool deepClone ) { BuildProperty clone; // If this property object is represented as an XML element. if (this.propertyElement != null) { XmlElement newPropertyElement; if (deepClone) { // Clone the XML element itself. The new XML element will be // associated with the same XML document as the original property, // but won't actually get added to the XML document. newPropertyElement = (XmlElement)this.propertyElement.Clone(); } else { newPropertyElement = this.propertyElement; } // Create the cloned BuildProperty object, and return it. clone = new BuildProperty(newPropertyElement, this.propertyValue, this.Type); } else { // Otherwise, it's just an in-memory property. We can't do a shallow // clone for this type of property, because there's no XML element for // the clone to share. ErrorUtilities.VerifyThrowInvalidOperation(deepClone, "ShallowCloneNotAllowed"); // Create a new property, using the same name, value, and property type. clone = new BuildProperty(this.Name, this.Value, this.Type); } // Do not set the ParentPersistedPropertyGroup on the cloned property, because it isn't really // part of the property group. // Be certain we didn't copy the value string: it's a waste of memory ErrorUtilities.VerifyThrow(Object.ReferenceEquals(clone.Value, this.Value), "Clone value should be identical reference"); return clone; }
public void TestCtor2 () { bp = new BuildProperty (null, "value"); }
/// <summary> /// Compares two BuildProperty objects ("this" and "compareToProperty") to determine /// if all the fields within the BuildProperty are the same. /// </summary> /// <param name="compareToProperty"></param> /// <returns>true if the properties are equivalent, false otherwise</returns> internal bool IsEquivalent ( BuildProperty compareToProperty ) { // Intentionally do not compare parentPersistedPropertyGroup, because this is // just a back-pointer, and doesn't really contribute to the "identity" of // the property. return (compareToProperty != null) && (0 == String.Compare(compareToProperty.propertyName, this.propertyName, StringComparison.OrdinalIgnoreCase)) && (compareToProperty.propertyValue == this.propertyValue) && (compareToProperty.FinalValue == this.FinalValue) && (compareToProperty.type == this.type); }
public void TestClone1 () { bp = new BuildProperty ("name", "value"); bp.Clone (false); }
public void TestClone2 () { bp = new BuildProperty ("name", "value"); bp.Clone (true); }
public void SetGlobalPropertyAfterLoadBeforeBuild() { MockLogger logger = new MockLogger(); Project project = ObjectModelHelpers.CreateInMemoryProject(@" <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`> <Target Name=`log_property`> <Message Text=`[$(p)]`/> </Target> </Project> ", logger); BuildPropertyGroup globals = project.GlobalProperties; // Set a property before building -- this should work BuildProperty p = new BuildProperty("p", "v1"); globals.SetProperty(p); project.Build(); logger.AssertLogContains("[v1]"); }
internal void AddProperty (BuildProperty property) { if (FromXml) properties.Add (property); else { if (propertiesByName.ContainsKey (property.Name)) { BuildProperty existing = propertiesByName [property.Name]; if (property.PropertyType <= existing.PropertyType) { propertiesByName.Remove (property.Name); propertiesByName.Add (property.Name, property); } } else propertiesByName.Add (property.Name, property); } }
internal void Evaluate () { BuildProperty evaluated = new BuildProperty (Name, Value); // In evaluate phase, properties are not expanded Expression exp = new Expression (); exp.Parse (Value, ParseOptions.None); evaluated.finalValue = (string) exp.ConvertTo (parentProject, typeof (string), ExpressionOptions.DoNotExpandItemRefs); parentProject.EvaluatedProperties.AddProperty (evaluated); }
public BuildProperty AddNewProperty (string propertyName, string propertyValue, bool treatPropertyValueAsLiteral) { if (!FromXml) throw new InvalidOperationException ("This method is only valid for persisted property groups."); if (treatPropertyValueAsLiteral) propertyValue = Utilities.Escape (propertyValue); XmlElement element = propertyGroup.OwnerDocument.CreateElement (propertyName, Project.XmlNamespace); propertyGroup.AppendChild (element); BuildProperty property = new BuildProperty (parentProject, element); property.Value = propertyValue; AddProperty (property); parentProject.MarkProjectAsDirty (); parentProject.NeedToReevaluate (); return property; }