Permit specifying output file
For get* CLI switches
Fixes #
Context
Design question: Should SimpleErrorLogger be enabled if we're redirecting into a file? Should it be enabled whenever we aren't using TerminalLogger?
The reason I ask is that it's the only thing that writes to stderr at the moment, so since I re-enabled normal loggers when writing to a file, that means I disabled SimpleErrorLogger, and now errors come through stdout (with no TerminalLogger) as MSBuild normally does things. I'm not convinced that's ideal...
Changes Made
Permit using -getResultOutputFile to redirect output from get* into a file. Example: dotnet msbuild foo.csproj -getProperty:Bar -getResultOutputFile:Biz.txt This writes the value of property Bar into Biz.txt.
Testing
~I tried using this, and it failed to load my test project because it was trying to include $(MonoAndroidResourcePrefix)(various), and MonoAndroidResourcePrefix was not defined. That doesn't feel like it's related to my change, but it's hard for me to firmly state that this works when 100% of my tests have failed 🙃~
I tried again today, and the error mysteriously disappeared. It failed until I added Flush, but now it seems to work properly.
Notes
Looking forward to have this in an SDK near me!
FYI, I called my commit 'Start on test', but that was just because I don't have the components to build on this laptop, so I didn't run it locally before pushing, but it seems to have built and passed 🙂
@Forgind is this a .NET 9 feature only? Or is it expected to become available in a .NET 8 SDK band?
@tmds it'll be in MSBuild 17.10/SDK 8.0.3xx.
Good job