dotnet / dotnet/msbuild

[Feature Request]: Provide an Item Function to stringify an Item and its Metadata

Open
#9,749 2 comments 1 reaction 0 assignees View on GitHub
backlog Feature Request needs-design Priority:2 triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 6h
Merged PRs (30d)
139

Description

### Summary

It's currently very easy to 'dump' a Property during external end-to-end testing of MSBuild logic by writing key/value pairs to a file. There's not a good way to dump an Item and its metadata similarly, making it very hard to get in-build logs or checkpoints without resorting to finicky, hand-rolled serialization schemes. We should provide a way to dump an Item that parallels the logic used to dump Items to stdout with `-getItem`.

### Background and Motivation

I'm trying to write tests for https://github.com/dotnet/sdk/pull/38504 using the SDK's testing framework for testing MSBuild, which relies on injecting targets that log specific properties to an external file, then read them in. It's very hard to do the same for Items.

### Proposed Feature

There should be some function, let's say '[MSBuild]::DumpItem(Item)', that writes an Item in some sort of semi-structured format. Options might include, but are not limited to:

* JSON Lines - i.e. one line of JSON, each line emitted as a separate Item (for future logging in a WriteLinesToFile Task?)
* some kind of key/value keyed collection, like space-delimited `key=value` pairs?
* ???

### Alternative Designs

_No response_

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.