postsharp / Metalama

Metalama is a Roslyn-based meta-programming framework. Use this repo to report bugs or ask questions.
164 stars 4 forks source link

Why does postsharp include fixed version of Nuget.Packaging? #325

Open AC42admin opened 4 days ago

AC42admin commented 4 days ago

Hi,

We have some conflicts in our solution and had to fix the version of Nuget.X to the same as shipped with Postsharp....which is quite annoying.

Under this folder 'C:\ProgramData\PostSharp\2024.1.4\bin.Release\net472' the version of NuGet.Packaging.dll is 6.9.1.x.

Is there a way to use the latest NuGet.X in our solution without having errors or warnings @build?

As a workaround we fixed the reference to Nuget.Packaging to 6.9.1 in our related solutions.

prochan2 commented 3 days ago

Hello,

The folder C:\ProgramData\PostSharp\2024.1.4\bin.Release\net472 is meant to be used only by PostSharp and assemblies from this folder shouldn't be referenced. Having a project with PostSharp and the latest NuGet.Packaging referenced via NuGet, there's no build warning or error.

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

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NuGet.Packaging" Version="6.10.1" />
    <PackageReference Include="PostSharp" Version="2024.1.4" />
  </ItemGroup>

</Project>

Referencing PostSharp using NuGet is the only supported way. In case you cannot use NuGet, there is still a way to reference PostSharp without NuGet. But even though it's available, we do not recommend it, and we cannot provide support in case this doesn't work. It is also only supposed to work with non-sdk-style .NET Framework projects. You can find the details in our docs.

In case you do reference PostSharp via NuGet, and you're still experiencing this issue, please provide a project that reproduces this, so we can investigate further.