dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.23k stars 1.35k forks source link

Question: it is possible to determine which task produced which item? #4670

Closed xtmq closed 5 years ago

xtmq commented 5 years ago

I build a project via MsBuild API, using BuildManager. So after a build I have ProjectInstance object. Is it possible to understand which ProjectItemInstance was produced bu which task (or target)?

I know about BuildResult.ResultsByTarget but for some items there is no data there. For example for Compile items from MarkupCompilePass1.

The only was I found so far is pass a logger, specify BuildParameters.LogTaskInputs = true and parse log messages. But it is relatively slow =(

Thanks in advance!

rainersigwald commented 5 years ago

No, I don't think there's a general way to do this. We don't even have a good event in the engine for "an item was created" -- it's just logged as a message.

May I ask why you're interested in this? I would generally not expect it to be useful, as most processes and extenders would expect items injected via a new target/task to work as if they were produced by the normal process.

xtmq commented 5 years ago

This time I'm looking for a way to distinct Compile items from MarkupCompilePass1 from all other Compile items. But I have expected this answer to be honest. But was afraid that I miss some obvious thing... Thanks for the fast reply!