Skip to content

.NET 10: odd <ItemGroup> behavior if directory that has parenthesis #11237

Closed
@jonathanpeppers

Description

Issue Description

We're trying to get on .NET 10 here:

We are currently blocked on this <ItemGroup> not working as expected:

https://github.com/dotnet/sdk/blob/e847db398b6ffcbaa94ea85dee7a84c6480d3da5/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.DefaultItems.props#L82-L90

Which results in this value missing a %(RuntimePackLabels) item metadata, even though $(UseMonoRuntime) is true:

Image

However, if I add a log message, such as:

<_Logging Include="UseMonoRuntime=$(UseMonoRuntime);_TargetFrameworkVersionWithoutV=$(_TargetFrameworkVersionWithoutV)" />

It prints values as expected:

Image

Steps to Reproduce

I am unable to make a small repro, this example works fine:

<Project>
  <PropertyGroup>
    <_DotNetSdk>D:\dotnet-sdk-10.0.100-alpha.1.25056.1-win-x64\sdk\10.0.100-alpha.1.25056.1\</_DotNetSdk>
    <TargetFramework>net10.0</TargetFramework>
    <TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
    <TargetFrameworkVersion>v10.0</TargetFrameworkVersion>
    <_TargetFrameworkVersionWithoutV>$(TargetFrameworkVersion.TrimStart('vV'))</_TargetFrameworkVersionWithoutV>
  </PropertyGroup>
  <Import Project="$(_DotNetSdk)Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.props" />
  <Target Name="Print">
    <Message Text="%(FrameworkReference.Identity) RuntimePackLabels=%(FrameworkReference.RuntimePackLabels)" Importance="High" />
  </Target>
  <PropertyGroup>
    <UseMonoRuntime>true</UseMonoRuntime>
  </PropertyGroup>
</Project>
> & "D:\dotnet-sdk-10.0.100-alpha.1.25056.1-win-x64\dotnet.exe" build foo.targets -tl:off -bl -t:Print
  Microsoft.NETCore.App RuntimePackLabels=Mono

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.05

So, it must be related to a larger build with lots of item groups?

Best repro I have, is to build an Android project on the PR above...

Expected Behavior

After project evaluation, we should have an item like:

<FrameworkReference Include="Microsoft.NETCore.App" RuntimePackLabels="Mono" />

Actual Behavior

After project evaluation, we are missing %(RuntimePackLabels) for:

<FrameworkReference Include="Microsoft.NETCore.App" />

Analysis

Here is an example .binlog, if you search for FrameworkReference:

build.zip

I made these changes in this log:

    <!-- Allow opt-in to Mono runtime pack for .NET 6.0 or higher -->
    <FrameworkReference Update="Microsoft.NETCore.App"
                        RuntimePackLabels="Mono"
--                      Condition="'$(UseMonoRuntime)' == 'true' And ('$(_TargetFrameworkVersionWithoutV)' != '') And ('$(_TargetFrameworkVersionWithoutV)' >= '6.0')"
                         />
++<_Logging Include="UseMonoRuntime=$(UseMonoRuntime);_TargetFrameworkVersionWithoutV=$(_TargetFrameworkVersionWithoutV)" />

Versions & Configurations

We've seen this behavior with the following .NET SDKs:

  • 10.0.100-alpha.1.25056.1
  • 10.0.100-alpha.1.24573.1

On both Windows and macOS, local and CI.

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions