Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Microsoft.Sbom.Targets] Doesn't find files in Artifacts output layout #715

Open
Tracked by #693
KalleOlaviNiemitalo opened this issue Sep 19, 2024 · 0 comments
Open
Tracked by #693
Labels
.NET Pull requests that update .net code

Comments

@KalleOlaviNiemitalo
Copy link

KalleOlaviNiemitalo commented Sep 19, 2024

Microsoft.Sbom.Targets 2.2.8 doesn't find the names of referenced NuGet packages when I use it with .NET SDK 8.0.304 in a project that specifies artifacts output layout in Directory.Build.props:

  <PropertyGroup>
    <UseArtifactsOutput>true</UseArtifactsOutput>
    <ArtifactsPath>$(MSBuildThisFileDirectory).artifacts</ArtifactsPath>
  </PropertyGroup>

Specifically, the NuGet and NuGetProjectCentric component detectors do not detect any components in this case.

The component detectors search for files such as project.assets.json in $(SbomGenerationBuildComponentPath), whose default value is $(MSBuildProjectDirectory) here:

<SbomGenerationBuildComponentPath Condition=" '$(SbomGenerationBuildComponentPath)' == '' ">$(MSBuildProjectDirectory)</SbomGenerationBuildComponentPath>

When the artifacts output layout is used, project.assets.json is not within $(MSBuildProjectDirectory) so it is not found during component detection.

It seems I can work around the incompatibility by setting <SbomGenerationBuildComponentPath>$(BaseIntermediateOutputPath)</SbomGenerationBuildComponentPath>, but I'm not sure whether that could break something else. Perhaps it'll break detection of third-party non-NuGet components that have been copied into the project source directory.

Fixing this properly may require changing https://github.com/microsoft/component-detection/ so that the artifacts path can be passed as a separate parameter and each component detector can then decide whether to search for files in the source directory, in the artifacts directory, or both.

Originally posted by @KalleOlaviNiemitalo in #693 (comment)

@KalleOlaviNiemitalo KalleOlaviNiemitalo changed the title [Microsoft.Sbom.Targets] Artifacts output layout [Microsoft.Sbom.Targets] Doesn't find files in Artifacts output layout Sep 19, 2024
@sfoslund sfoslund added needs triage Default status upon issue submission .NET Pull requests that update .net code and removed needs triage Default status upon issue submission labels Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.NET Pull requests that update .net code
Projects
None yet
Development

No branches or pull requests

2 participants