public override Task <int> Execute() { List <FileInfo> matchedProjects = ProjectUtility.GetAllMatchedProjects(_options.RootDir, new[] { ".csproj" }, _options.Include, _options.Exclude).ToList(); foreach (FileInfo projectFile in matchedProjects) { Project project = _projectStore.Load(projectFile); List <ProjectItemGroupElement> groups = project.Xml.ItemGroups.Where(s => s.Label == "Elephant Project").ToList(); if (!groups.Any()) { Log.Debug("Skipping {File}, nothing to do", projectFile.FullName); continue; } // Remove groups foreach (ProjectItemGroupElement groupElement in groups) { project.Xml.RemoveChild(groupElement); } Log.Information("Altered {File}, removed all project reference groups", Path.GetRelativePath(_options.RootDir.FullName, projectFile.FullName)); project.Save(); } return(Task.FromResult(0)); }
private string GetAssemblyName(FileInfo projectFile) { Project project = _projectStore.Load(projectFile); string id = project.GetPropertyValue("PackageId"); if (string.IsNullOrEmpty(id)) { id = project.GetPropertyValue("AssemblyName"); } if (string.IsNullOrEmpty(id)) { id = Path.GetFileNameWithoutExtension(projectFile.Name); } return(id); }