diff --git a/src/DotnetThirdPartyNotices/Commands/ScanCommand.cs b/src/DotnetThirdPartyNotices/Commands/ScanCommand.cs index 4491600..bc27bc1 100644 --- a/src/DotnetThirdPartyNotices/Commands/ScanCommand.cs +++ b/src/DotnetThirdPartyNotices/Commands/ScanCommand.cs @@ -109,7 +109,9 @@ private async Task GenerateOutputFileAsync(string? outputFilePath) { if (outputFilePath == null) return; - logger.LogInformation("Resolved {LicenseContentsCount} licenses for {Sum}/{ResolvedFilesCount} files", _licenseContents.Count, _licenseContents.Values.Sum(v => v.Count), _licenseContents.Values.Sum(v => v.Count) + _unresolvedFiles.Count); + var uniqueResolvedFilesCount = _licenseContents.Values.Sum(v => v.GroupBy(x => x.SourcePath).Count()); + var uniqueUnresolvedFilesCount = _unresolvedFiles.GroupBy(x => x.SourcePath).Count(); + logger.LogInformation("Resolved {LicenseContentsCount} licenses for {Sum}/{ResolvedFilesCount} files", _licenseContents.Count, uniqueResolvedFilesCount, uniqueResolvedFilesCount + uniqueUnresolvedFilesCount); logger.LogInformation("Unresolved files: {UnresolvedFilesCount}", _unresolvedFiles.Count); var stopWatch = new Stopwatch(); stopWatch.Start(); @@ -117,7 +119,7 @@ private async Task GenerateOutputFileAsync(string? outputFilePath) foreach (var (licenseContent, resolvedFileInfos) in _licenseContents) { var longestNameLen = 0; - foreach (var resolvedFileInfo in resolvedFileInfos) + foreach (var resolvedFileInfo in resolvedFileInfos.GroupBy(x => x.SourcePath).Select(x => x.First())) { var strLen = resolvedFileInfo.RelativeOutputPath?.Length ?? 0; if (strLen > longestNameLen) diff --git a/src/DotnetThirdPartyNotices/DotnetThirdPartyNotices.csproj b/src/DotnetThirdPartyNotices/DotnetThirdPartyNotices.csproj index 9ceb646..8a4b9a5 100644 --- a/src/DotnetThirdPartyNotices/DotnetThirdPartyNotices.csproj +++ b/src/DotnetThirdPartyNotices/DotnetThirdPartyNotices.csproj @@ -10,7 +10,7 @@ dotnet-thirdpartynotices DotnetThirdPartyNotices A .NET tool to generate file with third party legal notices - 0.3.1 + 0.3.2 MIT git https://github.com/bugproof/DotnetThirdPartyNotices diff --git a/src/DotnetThirdPartyNotices/Models/ResolvedFileInfo.cs b/src/DotnetThirdPartyNotices/Models/ResolvedFileInfo.cs index 12059da..7aba4ac 100644 --- a/src/DotnetThirdPartyNotices/Models/ResolvedFileInfo.cs +++ b/src/DotnetThirdPartyNotices/Models/ResolvedFileInfo.cs @@ -2,9 +2,9 @@ namespace DotnetThirdPartyNotices.Models; -internal class ResolvedFileInfo +internal class ResolvedFileInfo(string sourcePath) { - public string? SourcePath { get; init; } + public string SourcePath { get; } = sourcePath; public string? RelativeOutputPath { get; init; } public FileVersionInfo? VersionInfo { get; init; } public NuSpec? NuSpec { get; init; } diff --git a/src/DotnetThirdPartyNotices/Services/ProjectService.cs b/src/DotnetThirdPartyNotices/Services/ProjectService.cs index 477dc55..df77890 100644 --- a/src/DotnetThirdPartyNotices/Services/ProjectService.cs +++ b/src/DotnetThirdPartyNotices/Services/ProjectService.cs @@ -45,9 +45,8 @@ private IEnumerable ResolveFilesUsingResolveAssemblyReferences var assemblyPath = item.EvaluatedInclude; var versionInfo = FileVersionInfo.GetVersionInfo(assemblyPath); var packagePath = localPackageService.GetPackagePathFromAssemblyPath(assemblyPath); - var resolvedFileInfo = new ResolvedFileInfo + var resolvedFileInfo = new ResolvedFileInfo(assemblyPath) { - SourcePath = assemblyPath, VersionInfo = versionInfo, RelativeOutputPath = Path.GetFileName(assemblyPath), PackagePath = packagePath, @@ -81,9 +80,8 @@ private IEnumerable ResolveFilesUsingComputeFilesToPublish(Pro var relativePath = item.GetMetadataValue("RelativePath"); var packagePath = localPackageService.GetPackagePathFromAssemblyPath(assemblyPath); var nuSpec = localPackageService.GetNuSpecFromPackagePath(packagePath) ?? throw new ApplicationException($"Cannot find package path from assembly path ({assemblyPath})"); - var resolvedFileInfo = new ResolvedFileInfo + var resolvedFileInfo = new ResolvedFileInfo(assemblyPath) { - SourcePath = assemblyPath, VersionInfo = FileVersionInfo.GetVersionInfo(assemblyPath), NuSpec = nuSpec, RelativeOutputPath = relativePath,