private bool Condition(XElement element, PropertyValues props)
 {
     XAttribute condition = element.Attribute("Condition");
     if (condition != null) {
         var parser = new ProjectFilePropertyExpressionParser(props);
         return parser.ParseCondition(condition.Value);
     } else {
         return true;
     }
 }
 private void LoadProperties(IEnumerable<XElement> propertyGroups, PropertyValues props)
 {
     foreach (var propertyGroup in propertyGroups) {
         if (Condition(propertyGroup, props)) {
             foreach (var propElement in propertyGroup.Elements()) {
                 if (Condition(propElement, props)) {
                     props[propElement.Name.LocalName] = propElement.Value;
                 }
             }
         }
     }
 }
        public VisualStudioProjectFileDetails LoadProject(string path, string projectName, string configuration)
        {
            XDocument proj = XDocument.Load(path);

            var props = new PropertyValues();
            props["Configuration"] = configuration;

            var propertyGroups = proj.Element(msbuild + "Project").Elements(msbuild + "PropertyGroup");
            LoadProperties(propertyGroups, props);

            var projectDirectory = Path.GetDirectoryName(path);
            var outputDirectory = Path.Combine(projectDirectory, props["OutputPath"]);
            var outputFile = Path.Combine(outputDirectory, props["AssemblyName"] + "." + GetExtensionForOutputType(props["OutputType"]));

            return new VisualStudioProjectFileDetails {
                OutputFile = outputFile.TrimEnd('\\'),
                OutputDirectory = outputDirectory.TrimEnd('\\'),
                Name = projectName,
                ProjectFile = path,
                ProjectDirectory = projectDirectory,
            };
        }