question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conditional project references fail when targeting multiple TFMs

See original GitHub issue

Reproduction steps:

  1. Create 3 projects, LibA, LibB & LibC (netstandard1.1)
  2. Reference LibA from LibB and LibB from LibC
  3. Add a class in LibA and reference it in LibC
  4. Confirm successful build
  5. Make LibC target another TFM (netcoreapp1.1)
  6. Add a project reference to LibA, conditional to the second TFM
  7. Run dotnet build or build in VS2017
  8. Build fails for first TFM (netstandard1.1)

The following error message is provided: Cannot find project info for ‘X:\LibA\LibA.csproj’. This can indicate a missing project reference. LibC C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets 92

This is LibC.csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>    
    <TargetFrameworks>netstandard1.1;netcoreapp1.1</TargetFrameworks>
  </PropertyGroup>
  <ItemGroup>
    <ProjectReference Include="..\LibB\LibB.csproj" />
  </ItemGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1'">
    <ProjectReference Include="..\LibA\LibA.csproj" />
  </ItemGroup>
</Project>

Removing the conditional TFM, e.g. letting LibC only target netstandard1.1 again will result in a successful build even if the conditional reference remains.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
dsplaistedcommented, Dec 24, 2020

@sfoslund Would you be able to take a look at this? Nick’s comment describes the issue.

0reactions
nguerreracommented, Dec 22, 2020

I haven’t worked on this project for a long time, so I’m not aware of any updates. Adding @marcpopMSFT @dsplaisted

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - $(TargetFramework) is empty when targeting multiple ...
I have a project targeting multiple frameworks using <TargetFrameworks> (plural) in my .csproj file. This works fine, but I'm unable to do ...
Read more >
Conditional TargetFrameworks for Multi-Targeted .NET SDK ...
This is a short post that addresses an issue I ran into today when converting a project to .NET Core 2.0. I've been...
Read more >
Non-Trivial Multi-Targeting with .NET | by Brad Robinson
The VS 2017 issue with conditional TargetFrameworks; When building a project with a conditional project reference, the imported project ...
Read more >
Support multiple .NET Framework versions in your project file
Description of the various methods to target multiple .NET Framework versions from within a single NuGet package in your project file.
Read more >
Load Project Dependencies does not load a conditional ...
In real-life the problem is that a project has two TFMs and two conditional project references, one for each TFM. If the net472...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found