I have some issues with project referencing netstandard projects from net462 projects.
When I run tests in MyTests, it's complaining about missing dlls, those are the dlls from MyLogging NuGet references (SeriLog). I don't want MyTests to make a NuGet reference to MyLogging as that defeats the purpose of it, neither do I want to include the tests in MyLogging. Is there a way make a project reference automatically include all sub references? I'd rather not include a refence to MyLogging dependencies in MyTests, as I'm not interested in testing the how, just that it correctly logs to whatever it should based on configuration. Including MyLogging dependencies in the test project is leaking the implementation, and I will have to maintain references if I decide to log in a difference way.
MyLogging
- target netstandard1.3
- published as NuGet to be consumed by other projects
- Dependencies (here SeriLog) are referenced as a NuGet package
csproj file.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.3</TargetFramework>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="1.1.2" />
<PackageReference Include="Serilog" Version="2.4.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="1.4.0" />
<PackageReference Include="Serilog.Sinks.ColoredConsole" Version="2.0.0" />
</ItemGroup>
</Project>
MyTests
- target net462
- project reference to MyLogging.
csproj file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="4.19.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="1.1.2" />
<PackageReference Include="NSubstitute" Version="2.0.3" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.analyzers" Version="0.1.0" />
<PackageReference Include="xunit.categories" Version="1.0.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="MyLogging\MyLogging.csproj" />
</ItemGroup>
</Project>
If I use the dotnet cli tooling, I can run dotnet test
and it runs without issue, so I assume that it's VS2017 that gets confused with the new project format.