I need to get access to the msbuild command line parameters (the specified targets and properties in particular) from within the project file being processed in order to pass them down to the Properties of an <MSBuild> task.
My msbuild file uses a large number of properties, and I don't know ahead of time which ones will be overridden via the command line, so I'm looking for a way to pass these down without specifying each one manually to the Properties of the <MSBuild> task. Something like the $* variable in a bat file.
How can I accomplish this?
This question is ancient, but FWIW here is how I have handled getting the MSBuild command line parameters:
Option 1 (not recommended)
$([System.Environment]::CommandLine.Trim())
The problem is that this will cause the following error when using
dotnet build
.Option 2 (FTW)
Create a Task
Use the Task to create an Item for each argument
Optionally, reconstruct the arguments into a single string