phmonte / Buildalyzer

A utility to perform design-time builds of .NET projects without having to think too hard about it.
MIT License
589 stars 92 forks source link

Add API to retrieve compiler command-line and arguments from `IAnalyzerResult` #212

Closed siegfriedpammer closed 1 year ago

siegfriedpammer commented 1 year ago

Proposed API:

interface IAnalyzerResult
{
+ /// <summary>
+ /// Gets the compiler command produced by the `CoreCompile` task.
+ /// </summary>
+ string Command { get; }
+ /// <summary>
+ /// Gets the arguments passed to the compiler produced by the `CoreCompile` task.
+ /// </summary>
+ IEnumerable<string> CompilerArguments { get; }
}

The use-case behind this is that I want to use Roslyn's CSharpCommandLineParser to get the correct compilation and parser options. Currently I have to implement my own MSBuild logger similar to https://github.com/daveaglick/Buildalyzer/blob/main/src/Buildalyzer/Logging/EventProcessor.cs to get to the raw command.

Would accept a PR that implements this feature?

daveaglick commented 1 year ago

Would accept a PR that implements this feature?

Yeah, absolutely - Buildalyzer has an intentionally narrow scope, but this feature sounds like it fits right in with the goal of easily providing information about the build and compilation process.

My only request would be that integration tests are provided similar to the existing ones (I don't think you'll need any new projects under test, just a new parameterized test or two using the existing integration test setup that verifies the feature against different project types).

Let me know if you need a lift with anything!

daveaglick commented 1 year ago

New release of Buildalyzer with this feature went out last night - thanks again!