コード例 #1
0
 protected override void OnSetupDebugGroup(BuildPropertyGroup group)
 {
     group.AddNewProperty("Optimize", "false");
     group.AddNewProperty("DefineConstants", "DEBUG;TRACE");
     group.AddNewProperty("ErrorReport", "prompt");
     group.AddNewProperty("WarningLevel", "4");
 }
コード例 #2
0
		public BuildWhen (XmlElement whenElement, Project parentProject)
		{
			this.parentProject = parentProject;
			this.groupingCollection = new GroupingCollection (parentProject);
			if (whenElement == null)
				throw new ArgumentNullException ("whenElement");
			this.whenElement = whenElement;
			foreach (XmlElement xe in whenElement.ChildNodes) {
				switch (xe.Name) {
					case "ItemGroup":
						BuildItemGroup big = new BuildItemGroup (xe, parentProject, null, true);
						//big.BindToXml (xe);
						groupingCollection.Add (big);
						break;
					case "PropertyGroup":
						BuildPropertyGroup bpg = new BuildPropertyGroup (xe, parentProject, null, true);
						//bpg.BindToXml (xe);
						groupingCollection.Add (bpg);
						break;
					case "Choose":
						BuildChoose bc = new BuildChoose (xe, parentProject);
						groupingCollection.Add (bc);
						break;
					default:
						throw new InvalidProjectFileException ( string.Format ("Invalid element '{0}' in When.", xe.Name));
				}
			}
		}
コード例 #3
0
        public void ConstructWithNothing()
        {
            BuildPropertyGroup group = new BuildPropertyGroup();

            Assertion.AssertEquals(0, group.Count);
            Assertion.AssertEquals(false, group.IsImported);
        }
コード例 #4
0
        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");
        }
コード例 #5
0
        public void SimpleAddAndRetrieveProject()
        {
            // Initialize engine.
            Engine engine = new Engine(@"c:\");

            // Instantiate new project manager.
            ProjectManager projectManager = new ProjectManager();

            // Set up variables that represent the information we would be getting from 
            // the "MSBuild" task.
            string fullPath = @"c:\rajeev\temp\myapp.proj";
            BuildPropertyGroup globalProperties = new BuildPropertyGroup();
            globalProperties.SetProperty("Configuration", "Debug");

            // Create a new project that matches the information that we're pretending
            // to receive from the MSBuild task.
            Project project1 = new Project(engine);
            project1.FullFileName = fullPath;
            project1.GlobalProperties = globalProperties;

            // Add the new project to the ProjectManager.
            projectManager.AddProject(project1);

            // Try and retrieve the project from the ProjectManager based on the fullpath + globalprops,
            // and make sure we get back the same project we added.
            Assertion.AssertEquals(project1, projectManager.GetProject(fullPath, globalProperties, null));
        }
コード例 #6
0
 protected override void OnSetupReleaseGroup(BuildPropertyGroup group)
 {
     group.AddNewProperty("DefineDebug", "false");
     group.AddNewProperty("DefineTrace", "true");
     group.AddNewProperty("DocumentationFile", Name + ".xml");
     group.AddNewProperty("NoWarn", "42016,41999,42017,42018,42019,42032,42036,42020,42021,42022");
 }
コード例 #7
0
ファイル: BuildItem_Tests.cs プロジェクト: nikson/msbuild
        public void Metadata()
        {
            string content = @"
            <i Include='i1' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
               <m>$(p)</m>
               <n>n1</n>
            </i>";
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(content);
            BuildItem item = CreateBuildItemFromXmlDocument(doc);
            Assertion.AssertEquals("i", item.Name);
            BuildPropertyGroup properties = new BuildPropertyGroup();
            properties.SetProperty("p", "p1");

            // Evaluated
            Expander expander = new Expander(properties, null, ExpanderOptions.ExpandAll);
            item.EvaluateAllItemMetadata(expander, ParserOptions.AllowPropertiesAndItemLists, null, null);
            Assertion.AssertEquals("p1", item.GetEvaluatedMetadata("m"));

            // Unevaluated
            Assertion.AssertEquals("$(p)", item.GetMetadata("m"));
            Assertion.AssertEquals("n1", item.GetMetadata("n"));

            // All custom metadata
            ArrayList metadataNames = new ArrayList(item.CustomMetadataNames);
            Assertion.Assert(metadataNames.Contains("n"));
            Assertion.Assert(metadataNames.Contains("m"));

            // Custom metadata count only
            Assertion.AssertEquals(2, item.CustomMetadataCount);
            
            // All metadata count
            Assertion.AssertEquals(2 + FileUtilities.ItemSpecModifiers.All.Length, item.MetadataCount);
        }
コード例 #8
0
        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);
                    }
                }
            }
        }
コード例 #9
0
ファイル: Expander.cs プロジェクト: nikson/msbuild
 /// <summary>
 /// Special cased constructor. Where we are only going to expand properties and metadata,
 /// it's a waste of memory to use a lookup. Just use the property group.
 /// PERF: This improves the EvaluateAllItemDefinitions codepath.
 /// </summary>
 internal Expander(BuildPropertyGroup properties, string implicitMetadataItemType, Dictionary<string, string> unqualifiedItemMetadata)
 {
     this.options = ExpanderOptions.ExpandPropertiesAndMetadata;
     this.properties = properties;
     this.itemMetadata = unqualifiedItemMetadata;
     this.implicitMetadataItemType = implicitMetadataItemType;
 }
コード例 #10
0
		BuildProperty [] GetProperties (BuildPropertyGroup bpg)
		{
			List<BuildProperty> list = new List<BuildProperty> ();
			foreach (BuildProperty bp in bpg)
				list.Add (bp);
			return list.ToArray ();
		}
コード例 #11
0
ファイル: Node.cs プロジェクト: nikson/msbuild
        /// <summary>
        /// Initialize the node with the id and the callback object
        /// </summary>
        internal Node
        (
            int nodeId, 
            LoggerDescription[] nodeLoggers, 
            IEngineCallback parentCallback,
            BuildPropertyGroup parentGlobalProperties,
            ToolsetDefinitionLocations toolsetSearchLocations,
            string parentStartupDirectory
        )
        {
            this.nodeId = nodeId;
            this.parentCallback = parentCallback;

            this.exitNodeEvent = new ManualResetEvent(false);
            this.buildRequests = new Queue<BuildRequest>();

            this.requestToLocalIdMapping = new Hashtable();
            this.lastRequestIdUsed = 0;

            this.centralizedLogging = false;
            this.nodeLoggers = nodeLoggers;

            this.localEngine = null;
            this.launchedEngineLoopThread = false;
            this.nodeShutdown = false;
            this.parentGlobalProperties = parentGlobalProperties;
            this.toolsetSearchLocations = toolsetSearchLocations;
            this.parentStartupDirectory = parentStartupDirectory;
        }
コード例 #12
0
ファイル: Toolset.cs プロジェクト: GirlD/mono
		public Toolset (string toolsVersion, string toolsPath, string toolsFrameworkPath, BuildPropertyGroup buildProperties)
		{
			ToolsVersion = toolsVersion;
			ToolsPath = toolsPath;
			FrameworkToolsPath = toolsFrameworkPath;
			BuildProperties = buildProperties;
		}
コード例 #13
0
 public void SetUp()
 {
     // Whole bunch of setup code.
     XmlElement taskNode = new XmlDocument().CreateElement("MockTask");
     LoadedType taskClass = new LoadedType(typeof(MockTask), new AssemblyLoadInfo(typeof(MockTask).Assembly.FullName, null));
     Engine engine = new Engine(@"c:\");
     loggingHelper = new EngineLoggingServicesHelper();
     engine.LoggingServices = loggingHelper;
     Project project = new Project(engine);
     taskExecutionModule = new MockTaskExecutionModule(new EngineCallback(engine));
     // Set up some "fake data" which will be passed to the Task Execution State object
     Hashtable[] fakeArray = new Hashtable[1];
     fakeArray[0] = new Hashtable();
     projectLevelProprtiesForInference = new BuildPropertyGroup();
     projectLevelPropertiesForExecution = new BuildPropertyGroup();
     inferenceBucketItemsByName = fakeArray;
     inferenceBucketMetaData = fakeArray;
     projectLevelItemsForInference = new Hashtable();
     executionBucketItemsByName = fakeArray;
     executionBucketMetaData = fakeArray;
     projectLevelItemsForExecution = new Hashtable();
     hostObject = null;
     projectFileOfTaskNode = "In Memory";
     parentProjectFullFileName = project.FullFileName;
     nodeProxyId = engine.EngineCallback.CreateTaskContext(project, null, null, taskNode, EngineCallback.inProcNode, new BuildEventContext(BuildEventContext.InvalidNodeId, BuildEventContext.InvalidTargetId, BuildEventContext.InvalidProjectContextId, BuildEventContext.InvalidTaskId));
     executionDirectory = Directory.GetCurrentDirectory();
     projectId = project.Id;
 }
コード例 #14
0
ファイル: BuildEngine.cs プロジェクト: carrie901/mono
		public bool BuildProjectFile (string projectFileName,
				       string[] targetNames,
				       IDictionary globalProperties,
				       IDictionary targetOutputs, string toolsVersion)
		{
			if (String.IsNullOrEmpty (projectFileName)) {
				string oldProjectToolsVersion = project.ToolsVersion;
				project.ToolsVersion = toolsVersion;
				try {
					return engine.BuildProject (project, targetNames, targetOutputs,
						BuildSettings.DoNotResetPreviouslyBuiltTargets);
				} finally {
					project.ToolsVersion = oldProjectToolsVersion;
				}
			} else {
				BuildPropertyGroup bpg = new BuildPropertyGroup ();
				if (globalProperties != null)
					foreach (DictionaryEntry de in globalProperties)
						bpg.AddProperty (new BuildProperty (
							(string) de.Key, (string) de.Value,
							PropertyType.Global));
				return engine.BuildProjectFile (projectFileName,
					targetNames, bpg, targetOutputs, BuildSettings.DoNotResetPreviouslyBuiltTargets, toolsVersion);
			}
		}
コード例 #15
0
ファイル: CacheManager.cs プロジェクト: nikson/msbuild
        private CacheScope GetCacheScopeIfExists(string scopeName, BuildPropertyGroup scopeProperties, string scopeToolsVersion, CacheContentType cacheContentType)
        {
            CacheScope cacheScope = null;

            // Default the version to the default engine version
            if (scopeToolsVersion == null)
            {
                scopeToolsVersion = defaultToolsVersion;
            }

            // Retrieve list of scopes by this name
            if (cacheContents[(int)cacheContentType].ContainsKey(scopeName))
            {
                List<CacheScope> scopesByName = (List<CacheScope>)cacheContents[(int)cacheContentType][scopeName];

                // If the list exists search for matching scope properties otherwise create the list
                if (scopesByName != null)
                {
                    lock (cacheManagerLock)
                    {
                        for (int i = 0; i < scopesByName.Count; i++)
                        {
                            if (scopesByName[i].ScopeProperties.IsEquivalent(scopeProperties) && (String.Compare(scopeToolsVersion, scopesByName[i].ScopeToolsVersion, StringComparison.OrdinalIgnoreCase) == 0))
                            {
                                cacheScope = scopesByName[i];
                                break;
                            }
                        }
                    }
                }
            }

            return cacheScope;
        }
コード例 #16
0
ファイル: BuildExecutor.cs プロジェクト: paulj/webgac
        public static bool Build(Project pProj, OutputWindowPane pPane, string pTarget, NameValueCollection pParams)
        {
            Microsoft.Build.BuildEngine.Engine buildEngine = new Microsoft.Build.BuildEngine.Engine();
              BuildExecutor executor = new BuildExecutor(pPane);

              RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\.NETFramework", false);
              if (key == null) {
            throw new Exception("Failed to determine .NET Framework install root - no .NETFramework key");
              }
              string installRoot = key.GetValue("InstallRoot") as string;
              if (installRoot == null) {
            throw new Exception("Failed to determine .NET Framework install root - no InstallRoot value");
              }
              key.Close();

              buildEngine.BinPath = Path.Combine(installRoot, string.Format("v{0}.{1}.{2}", Environment.Version.Major, Environment.Version.Minor, Environment.Version.Build));
              buildEngine.RegisterLogger(executor);

              executor.Verbosity = LoggerVerbosity.Normal;

              BuildPropertyGroup properties = new BuildPropertyGroup();
              foreach (string propKey in pParams.Keys) {
            string val = pParams[propKey];

            properties.SetProperty(propKey, val, true);
              }

              return buildEngine.BuildProjectFile(pProj.FileName, new string[]{pTarget}, properties);
        }
コード例 #17
0
		public void TestAssignment ()
		{
			bpg = new BuildPropertyGroup ();
			
			Assert.AreEqual (0, bpg.Count);
			Assert.AreEqual (false, bpg.IsImported);
		}
コード例 #18
0
ファイル: Expander_Tests.cs プロジェクト: nikson/msbuild
        public void ExpandAllIntoTaskItems3()
        {
            BuildPropertyGroup pg = new BuildPropertyGroup();

            BuildItemGroup ig = new BuildItemGroup();
            ig.AddItem(new BuildItem("Compile", "foo.cs"));
            ig.AddItem(new BuildItem("Compile", "bar.cs"));

            BuildItemGroup ig2 = new BuildItemGroup();
            ig2.AddItem(new BuildItem("Resource", "bing.resx"));

            Hashtable itemsByType = new Hashtable(StringComparer.OrdinalIgnoreCase);
            itemsByType["Compile"] = ig;
            itemsByType["Resource"] = ig2;

            Expander expander = new Expander(pg, itemsByType);

            List<TaskItem> itemsOut = expander.ExpandAllIntoTaskItems("foo;bar;@(compile);@(resource)", null);

            ObjectModelHelpers.AssertItemsMatch(@"
                foo
                bar
                foo.cs
                bar.cs
                bing.resx
                ", itemsOut.ToArray());
        }
コード例 #19
0
		BuildProperty [] GetProperties (BuildPropertyGroup bpg)
		{
			BuildProperty [] arr = new BuildProperty [bpg.Count];
			int i = 0;
			foreach (BuildProperty bp in bpg)
				arr [i++] = bp;
			return arr;
		}
コード例 #20
0
        public void ConstructWithSimpleProject()
        {
            Project p = Build.UnitTests.ObjectModelHelpers.CreateInMemoryProject(basicProjectContentsWithOnePropertyGroup);
            BuildPropertyGroup group = new BuildPropertyGroup(p);

            Assertion.AssertEquals(0, group.Count);
            Assertion.AssertEquals(false, group.IsImported);
        }
コード例 #21
0
ファイル: MockEngine.cs プロジェクト: nikson/msbuild
 public MockEngine(bool logToConsole)
 {
     mockLogger = new MockLogger();
     this.logToConsole = logToConsole;
     this.engine = new Engine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath));
     this.engine.RegisterLogger(new ConsoleLogger());
     this.engine.RegisterLogger(mockLogger);
     engineGlobalProperties = new BuildPropertyGroup();
 }
コード例 #22
0
ファイル: Expander_Tests.cs プロジェクト: nikson/msbuild
        public void ExpandAllIntoTaskItems1()
        {
            BuildPropertyGroup pg = new BuildPropertyGroup();
            Expander expander = new Expander(pg);

            List<TaskItem> itemsOut = expander.ExpandAllIntoTaskItems("foo", null);

            ObjectModelHelpers.AssertItemsMatch(@"foo", itemsOut.ToArray());
        }
コード例 #23
0
		static string GetPropValue (BuildPropertyGroup bpg, string name)
		{
			foreach (BuildProperty bp in bpg) {
				if (bp.Name == name) {
					return bp.FinalValue;
				}
			}
			return String.Empty;
		}
コード例 #24
0
		public void TestAddNewProperty1 ()
		{
			string name = "name";
			string value = "value";

			bpg = new BuildPropertyGroup ();

			bpg.AddNewProperty (name, value);
		}
コード例 #25
0
        /// <summary>
        /// Overloaded constructor.
        /// </summary>
        /// <param name="project">An instance of a build project</param>
        /// <exception cref="ArgumentNullException">Is thrown if the passed Project is null.</exception>
        internal GlobalPropertyHandler(MSBuild.Project project)
        {
            Debug.Assert(project != null, "The project parameter passed cannot be null");

            this.globalProjectProperties = project.GlobalProperties;

            Debug.Assert(project.ParentEngine != null, "The parent engine has not been initialized");

            this.globalEngineProperties = project.ParentEngine.GlobalProperties;
        }
コード例 #26
0
 /// <summary>
 /// Invalidates any cache of properties after some property value has changed.
 /// </summary>
 public virtual void InvalidatePropertyCache()
 {
     // property cache will need to be updated
     this.currentConfig = null;
     // Signal the output groups that something is changed
     foreach (OutputGroup group in this.OutputGroups)
     {
         group.InvalidateGroup();
     }
 }
コード例 #27
0
        /// <summary>
        /// Overloaded constructor.
        /// </summary>
        /// <param name="project">An instance of a build project</param>
        /// <exception cref="ArgumentNullException">Is thrown if the passed Project is null.</exception>
        internal GlobalPropertyHandler(MSBuild.Project project)
        {
            Debug.Assert(project != null, "The project parameter passed cannot be null");

            this.globalProjectProperties = project.GlobalProperties;

            Debug.Assert(project.ParentEngine != null, "The parent engine has not been initialized");

            this.globalEngineProperties = project.ParentEngine.GlobalProperties;
        }
コード例 #28
0
ファイル: CacheScope.cs プロジェクト: nikson/msbuild
 /// <summary>
 /// This constructor creates a scope for a particular name and set of properties
 /// </summary>
 internal CacheScope(string scopeName, BuildPropertyGroup scopeProperties, string scopeToolsVersion)
 {
     // Make certain we don't cache a reference to a Project object, which would defeat 
     // the purpose of this cache
     scopeProperties.ClearParentProject(); 
     
     this.scopeName = scopeName;
     this.scopeToolsVersion = scopeToolsVersion;
     this.scopeProperties = scopeProperties;
     this.cacheContents = new Hashtable(StringComparer.OrdinalIgnoreCase);
 }
コード例 #29
0
ファイル: CacheScope_Tests.cs プロジェクト: nikson/msbuild
        public void TestConstructor()
        {
            BuildPropertyGroup default_scope = new BuildPropertyGroup(new Project());
            Assertion.AssertNotNull(default_scope);

            CacheScope testScope = new CacheScope("Test.proj", default_scope, "2.0");
            Assert.AreEqual(testScope.ScopeProperties, default_scope, "Expected ScopeProperties to be set");

            // We should have detached the parent project from the property group, to avoid holding on to it in the cache
            Assertion.AssertEquals(null, testScope.ScopeProperties.ParentProject);
        }
コード例 #30
0
ファイル: IntrinsicTask_Tests.cs プロジェクト: nikson/msbuild
        public void PropertyGroupEmpty()
        {
            string content = @"
            <Target Name='t' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
                <PropertyGroup/>
            </Target>";
            IntrinsicTask task = CreateIntrinsicTask(content);
            BuildPropertyGroup properties = new BuildPropertyGroup();
            ExecuteTask(task, LookupHelpers.CreateLookup(properties));

            Assertion.AssertEquals(0, properties.Count);
        }
コード例 #31
0
        /// <summary>
        /// Go through each &lt;BuildItemDefinition&gt; element in order, evaluating it using the
        /// supplied properties and any previously evaluated definitions, to build up a complete
        /// library of item types and their default metadata values.
        /// </summary>
        internal void Evaluate(BuildPropertyGroup evaluatedProperties)
        {
            // Clear out previous data first
            itemDefinitionsDictionary.Clear();

            foreach (BuildItemDefinitionGroupXml itemDefinitionGroupXml in itemDefinitions)
            {
                itemDefinitionGroupXml.Evaluate(evaluatedProperties, itemDefinitionsDictionary);
            }

            evaluated = true;
        }
コード例 #32
0
ファイル: ProjectConfig.cs プロジェクト: Plankankul/SpecSharp
        /// <include file='doc\ProjectConfig.uex' path='docs/doc[@for="ProjectConfig.SetConfigurationProperty"]/*' />
        public virtual void SetConfigurationProperty(string propertyName, string propertyValue)
        {
            this.ProjectMgr.SetProjectFileDirty(true);
            string condition = String.Format(CultureInfo.InvariantCulture, ConfigProvider.configString, this.ConfigName);

            this.ProjectMgr.MSBuildProject.SetProperty(propertyName, propertyValue, condition);

            // property cache will need to be updated
            this.currentConfig = null;

            return;
        }
コード例 #33
0
        /// <summary>
        /// Evaluates the specified condition in the project.
        /// WARNING: EvaluateCondition might add a temporary property group and remove it again,
        /// which invalidates enumerators over the list of property groups!
        /// </summary>
        internal static bool EvaluateCondition(MSBuild.Project project,
                                               string condition)
        {
            const string propertyName = "MSBuildInternalsEvaluateConditionDummyPropertyName";

            MSBuild.BuildPropertyGroup pGroup = project.AddNewPropertyGroup(true);
            pGroup.AddNewProperty(propertyName, "ConditionFalse");
            pGroup.AddNewProperty(propertyName, "ConditionTrue").Condition = condition;
            bool result = project.GetEvaluatedProperty(propertyName) == "ConditionTrue";

            project.RemovePropertyGroup(pGroup);
            return(result);
        }
コード例 #34
0
ファイル: EngineCallback.cs プロジェクト: nikson/msbuild
        /// <summary>
        /// Called on the main node only.
        /// </summary>
        public Exception PostCacheEntriesToHost(int nodeId, CacheEntry[] entries, string scopeName, BuildPropertyGroup scopeProperties, string scopeToolsVersion, CacheContentType cacheContentType)
        {
            try
            {
                parentEngine.CacheManager.SetCacheEntries(entries, scopeName, scopeProperties, scopeToolsVersion, cacheContentType);
            }
            catch (InvalidOperationException e)
            {
                return e;
            }

            return null;
        }
コード例 #35
0
 internal override void CreateFromStream(BinaryReader reader)
 {
     base.CreateFromStream(reader);
     #region Entries
     if (reader.ReadByte() == 0)
     {
         entries = null;
     }
     else
     {
         int numberOfEntries = reader.ReadInt32();
         entries = new CacheEntry[numberOfEntries];
         for (int i = 0; i < entries.Length; i++)
         {
             entries[i] = CacheEntryCustomSerializer.CreateFromStream(reader);
         }
     }
     #endregion
     #region ScopeName
     if (reader.ReadByte() == 0)
     {
         scopeName = null;
     }
     else
     {
         scopeName = reader.ReadString();
     }
     #endregion
     #region ScopeProperties
     if (reader.ReadByte() == 0)
     {
         scopeProperties = null;
     }
     else
     {
         scopeProperties = new BuildPropertyGroup();
         scopeProperties.CreateFromStream(reader);
     }
     #endregion
     #region ScopeToolsVersion
     if (reader.ReadByte() == 0)
     {
         scopeToolsVersion = null;
     }
     else
     {
         scopeToolsVersion = reader.ReadString();
     }
     #endregion
     cacheContentType = (CacheContentType)reader.ReadByte();
 }
コード例 #36
0
        /// <include file='doc\ConfigProvider.uex' path='docs/doc[@for="ConfigProvider.AddCfgsOfCfgName"]/*' />
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="cloneName"></param>
        /// <param name="fPrivate"></param>
        /// <returns></returns>
        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, name).Trim();

            // Get all configs
            MSBuild.BuildPropertyGroupCollection configGroup   = this.Project.MSBuildProject.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, true, CultureInfo.InvariantCulture) != 0)
                    {
                        continue;
                    }

                    configToClone = currentConfig;
                }
            }

            MSBuild.BuildPropertyGroup newConfig = null;
            if (configToClone != null)
            {
                // Clone the configuration settings
                newConfig = this.Project.ClonePropertyGroup(configToClone);
            }
            else
            {
                // no source to clone from, lets just create a new empty config
                newConfig = this.Project.MSBuildProject.AddNewPropertyGroup(true);
            }


            // Set the condition that will define the new configuration
            string newCondition = String.Format(CultureInfo.InvariantCulture, configString, name);

            newConfig.Condition = newCondition;

            NotifyOnCfgNameAdded(name);
            return(NativeMethods.S_OK);
        }
コード例 #37
0
ファイル: Toolset.cs プロジェクト: nikson/msbuild
        /// <summary>
        /// Constructor that also associates a set of properties with the tools version
        /// </summary>
        /// <param name="toolsVersion">Name of the toolset</param>
        /// <param name="toolsPath">Path to this toolset's tasks and targets</param>
        /// <param name="buildProperties">Properties that should be associated with the Toolset.
        /// May be null, in which case an empty property group will be used.</param>
        public Toolset(string toolsVersion, string toolsPath, BuildPropertyGroup buildProperties)
        {
            ErrorUtilities.VerifyThrowArgumentLength(toolsVersion, "toolsVersion");
            ErrorUtilities.VerifyThrowArgumentLength(toolsPath, "toolsPath");

            this.toolsVersion = toolsVersion;
            this.ToolsPath = toolsPath;

            this.properties = new BuildPropertyGroup();
            if (buildProperties != null)
            {
                this.properties.ImportProperties(buildProperties);
            }
        }
コード例 #38
0
ファイル: Toolset.cs プロジェクト: maoxingda/msbuild-1
        /// <summary>
        /// Constructor that also associates a set of properties with the tools version
        /// </summary>
        /// <param name="toolsVersion">Name of the toolset</param>
        /// <param name="toolsPath">Path to this toolset's tasks and targets</param>
        /// <param name="buildProperties">Properties that should be associated with the Toolset.
        /// May be null, in which case an empty property group will be used.</param>
        public Toolset(string toolsVersion, string toolsPath, BuildPropertyGroup buildProperties)
        {
            ErrorUtilities.VerifyThrowArgumentLength(toolsVersion, "toolsVersion");
            ErrorUtilities.VerifyThrowArgumentLength(toolsPath, "toolsPath");

            this.toolsVersion = toolsVersion;
            this.ToolsPath    = toolsPath;

            this.properties = new BuildPropertyGroup();
            if (buildProperties != null)
            {
                this.properties.ImportProperties(buildProperties);
            }
        }
コード例 #39
0
ファイル: GroupingCollection.cs プロジェクト: mdae/MonoRT
 internal void Add(BuildPropertyGroup bpg)
 {
     bpg.GroupingCollection = this;
     propertyGroups++;
     if (add_iterator == null)
     {
         list.AddLast(bpg);
     }
     else
     {
         list.AddAfter(add_iterator, bpg);
         add_iterator = add_iterator.Next;
     }
 }
コード例 #40
0
ファイル: Engine.cs プロジェクト: mdae/MonoRT
        // engine should be invoked with path where binary files are
        // to find microsoft.build.tasks
        public Engine(string binPath)
        {
            this.binPath                        = binPath;
            this.buildEnabled                   = true;
            this.projects                       = new Dictionary <string, Project> ();
            this.eventSource                    = new EventSource();
            this.loggers                        = new List <ILogger> ();
            this.buildStarted                   = false;
            this.global_properties              = new BuildPropertyGroup();
            this.builtTargetsOutputByName       = new Dictionary <string, ITaskItem[]> ();
            this.currentlyBuildingProjectsStack = new Stack <Project> ();

            RegisterDefaultTasks();
        }
コード例 #41
0
ファイル: EngineCallback.cs プロジェクト: xen2/msbuild
        /// <summary>
        /// Called either on the main or child node. This is the routing method for setting cache entries.
        /// </summary>
        public void SetCacheEntries
        (
            int handleId, CacheEntry[] entries,
            string cacheScope, string cacheKey, string cacheVersion,
            CacheContentType cacheContentType, bool localNodeOnly
        )
        {
            TaskExecutionContext executionContext = GetTaskContextFromHandleId(handleId);
            BuildPropertyGroup   scopeProperties;

            if (cacheKey == null)
            {
                Project parentProject = executionContext.ParentProject;
                scopeProperties = parentProject.GlobalProperties;
            }
            else
            {
                // Property values are compared using case sensitive comparisons because the case of property values do have meaning.
                // In this case we are using properties in a manner where we do not want case sensitive comparisons.
                // There is not enough benefit for this one special case to add case insensitive
                // comparisons to build properties. We instead uppercase all of the keys for both get and set CachedEntries.
                scopeProperties = new BuildPropertyGroup();
                scopeProperties.SetProperty("CacheKey", cacheKey.ToUpper(CultureInfo.InvariantCulture));
            }

            if (cacheScope == null)
            {
                cacheScope = executionContext.ParentProject.FullFileName;
            }

            if (cacheVersion == null)
            {
                cacheVersion = executionContext.ParentProject.ToolsVersion;
            }

            parentEngine.CacheManager.SetCacheEntries(entries, cacheScope, scopeProperties, cacheVersion, cacheContentType);

            // Also send these to the parent if we're allowed to
            if (parentEngine.Router.ChildMode && !localNodeOnly)
            {
                Exception exception = parentEngine.Router.ParentNode.PostCacheEntriesToHost(entries, cacheScope, scopeProperties, cacheVersion, cacheContentType);

                // If we had problems on the parent node, rethrow the exception here
                if (exception != null)
                {
                    throw exception;
                }
            }
        }
コード例 #42
0
 /// <summary>
 /// Sets the given property in the given property group.
 /// </summary>
 /// <param name="property"></param>
 /// <param name="propertyGroup"></param>
 /// <param name="globalProperties"></param>
 private void SetProperty(PropertyDefinition property, BuildPropertyGroup propertyGroup, BuildPropertyGroup globalProperties)
 {
     try
     {
         // Global properties cannot be overwritten
         if (globalProperties[property.Name] == null)
         {
             propertyGroup.SetProperty(property.Name, property.Value);
         }
     }
     catch (ArgumentException ex)
     {
         InvalidToolsetDefinitionException.Throw(ex, "InvalidPropertyNameInToolset", property.Name, property.Source, ex.Message);
     }
 }
コード例 #43
0
ファイル: Engine.cs プロジェクト: raj581/Marvin
 // engine should be invoked with path where binary files are
 // to find microsoft.build.tasks
 public Engine(string binPath)
 {
     this.binPath                        = binPath;
     this.buildEnabled                   = true;
     this.projects                       = new Dictionary <string, Project> ();
     this.eventSource                    = new EventSource();
     this.loggers                        = new List <ILogger> ();
     this.buildStarted                   = false;
     this.global_properties              = new BuildPropertyGroup();
     this.builtTargetsOutputByName       = new Dictionary <string, ITaskItem[]> ();
     this.currentlyBuildingProjectsStack = new Stack <Project> ();
     this.Toolsets                       = new ToolsetCollection();
     LoadDefaultToolsets();
     defaultTasksTableByToolsVersion = new Dictionary <string, TaskDatabase> ();
 }
コード例 #44
0
            /// <summary>
            /// Given the properties and dictionary of previously encountered item definitions, evaluates
            /// this group of item definitions and adds to the dictionary as necessary.
            /// </summary>
            /// <exception cref="InvalidProjectFileException">If the item definitions are incorrectly defined</exception>
            internal void Evaluate(BuildPropertyGroup properties, ItemDefinitionsDictionary itemDefinitionsDictionary)
            {
                Expander expander = new Expander(properties);

                if (!Utilities.EvaluateCondition(condition, conditionAttribute, expander, ParserOptions.AllowProperties, parentProject))
                {
                    return;
                }

                List <XmlElement> childElements = ProjectXmlUtilities.GetValidChildElements(element);

                foreach (XmlElement child in childElements)
                {
                    EvaluateItemDefinitionElement(child, properties, itemDefinitionsDictionary);
                }
            }
コード例 #45
0
ファイル: BuildWhen.cs プロジェクト: samcf111/unityMono5.5.0
        public BuildWhen(XmlElement whenElement, Project parentProject)
        {
            //this.parentProject = parentProject;
            this.groupingCollection = new GroupingCollection(parentProject);
            if (whenElement == null)
            {
                throw new ArgumentNullException("whenElement");
            }
            this.whenElement = whenElement;
            foreach (XmlNode node in whenElement.ChildNodes)
            {
                switch (node.NodeType)
                {
                case XmlNodeType.Element:
                    var xe = (XmlElement)node;
                    switch (xe.Name)
                    {
                    case "ItemGroup":
                        BuildItemGroup big = new BuildItemGroup(xe, parentProject, null, true);
                        //big.BindToXml (xe);
                        groupingCollection.Add(big);
                        break;

                    case "PropertyGroup":
                        BuildPropertyGroup bpg = new BuildPropertyGroup(xe, parentProject, null, true);
                        //bpg.BindToXml (xe);
                        groupingCollection.Add(bpg);
                        break;

                    case "Choose":
                        BuildChoose bc = new BuildChoose(xe, parentProject);
                        groupingCollection.Add(bc);
                        break;

                    default:
                        throw new InvalidProjectFileException(string.Format("Invalid element '{0}' in When.", xe.Name));
                    }
                    break;

                case XmlNodeType.Comment:
                    break;

                default:
                    throw new InvalidProjectFileException(string.Format("Invalid element '{0}' in When Condition.", node.NodeType));
                }
            }
        }
コード例 #46
0
ファイル: ProjectConfig.cs プロジェクト: Plankankul/SpecSharp
        private MSBuild.BuildProperty GetMsBuildProperty(string propertyName, bool resetCache)
        {
            if (resetCache || this.currentConfig == null)
            {
                // Get properties for current configuration from project file and cache it
                this.ProjectMgr.MSBuildProject.GlobalProperties.SetProperty("Configuration", this.ConfigName);
                this.currentConfig = this.ProjectMgr.MSBuildProject.EvaluatedProperties;
            }

            if (this.currentConfig == null)
            {
                throw new Exception("Failed to retrive properties");
            }

            // return property asked for
            return(this.currentConfig[propertyName]);
        }
コード例 #47
0
 internal override void CreateFromStream(BinaryReader reader)
 {
     base.CreateFromStream(reader);
     #region EnvironmentVariables
     int numberOfVariables = reader.ReadInt32();
     environmentVariables = new Hashtable(numberOfVariables);
     for (int i = 0; i < numberOfVariables; i++)
     {
         string key      = reader.ReadString();
         string variable = reader.ReadString();
         environmentVariables.Add(key, variable);
     }
     #endregion
     #region NodeLoggers
     if (reader.ReadByte() == 0)
     {
         nodeLoggers = null;
     }
     else
     {
         int numberOfLoggers = reader.ReadInt32();
         nodeLoggers = new LoggerDescription[numberOfLoggers];
         for (int i = 0; i < numberOfLoggers; i++)
         {
             LoggerDescription logger = new LoggerDescription();
             logger.CreateFromStream(reader);
             nodeLoggers[i] = logger;
         }
     }
     #endregion
     nodeId          = reader.ReadInt32();
     parentProcessId = reader.ReadInt32();
     #region ParentGlobalProperties
     if (reader.ReadByte() == 0)
     {
         parentGlobalProperties = null;
     }
     else
     {
         parentGlobalProperties = new BuildPropertyGroup();
         parentGlobalProperties.CreateFromStream(reader);
     }
     #endregion
     toolsetSearchLocations = (ToolsetDefinitionLocations)reader.ReadByte();
     parentStartupDirectory = (string)reader.ReadString();
 }
コード例 #48
0
ファイル: Engine.cs プロジェクト: mdae/MonoRT
        public bool BuildProjectFile(string projectFile,
                                     string[] targetNames,
                                     BuildPropertyGroup globalProperties,
                                     IDictionary targetOutputs,
                                     BuildSettings buildFlags)
        {
            Project project;

            if (projects.ContainsKey(projectFile))
            {
                project = (Project)projects [projectFile];
            }
            else
            {
                project = CreateNewProject();
                project.Load(projectFile);
            }

            BuildPropertyGroup engine_old_grp  = null;
            BuildPropertyGroup project_old_grp = null;

            if (globalProperties != null)
            {
                engine_old_grp  = GlobalProperties.Clone(true);
                project_old_grp = project.GlobalProperties.Clone(true);

                // Override project's global properties with the
                // ones explicitlcur_y specified here
                foreach (BuildProperty bp in globalProperties)
                {
                    project.GlobalProperties.AddProperty(bp);
                }
                project.NeedToReevaluate();
            }

            try {
                return(project.Build(targetNames, targetOutputs, buildFlags));
            } finally {
                if (globalProperties != null)
                {
                    GlobalProperties         = engine_old_grp;
                    project.GlobalProperties = project_old_grp;
                }
            }
        }
コード例 #49
0
        /// <summary>
        /// This functions returns true if a project with the same properties, toolset version and filename has been previously loaded. It
        /// will return false for currently loaded projects and projects that have never been loaded.
        /// </summary>
        /// <returns>True if exact same instance has been loaded before </returns>
        internal bool HasProjectBeenLoaded
        (
            string projectFileFullPath,
            BuildPropertyGroup globalProperties,
            string toolsVersion
        )
        {
            ProjectEntry projectEntry = GetProjectEntry(unloadedProjects, projectFileFullPath, globalProperties, toolsVersion);

            if (projectEntry != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #50
0
        /// <summary>
        /// Get a node that the project has been assigned to
        /// </summary>
        /// <returns>Index of the node the project is assigned to and 0 otherwise</returns>
        internal int GetRemoteProject
        (
            string projectFileFullPath,
            BuildPropertyGroup globalProperties,
            string toolsVersion
        )
        {
            ProjectEntry projectEntry = GetProjectEntry(nodeToProjectsMapping, projectFileFullPath, globalProperties, toolsVersion);

            if (projectEntry != null)
            {
                return(projectEntry.nodeIndex);
            }
            else
            {
                return(EngineCallback.invalidNode);
            }
        }
コード例 #51
0
        /// <summary>
        /// Populates the toolset collection passed in with the toolsets read from some location.
        /// </summary>
        /// <remarks>Internal for unit testing only</remarks>
        /// <param name="toolsets"></param>
        /// <param name="globalProperties"></param>
        /// <param name="initialProperties"></param>
        /// <param name="accumulateProperties"></param>
        /// <returns>the default tools version if available, or null otherwise</returns>
        internal string ReadToolsets(ToolsetCollection toolsets,
                                     BuildPropertyGroup globalProperties,
                                     BuildPropertyGroup initialProperties,
                                     bool accumulateProperties)
        {
            error.VerifyThrowArgumentNull(toolsets, nameof(toolsets));

            ReadEachToolset(toolsets, globalProperties, initialProperties, accumulateProperties);

            string defaultToolsVersion = DefaultToolsVersion;

            // We don't check whether the default tools version actually
            // corresponds to a toolset definition. That's because our default for
            // the indefinite future is 2.0, and 2.0 might not be installed, which is fine.
            // If a project tries to use 2.0 (or whatever the default is) in these circumstances
            // they'll get a nice error saying that toolset isn't available and listing those that are.
            return(defaultToolsVersion);
        }
コード例 #52
0
ファイル: LocalNode.cs プロジェクト: maoxingda/msbuild-1
        /// <summary>
        /// This methods activates the local node
        /// </summary>
        internal void Activate
        (
            Hashtable environmentVariables,
            LoggerDescription[] nodeLoggers,
            int nodeId,
            BuildPropertyGroup parentGlobalProperties,
            ToolsetDefinitionLocations toolsetSearchLocations,
            int parentId,
            string parentStartupDirectory
        )
        {
            ErrorUtilities.VerifyThrow(node == null, "Expected node to be null on activation.");

            this.parentProcessId = parentId;

            engineCallback.Reset();

            inUseEvent.Set();

            // Clear the environment so that we dont have extra variables laying around, this
            // may be a performance hog but needs to be done
            IDictionary variableDictionary = Environment.GetEnvironmentVariables();

            foreach (string variableName in variableDictionary.Keys)
            {
                Environment.SetEnvironmentVariable(variableName, null);
            }

            foreach (string key in environmentVariables.Keys)
            {
                Environment.SetEnvironmentVariable(key, (string)environmentVariables[key]);
            }

            // Host the msbuild engine and system
            node = new Node(nodeId, nodeLoggers, engineCallback, parentGlobalProperties, toolsetSearchLocations, parentStartupDirectory);


            // Write the initialization complete event out directly
            LocalCallDescriptorForInitializationComplete callDescriptor =
                new LocalCallDescriptorForInitializationComplete(Process.GetCurrentProcess().Id);

            // Post the message indicating that the initialization is complete
            engineCallback.PostMessageToParent(callDescriptor, true);
        }
コード例 #53
0
        /// <summary>
        /// Evaluates a When clause.  Checks if the condition is true, and if it is,
        /// applies all of the contained property group, item lists, and import statements.
        /// Returns true if the When clause is process (because the condition is true), false
        /// otherwise.
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <owner>DavidLe</owner>
        /// <param name="parentPropertyBag"></param>
        /// <param name="conditionedPropertiesTable"></param>
        /// <returns>bool</returns>
        internal bool EvaluateCondition
        (
            BuildPropertyGroup parentPropertyBag,
            Hashtable conditionedPropertiesTable
        )
        {
            if (
                (this.Condition != null)
                &&
                !Utilities.EvaluateCondition(this.Condition, this.ConditionAttribute,
                                             new Expander(parentPropertyBag, parentProject.EvaluatedItemsByName),
                                             conditionedPropertiesTable, ParserOptions.AllowProperties, this.parentProject.ParentEngine.LoggingServices, this.parentProject.ProjectBuildEventContext)
                )
            {
                return(false);
            }

            return(true);
        }
コード例 #54
0
 /// <summary>
 /// Reads all the toolsets and populates the given ToolsetCollection with them
 /// </summary>
 /// <param name="toolsets"></param>
 /// <param name="globalProperties"></param>
 /// <param name="initialProperties"></param>
 /// <param name="accumulateProperties"></param>
 private void ReadEachToolset(ToolsetCollection toolsets,
                              BuildPropertyGroup globalProperties,
                              BuildPropertyGroup initialProperties,
                              bool accumulateProperties)
 {
     foreach (PropertyDefinition toolsVersion in ToolsVersions)
     {
         // We clone here because we don't want to interfere with the evaluation
         // of subsequent Toolsets; otherwise, properties found during the evaluation
         // of this Toolset would be persisted in initialProperties and appear
         // to later Toolsets as Global or Environment properties from the Engine.
         BuildPropertyGroup initialPropertiesClone = initialProperties.Clone(true /* deep clone */);
         Toolset            toolset = ReadToolset(toolsVersion, globalProperties, initialPropertiesClone, accumulateProperties);
         if (toolset != null)
         {
             toolsets.Add(toolset);
         }
     }
 }
コード例 #55
0
        // Аналогиченая фукнция в ProjectConfig объявлена скрытой, так что дублируем ее.
        /// <summary>
        /// Get MsBuild property by name. Use cached configuration if resetCache if false.
        /// </summary>
        /// <param name="propertyName">Name of MSBuild property to retrieve</param>
        /// <param name="resetCache">True if need reed fresh information from project file</param>
        /// <returns>MSBuild property</returns>
        public MSBuild.BuildProperty GetMsBuildProperty(string propertyName, bool resetCache)
        {
            if (resetCache || _currentConfig == null)
            {
                // Get properties for current configuration from project file and cache it
                ProjectMgr.SetConfiguration(this.ConfigName);
                _currentConfig = ProjectMgr.BuildProject.EvaluatedProperties;

                ProjectMgr.SetCurrentConfiguration();
            }

            if (_currentConfig == null)
            {
                throw new Exception("Failed to retrive properties");
            }

            // return property asked for
            return(_currentConfig[propertyName]);
        }
コード例 #56
0
        public MSBuild.BuildProperty GetMsBuildProperty(string propertyName, bool resetCache, MSBuild.Project buildProject)
        {
            if (resetCache || this.currentConfig == null)
            {
                // Get properties for current configuration from project file and cache it
                this.project.SetConfiguration(this.ConfigName, this.PlatformName);
                this.currentConfig = buildProject.EvaluatedProperties;

                project.SetCurrentConfiguration();
            }

            if (this.currentConfig == null)
            {
                throw new Exception("Failed to retrive properties");
            }

            // return property asked for
            return(this.currentConfig[propertyName]);
        }
コード例 #57
0
 internal LocalCallDescriptorForInitializeNode
 (
     Hashtable environmentVariablesToSend,
     LoggerDescription[] nodeLoggers,
     int nodeId,
     BuildPropertyGroup parentGlobalProperties,
     ToolsetDefinitionLocations toolsetSearchLocations,
     int parentProcessId,
     string parentStartupDirectory
 )
     : base(LocalCallType.InitializeNode)
 {
     this.environmentVariables   = environmentVariablesToSend;
     this.parentGlobalProperties = parentGlobalProperties;
     this.toolsetSearchLocations = toolsetSearchLocations;
     this.nodeLoggers            = nodeLoggers;
     this.nodeId                 = nodeId;
     this.parentProcessId        = parentProcessId;
     this.parentStartupDirectory = parentStartupDirectory;
 }
コード例 #58
0
        public virtual void SetConfigurationProperty(string propertyName, string propertyValue)
        {
            if (!this.project.QueryEditProjectFile(false))
            {
                throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED);
            }

            string condition = String.Format(CultureInfo.InvariantCulture, ConfigProvider.configString, this.ConfigName);

            this.project.BuildProject.SetProperty(propertyName, propertyValue, condition);

            // property cache will need to be updated
            this.currentConfig = null;
            // Signal the output groups that something is changed
            foreach (OutputGroup group in this.OutputGroups)
            {
                group.InvalidateGroup();
            }
            this.project.SetProjectFileDirty(true);

            return;
        }
コード例 #59
0
ファイル: BuildRequest.cs プロジェクト: szaliszali/msbuild
        /// <summary>
        /// Called by the Engine
        /// </summary>
        internal BuildRequest
        (
            int handleId,
            string projectFileName,
            string[] targetNames,
            BuildPropertyGroup globalProperties,
            string toolsetVersion,
            int requestId,
            bool useResultsCache,
            bool unloadProjectsOnCompletion
        )
            :
            this
            (
                handleId,
                projectFileName,
                targetNames,
                (IDictionary)null,
                toolsetVersion,
                requestId,
                useResultsCache,
                unloadProjectsOnCompletion
            )
        {
            // Create a hashtable out of the BuildPropertyGroup passed in.
            // This constructor is called only through the object model.
            if (globalProperties != null)
            {
                Hashtable globalPropertiesTable = new Hashtable(globalProperties.Count);
                foreach (BuildProperty property in globalProperties)
                {
                    globalPropertiesTable.Add(property.Name, property.FinalValue);
                }

                this.globalPropertiesPassedByTask = globalPropertiesTable;
                this.globalProperties             = globalProperties;
            }
        }
コード例 #60
0
ファイル: IntrinsicTask.cs プロジェクト: yxbdali/msbuild
        /// <summary>
        /// Creates an IntrinsicTask object around a "task" node
        /// </summary>
        internal IntrinsicTask(XmlElement taskNodeXmlElement, EngineLoggingServices loggingServices, BuildEventContext eventContext, string executionDirectory, ItemDefinitionLibrary itemDefinitionLibrary)
        {
            this.taskNodeXmlElement    = taskNodeXmlElement;
            this.conditionAttribute    = taskNodeXmlElement.Attributes[XMakeAttributes.condition];
            this.loggingServices       = loggingServices;
            this.buildEventContext     = eventContext;
            this.executionDirectory    = executionDirectory;
            this.itemDefinitionLibrary = itemDefinitionLibrary;

            ErrorUtilities.VerifyThrow(IsIntrinsicTaskName(taskNodeXmlElement.Name), "Only PropertyGroup and ItemGroup are known intrinsic tasks");

            switch (taskNodeXmlElement.Name)
            {
            case XMakeElements.propertyGroup:
                backingType = BackingType.PropertyGroup;
                // If the backing type is a property group, we can just use a property group object; its semantics aren't
                // tangled up with the project object. Put another way, we only really need the code that understands the XML
                // format of a property group, and we can get that without the rest of BuildPropertyGroup getting in the way.
                // Specify that these properties are output properties, so they get reverted when the project is reset.
                backingPropertyGroup = new BuildPropertyGroup(null /* no parent project */, taskNodeXmlElement, PropertyType.OutputProperty);
                break;

            case XMakeElements.itemGroup:
                backingType = BackingType.ItemGroup;
                // If the backing type is an item group, we just re-use the code that understands the XML format of an item group;
                // the semantics of BuildItemGroup are too coupled to its current use in the Project object for us to re-use it.
                backingItemGroupXml = new BuildItemGroupXml(taskNodeXmlElement);
                List <XmlElement> children = backingItemGroupXml.GetChildren();
                backingBuildItemGroupChildren = new List <BuildItemGroupChildXml>(children.Count);

                foreach (XmlElement child in children)
                {
                    BuildItemGroupChildXml childXml = new BuildItemGroupChildXml(child, ChildType.Any);
                    backingBuildItemGroupChildren.Add(childXml);
                }
                break;
            }
        }