arcade icon indicating copy to clipboard operation
arcade copied to clipboard

Getting NETSDK1023 even when xunit.assert isn't implicitly referenced

Open bricelam opened this issue 2 years ago • 5 comments

  • [ ] This issue is blocking
  • [ ] This issue is causing unreasonable pain

After a130eb4216444f36a8966bd0c7ab97fa0d6ece6d, we're seeing some unusual behavior in the EF Core specification tests (tests that ship as NuGet packages for providers to use).

We have these lines in our csproj:

<Project>
  <PropertyGroup>
    <IsUnitTestProject>False</IsUnitTestProject>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="xunit.assert" Version="$(XUnitVersion)" />
    <PackageReference Include="xunit.core" Version="$(XUnitVersion)" />
  </ItemGroup>
</Project>

The error messages that started showing up after the arcade commit are as follows:

D:\efcore.dotnet\sdk\8.0.100-preview.6.23279.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.Shared.targets(152,5): error NETSDK1023: A PackageReference for 'xunit.assert' was included in your project. This package is implicitly referenced by the .NET SDK and you do not typically need to reference it from your project. For more information, see https://aka.ms/sdkimplicitrefs [D:\efcore\test\EFCore.Specification.Tests\EFCore.Specification.Tests.csproj] D:\efcore.dotnet\sdk\8.0.100-preview.6.23279.4\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.Shared.targets(152,5): error NETSDK1023: A PackageReference for 'xunit.core' was included in your project. This package is implicitly referenced by the .NET SDK and you do not typically need to reference it from your project. For more information, see https://aka.ms/sdkimplicitrefs [D:\efcore\test\EFCore.Specification.Tests\EFCore.Specification.Tests.csproj]

However, if I comment out the PackageReferences I get compiler errors saying that it can't find xUnit.net types.

For now, I've worked around the issue by adding <NoWarn>NETSDK1023</NoWarn>, but it would be good to understand why IsImplicitlyDefined="true" is affecting this project when the package reference clearly isn't being added outside of the project.

Release Note Category

  • [ ] Feature changes/additions
  • [ ] Bug fixes
  • [ ] Internal Infrastructure Improvements

Release Note Description

bricelam avatar Jun 12 '23 20:06 bricelam

@agocke can you help here?

missymessa avatar Aug 24 '23 20:08 missymessa

ping @agocke :)

missymessa avatar Sep 21 '23 19:09 missymessa

Could I get a binlog from the efcore build? I looked through the source and the reason wasn't obvious.

agocke avatar Oct 05 '23 22:10 agocke

@bricelam can you help @agocke help you? :)

missymessa avatar Oct 19 '23 20:10 missymessa

Steps:

  1. Clone dotnet/efcore
  2. Search for NETSDK1023 and remove it
  3. Get a binlog

bricelam avatar Oct 20 '23 16:10 bricelam