Skip to content

Honor csproj Conditions #46

@Piedone

Description

@Piedone

It seems to me that the tool currently only checks <PackageReference> elements in csprojs without parsing and evaluating said csprojs. This causes Conditions in csprojs not to be applied either, causing the tool to process package references that aren't actually active in the current context.

For example, we have this in one of our projects:

<ItemGroup Condition="'$(NuGetBuild)' == 'true'">
  <PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="8.0.2" />
</ItemGroup>

This package reference is checked for consolidation even if the NuGetBuild variable is not true.

This is an issue because it necessitates keeping package references consolidated that we don't actually need, see #41 (comment).

You don't necessarily need to parse these Conditions; rather, MSBuild can be used to get these values. For an inspiration, check out this code that similarly retrieves an MSBuild property's value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions