public SpecFlowProject ReadSpecFlowProject(string projectFilePath) { var specFlowProject = new SpecFlowProject(); Microsoft.Build.Evaluation.Project project = null; string projectFolder = Path.GetDirectoryName(projectFilePath); try { var reader = XmlReader.Create(projectFilePath); project = ProjectCollection.GlobalProjectCollection.LoadProject(reader); specFlowProject.ProjectSettings.ProjectFolder = projectFolder; specFlowProject.ProjectSettings.ProjectName = Path.GetFileNameWithoutExtension(projectFilePath); specFlowProject.ProjectSettings.AssemblyName = project.AllEvaluatedProperties.First(x => x.Name == "AssemblyName").EvaluatedValue; specFlowProject.ProjectSettings.DefaultNamespace = project.AllEvaluatedProperties.First(x => x.Name == "RootNamespace").EvaluatedValue; } catch (Exception ex) { Debug.WriteLine(ex, "Project load error"); return(new SpecFlowProject()); } specFlowProject.ProjectSettings.ProjectPlatformSettings.Language = GetLanguage(project); foreach (ProjectItem item in project.FeatureFiles()) { var featureFile = new FeatureFileInput(item.EvaluatedInclude); var ns = item.GetMetadataValue("CustomToolNamespace"); if (!String.IsNullOrEmpty(ns)) { featureFile.CustomNamespace = ns; } specFlowProject.FeatureFiles.Add(featureFile); } ProjectItem appConfigItem = project.ApplicationConfigurationFile(); if (appConfigItem != null) { var configFilePath = Path.Combine(projectFolder, appConfigItem.EvaluatedInclude); var configFileContent = File.ReadAllText(configFilePath); var configurationHolder = GetConfigurationHolderFromFileContent(configFileContent); specFlowProject.ProjectSettings.ConfigurationHolder = configurationHolder; specFlowProject.Configuration = configurationLoader.LoadConfiguration(configurationHolder); } return(specFlowProject); }