dotnet / dotnet/msbuild

ItemGroup item condition with metadata doesn't work in Project

Open
#3,479 8 comments 19 reactions 0 assignees View on GitHub
Area: Documentation Area: Language Priority:3 triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

`ItemGroup` with an item which has a condition with item metadata doesn't work in `Project`, but it works in a `Target`.

### Steps to reproduce

#### Example `ItemGroup`
```xml

```

This works in a `Target`, but not in `Project`.

#### Command line
```
msbuild
```
or
```
dotnet build
```

### Expected behavior
It uses the metadata to evaluate the condition.

### Actual behavior
It throws an exception:
```
error MSB4191: The reference to custom metadata "X" at position 1 is not allowed in this condition "'%(Content.X)' == 'abc'".
```

### Environment data
`msbuild /version` output:
15.7.179.6572

OS info:
Windows 10

If applicable, version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc):
- Visual Studio: 15.7.4.
- .NET CLI: 2.1.300.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.