Skip to content

[Bug]: Condition attribute is ignored in legacy csproj files when referenced from an SDK csproj file  #8889

@MovGP0

Description

@MovGP0

Issue Description

When an SDK style csproj file references an legacy csproj file, that references other projects conditionally based on the build target, the condition in the legacy project file is ignored.

When the SDK style project file is backported to an legacy csproj file format, the build works fine.

Steps to Reproduce

Sdk.csproj

<Project Sdk="Microsoft.NET.Sdk">
<!-- ... -->
<ItemGroup>
    <ProjectReference Include="..\Legacy\Legacy.csproj" />
  </ItemGroup>
</Project>

Legacy.csproj

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- ... -->
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'False|False' ">
    <ProjectReference Include="..\Legacy2\Legacy2.csproj"  Condition=" '$(Configuration)|$(Platform)' == 'False|False' " />
  </ItemGroup>
</Project>

Expected Behavior

The Condition attribute should be honored.

Actual Behavior

The condition is ignored and the build breaks because it can't build the Legacy2 project.

Analysis

Our current workaround is to use legacy .csproj file format only.

Versions & Configurations

MSBuild version 17.6.3+07e294721 for .NET Framework
17.6.3.22601

Visual Studio Version 17.6.3

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions