Exemplo n.º 1
0
        private VSProjectConfiguration ReadPropertyGroup(XmlReader xmlReader)
        {
            VSProjectConfiguration configuration = new VSProjectConfiguration();

            if (xmlReader["Condition"] != null && propertiesDictionary == false)
            {
                configuration.Condition = xmlReader["Condition"];
            }

            xmlReader.Read();
            IDictionary <string, string> props = propertiesDictionary ? properties : configuration.Properties;

            while (xmlReader.NodeType != XmlNodeType.EndElement)
            {
                if (string.Equals(xmlReader.Name, "PublishDatabaseSettings", StringComparison.OrdinalIgnoreCase))
                {
                    xmlReader.Skip();
                    continue;
                }

                string name = xmlReader.Name;
                string val  = xmlReader.ReadElementContentAsString();
                if (props.ContainsKey(name))
                {
                    continue;
                }

                props.Add(name, val);
            }

            return(configuration);
        }
Exemplo n.º 2
0
        private VSProjectConfiguration ReadPropertyGroup(XmlReader xmlReader)
        {
            VSProjectConfiguration configuration = new VSProjectConfiguration();

            if (xmlReader["Condition"] != null && propertiesDictionary == false)
            {
                configuration.Condition = xmlReader["Condition"];
            }

            xmlReader.Read();

            while (xmlReader.NodeType != XmlNodeType.EndElement)
            {
                if (propertiesDictionary)
                {
                    if (properties.ContainsKey(xmlReader.Name))
                    {
                        throw new ArgumentException(
                                  string.Format(
                                      CultureInfo.InvariantCulture,
                                      "Property '{0}' has already been added to the group. VS project '{1}'",
                                      xmlReader.Name,
                                      ProjectFileName));
                    }

                    properties.Add(xmlReader.Name, xmlReader.ReadElementContentAsString());
                }
                else
                {
                    if (configuration.Properties.ContainsKey(xmlReader.Name))
                    {
                        throw new ArgumentException(
                                  string.Format(
                                      CultureInfo.InvariantCulture,
                                      "Property '{0}' has already been added to the group. VS project '{1}'",
                                      xmlReader.Name,
                                      ProjectFileName));
                    }

                    configuration.Properties.Add(xmlReader.Name, xmlReader.ReadElementContentAsString());
                }
            }

            return(configuration);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the output path for a specified VisualStudio project. The output path is relative
        /// to the directory where the project file is located.
        /// </summary>
        /// <param name="buildConfiguration">The build configuration.</param>
        /// <returns>
        /// The output path or <c>null</c> if the project is not compatible.
        /// </returns>
        /// <exception cref="ArgumentException">The method could not extract the data from the project file.</exception>
        public LocalPath GetProjectOutputPath(string buildConfiguration)
        {
            // skip non-C# projects
            if (ProjectTypeGuid != VSProjectType.CSharpProjectType.ProjectTypeGuid)
            {
                return(null);
            }

            // find the project configuration
            string condition = string.Format(
                CultureInfo.InvariantCulture,
                "'$(Configuration)|$(Platform)' == '{0}|AnyCPU'",
                buildConfiguration);
            VSProjectConfiguration projectConfiguration = Project.FindConfiguration(condition);

            if (projectConfiguration == null)
            {
                string message = string.Format(
                    CultureInfo.InvariantCulture,
                    "Could not find '{0}' configuration for the project '{1}'.",
                    condition,
                    ProjectName);

                throw new ArgumentException(message);
            }

            if (false == projectConfiguration.Properties.ContainsKey("OutputPath"))
            {
                string message = string.Format(
                    CultureInfo.InvariantCulture,
                    "Missing OutputPath for the '{0}' configuration of the project '{1}'.",
                    buildConfiguration,
                    ProjectName);

                throw new ArgumentException(message);
            }

            return(new LocalPath(projectConfiguration.Properties["OutputPath"]));
        }