bugproof / DotnetThirdPartyNotices

A .NET tool to generate file with third party legal notices
MIT License
22 stars 2 forks source link

Doesn't work with Blazor projects #8

Open bugproof opened 2 years ago

bugproof commented 2 years ago

Upvote & Fund

Fund with Polar

danielklecha commented 6 months ago

It worked with version 0.3.2.

  1. create Blazor app in .NET 8
  2. add any reference e.g. Serilog
  3. add <StaticWebAssetsEnabled>false</StaticWebAssetsEnabled> to csproj
  4. run dotnet-thirdpartynotices in solution folder
  5. Confirm that third-party-notices.txt wa generated with one license (PASS)
bugproof commented 6 months ago

Just tried it. For some reason my Blazor WASM project in .NET 8 doesn't compile with <StaticWebAssetsEnabled>false</StaticWebAssetsEnabled> and without it I get Resolved files count: 0

part of the csproj file:

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

    <PropertyGroup>
        <TargetFramework>net8.0</TargetFramework>
        <Nullable>enable</Nullable>
        <ImplicitUsings>enable</ImplicitUsings>
        <RootNamespace>Client</RootNamespace>
        <PublishTrimmed>true</PublishTrimmed>
        <ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
        <LangVersion>preview</LangVersion>
        <BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
    </PropertyGroup>

I have for example

<PackageReference Include="MudBlazor" Version="6.17.0" />

There is some issue with

https://github.com/bugproof/DotnetThirdPartyNotices/blob/f95ca4ab50c8b55f90da04dad4fa06346d8e1730/src/DotnetThirdPartyNotices/Services/ProjectService.cs#L18

bugproof commented 6 months ago

This tool works perfectly though: ThirdLicense

I did some small analysis and:

It wraps dotnet list package --include-transitive command to extract the dependencies - I don't know which .NET versions it supports. Their license finder code is very basic and it doesn't embed full license text in the file.

So ways to solve this issue is:

A. Wrapping dotnet list package as alternative for ComputeFilesToPublish and just use resolver logic as usual B. Checking how dotnet list package is implemented and replicate it here -- which is just a wrapper over nuget cli ListPackageCommandRunner

This class seems to be responsible for it MSBuildAPIUtility which I think is just based on project.assets.json file.