Skip to content

Commit

Permalink
Declare System.Net.Http as a framework dependency
Browse files Browse the repository at this point in the history
Declaring System.Net.Http as a nuget dependency for net47 is problematic for some consuming projects because it offers assembly version 4.1.1.3, whereas the FluentAssertions assembly itself references 4.2.0.0 of that same assembly. This causes the C# compiler to break the build for these projects.

The fix is to declare that System.Net.Http comes from an ordinary `Reference` item that is supplied by the target framework (which in fact it should as it does for FluentAssertions itself) instead of from the NuGet package.

It is interesting to call out that although this project previously declared `System.Net.Http` as a `PackageReference`, msbuild nevertheless chose to use the targeting framework version instead of the nuget version. This is ... not something I can explain. And many other projects have the same behavior, which is why it typically works for consuming projects. I don't know why exactly, but some projects do _not_ share this behavior, and those that actually use the nuget dependency that was declared here (before this change) would fail to compile.

Fixes #2121
  • Loading branch information
AArnott committed Feb 4, 2023
1 parent 214dd22 commit fffd370
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Src/FluentAssertions/FluentAssertions.csproj
Expand Up @@ -91,7 +91,10 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net47'">
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<TfmSpecificFrameworkAssemblyReferences Include="System.Net.Http">
<TargetFramework>$(TargetFramework)</TargetFramework>
</TfmSpecificFrameworkAssemblyReferences>
<Reference Include="System.Net.Http" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
Expand Down

0 comments on commit fffd370

Please sign in to comment.