dotnet / dotnet/msbuild

Expand Item Metadata in Item Functions

Open
#6,196 3 comments 2 reactions 0 assignees View on GitHub
Area: Language needs-design triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 13h
Merged PRs (30d)
133

Description

Based on my testing, it is possible to use MSBuild properties in Item Functions, as in this example project:

```xml

```

However, it is _not_ possible to use _item metadata_ in Item Functions, as in this example project:

```xml

```

The `SomeItemWithMetadata` items will be `path/to/file.%(VERSION).ext` and `path/to/file.Metadata('Version').ext`, resp.

I think this feature would be generally useful, but let me briefly explain my use case: I am writing managed plugins for the Unity game engine. The C# projects for these plugins need to reference Unity assemblies stored in "packages", which Unity stores in a folder called `PackageCache`. There, every package is in a folder called `com.unity.packageName@` where `` is a SemVer string. I want to define MSBuild properties for some of the common assembly/package paths, for reuse between C# projects. So, ideally, I would like my projects to look as follows (with `Project` tags ommitted...):

```xml

./relative/path/to/Unity/project/Library/PackageCache
com.unity.packageA@VERSION/sufolders/SomeAssemblyA.dll
com.unity.packageB@VERSION/sufolders/SomeAssemblyB.dll


```

Contributor guide

No contributing guide indexed for this repository

Research direction

No source files or tests are named. Start by reproducing the XML examples from the issue and tracing how MSBuild evaluates Item Functions and item metadata. Done means Item Functions can expand metadata such as %(Version) or Metadata('Version') and produce the expected transformed item paths.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.