0

I'm trying to define a new, custom element in Directory.Build.targets: <DynamicReference>. This definition should be a combination of <Reference> and <PackageReference>. The decision of which to use will be predicated on the Boolean properties "DynamicReferencesUseLocal" and "DynamicReferencesUsePackages".

The behavior I'm trying to achieve is simple, but I don't have much understanding of how to "alias" these items and/or combine them.

Given a project that imports this item, the intended result would be a project that's able to reference assemblies like so:

<ItemGroup>
  <DynamicReference Prefer="Package">
    <PackageName>MyFramework.UI</PackageName>
    <PackageVersion>2.0.*</PackageName>
    <LocalPath>C:/SomePath/MyFramework.UI.dll</LocalPath>
  </DynamicReference>
</ItemGroup>

Essentially this is the same as defining two ItemGroups using a Condition attribute. This seems a little bloated when there's many references.

2
  • Do you mean switching between ProjectReference and PackageReference? (A use case for switching between Reference and PackageReference seems very unusual.) Commented Aug 2, 2024 at 13:04
  • 1
    This seems like an XY problem to me. Commented Aug 2, 2024 at 13:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.