msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

Permit specifying output file

Open Forgind opened this issue 1 year ago • 1 comments

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

Forgind avatar Jan 12 '24 19:01 Forgind

Looking forward to have this in an SDK near me!

tmds avatar Feb 20 '24 15:02 tmds

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 avatar Feb 23 '24 17:02 Forgind

@Forgind is this a .NET 9 feature only? Or is it expected to become available in a .NET 8 SDK band?

tmds avatar Apr 11 '24 08:04 tmds

@tmds it'll be in MSBuild 17.10/SDK 8.0.3xx.

rainersigwald avatar Apr 11 '24 16:04 rainersigwald

Good job

VAllens avatar Apr 12 '24 04:04 VAllens