From 6c3cf8ccb8d8cb00095a43ea33df31abfdd9bf4e Mon Sep 17 00:00:00 2001 From: Christian Zingg Date: Thu, 19 May 2022 17:03:57 +0200 Subject: [PATCH] also evaluate licenses in Directory.Build.props --- README.md | 2 +- src/Methods.cs | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 05d96e1c..986318f7 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,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 diff --git a/src/Methods.cs b/src/Methods.cs index c0a93e59..36acc62d 100644 --- a/src/Methods.cs +++ b/src/Methods.cs @@ -360,8 +360,8 @@ public async Task> 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" }; /// /// Retreive the project references from csproj or fsproj file @@ -817,11 +817,18 @@ private async Task> 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; }