pamidur / aspect-injector

AOP framework for .NET (c#, vb, etc)
Apache License 2.0
742 stars 111 forks source link

Feature: using Apects.Cache and other parent nugets without runnining aspect-injector every build #192

Closed kondr1 closed 2 years ago

kondr1 commented 2 years ago

I using Aspects.Cache in my nuget, but don't use ApsectInjector. So it running every build =(

AspectInjector|1.0.0: Found 0 aspects, 0 injections

In my main solution i plan don't use any injections too I need to use <AspectInjector_Enabled>false</AspectInjector_Enabled> in every csproj? Maybe exists some workaround?

pamidur commented 2 years ago

Let me reiterate and see if I got your issue right:

If that's the case - you can make all references resources in assm A - Private as per https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#controlling-dependency-assets.

<ItemGroup>
    <PackageReference Include="AspectInjector" Version="2.7.3" PrivateAssets="all" />
  </ItemGroup>
kondr1 commented 2 years ago

In that case i need PrivateAssets="all" in that file

Ok :) I see what i should do. Thanks!

pamidur commented 2 years ago

Oh my bad actually, you'll need either

  <ItemGroup>
    <PackageReference Include="Aspects.Cache" Version="2.0.2" PrivateAssets="buildTransitive"/>
  </ItemGroup>

or this if you want to completely hide caching attributes and classes

  <ItemGroup>
    <PackageReference Include="Aspects.Cache" Version="2.0.2" PrivateAssets="all"/>
  </ItemGroup>
pamidur commented 2 years ago

Please feel free to reopen this issue if it doesn't work for you!