예제 #1
0
        /// <summary>
        /// Create XML Element representing a target
        /// </summary>
        private void GenerateProjectRootElement()
        {
            _projectRootElement.SetAttribute("xmlns", @"http://schemas.microsoft.com/developer/msbuild/2003");

            if (_defaultTargets != null)
            {
                _projectRootElement.SetAttribute("DefaultTargets", _defaultTargets);
            }

            if (_initialTargets != null)
            {
                _projectRootElement.SetAttribute("InitialTargets", _initialTargets);
            }

            if (_toolsVersion != null)
            {
                _projectRootElement.SetAttribute("ToolsVersion", _toolsVersion);
            }

            XmlElement propertyGroupElement = _projectXmlDocument.CreateElement("PropertyGroup", @"http://schemas.microsoft.com/developer/msbuild/2003");
            XmlNode    propertyGroup        = _projectRootElement.AppendChild(propertyGroupElement as XmlNode);
            XmlElement propertyElement      = _projectXmlDocument.CreateElement("GlobalConfigurationName", @"http://schemas.microsoft.com/developer/msbuild/2003");

            propertyElement.InnerXml = _filename + ":$(ConfigurationId)";
            propertyGroup.AppendChild(propertyElement as XmlNode);
            _projectXmlDocument.AppendChild(_projectRootElement as XmlNode);
        }
예제 #2
0
 /// <summary>
 /// Constructor allows you to set all the data members
 /// </summary>
 public ProjectDefinition(string filename, string initialTargets, string defaultTargets, string toolsVersion, bool createMSBuildProject)
 {
     _initialTargets       = initialTargets;
     _defaultTargets       = defaultTargets;
     _toolsVersion         = toolsVersion;
     _filename             = filename;
     _createMSBuildProject = createMSBuildProject;
     _projectXmlDocument   = new XmlDocumentWithLocation();
     _targets            = new Dictionary <string, TargetDefinition>();
     _projectRootElement = _projectXmlDocument.CreateElement("Project", @"http://schemas.microsoft.com/developer/msbuild/2003");
     GenerateProjectRootElement();
 }