RE: https://hachyderm.io/@tmeschter/116751973349195922
There's another option for getting information out of MSBuild that I didn't cover before because the thread was getting long: `-getTargetResult`.
In MSBuild a target can (optionally) return a set of items. This lets you treat it as a function, not just a "unit of work".
For example, you can run:
`dotnet build -getTargetResult:ResolveReferences`
and get
```
{
"TargetResults": {
"ResolveReferences": {
"Result": "Success",
"Items": [
{
"Identity": "C:\\Program Files\\dotnet\\packs\\Microsoft.NETCore.App.Ref\\10.0.8\\ref\\net10.0\\Microsoft.CSharp.dll",
"FileVersion": "10.0.826.23019",
...
},
{
"Identity": "C:\\Program Files\\dotnet\\packs\\Microsoft.NETCore.App.Ref\\10.0.8\\ref\\net10.0\\Microsoft.VisualBasic.Core.dll",
"FileVersion": "15.0.826.23019",
...
},
...
]
}
}
}
```
which is a list of all the references being passed to the C# compiler, along with a bunch of metadata on each.
Or you can run the "Build" target and get information about the outputs:
```
> dotnet build -getTargetResult:Build
{
"TargetResults": {
"Build": {
"Result": "Success",
"Items": [
{
"Identity": "C:\\Users\\me\\source\\repos\\TestConsole\\TestConsole\\bin\\Debug\\net10.0\\TestConsole.dll",
"ReferenceAssembly": "C:\\Users\\me\\source\\repos\\TestConsole\\TestConsole\\obj\\Debug\\net10.0\\ref\\TestConsole.dll",
"FullPath": "C:\\Users\\me\\source\\repos\\TestConsole\\TestConsole\\bin\\Debug\\net10.0\\TestConsole.dll",
...
}
]
}
}
}
```
So depending on the target that can be another option.
#msbuild #dotnet #csharp