Skip to content

Commit

Permalink
Merge pull request #116 from christianzingg/feature/93_Directory.Buil…
Browse files Browse the repository at this point in the history
…d.props

also evaluate licenses in Directory.Build.props
  • Loading branch information
Lexy2 authored Feb 28, 2025
2 parents dcc6c18 + 6c3cf8c commit ac9014f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ dotnet-project-licenses -i projectFolder

### Print unique licenses

Values for the input may include a folder path, a Visual Studio '.sln' file, a '.csproj' or a '.fsproj' file or a '.vbproj' file.
Values for the input may include a folder path, a Visual Studio '.sln' file, a '.csproj' or a '.fsproj' file or a '.vbproj' file or the 'Directory.Build.props' file.

```ps
dotnet-project-licenses -i projectFolder -u
Expand Down
21 changes: 14 additions & 7 deletions src/Methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ public async Task<Dictionary<string, PackageList>> GetPackages()

public string[] GetProjectExtensions(bool withWildcard = false) =>
withWildcard ?
new[] { "*.csproj", "*.fsproj", "*.vbproj" } :
new[] { ".csproj", ".fsproj", ".vbproj" };
new[] { "*.csproj", "*.fsproj", "*.vbproj", "Directory.Build.props" } :
new[] { ".csproj", ".fsproj", ".vbproj", "Directory.Build.props" };

/// <summary>
/// Retreive the project references from csproj or fsproj file
Expand Down Expand Up @@ -865,11 +865,18 @@ private async Task<IEnumerable<string>> GetValidProjects(string projectPath)
.ToList();
break;
default:
validProjects =
GetProjectExtensions(withWildcard: true)
.SelectMany(wildcardExtension =>
Directory.EnumerateFiles(projectPath, wildcardExtension, SearchOption.AllDirectories)
);
if (pathInfo.Name == "Directory.Build.props")
{
validProjects = new string[] { projectPath };
}
else
{
validProjects =
GetProjectExtensions(withWildcard: true)
.SelectMany(wildcardExtension =>
Directory.EnumerateFiles(projectPath, wildcardExtension, SearchOption.AllDirectories)
);
}
break;
}

Expand Down

0 comments on commit ac9014f

Please sign in to comment.