Conditional project references fail when targeting multiple TFMs
See original GitHub issueReproduction steps:
- Create 3 projects, LibA, LibB & LibC (netstandard1.1)
- Reference LibA from LibB and LibB from LibC
- Add a class in LibA and reference it in LibC
- Confirm successful build
- Make LibC target another TFM (netcoreapp1.1)
- Add a project reference to LibA, conditional to the second TFM
- Run dotnet build or build in VS2017
- 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:
- Created 6 years ago
- Comments:11 (9 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sfoslund Would you be able to take a look at this? Nick’s comment describes the issue.
I haven’t worked on this project for a long time, so I’m not aware of any updates. Adding @marcpopMSFT @dsplaisted