0

I have a Class Library, let's call it BO, that is set for multi-targeted frameworks.

<TargetFrameworks>net40;net5.0</TargetFrameworks>

This "BO" has a net5.0 Projects Dependency / Reference to another Class Library, let's call it DA, that is .NET 5.0 only.

When I build the BO project, it does not build the DA project.
I have to first manually build the DA project and I can then build the BO project.
If I remove the multi-target "net40" from the BO, then the DA will build when I build the BO.

Am I missing something or is this a Visual Studio bug?

Here is the BO and DA project files.
BO

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFrameworks>net40;net5.0</TargetFrameworks>
    </PropertyGroup>

    <PropertyGroup>
        <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
        <Deterministic>false</Deterministic>
    </PropertyGroup>
    
    <ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
        <ProjectReference Include="..\DA.csproj" />
    </ItemGroup>
</Project>

DA

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.8" />
  </ItemGroup>
</Project>
goroth
  • 2,510
  • 5
  • 35
  • 66
  • 1
    Did you update visual studio to latest version? And you can also try to clean the project then build. – Dylan Aug 02 '21 at 10:04
  • @DylanZhu-MSFT I have tried the latest VS 2019 and VS 2022 but that both have the same problem. Cleaning all the projects in the solution does not seem to help. I'm pretty sure this is a MS / VS bug. – goroth Aug 02 '21 at 12:52
  • Thank you for feedback, and I reproduced it on my side. I suggest you report it to developer community: https://developercommunity.visualstudio.com/report?space=8&entry=problem – Dylan Aug 03 '21 at 07:20

0 Answers0