ligershark / psbuild

This project aims to make using MSBuild easier from powershell
Apache License 2.0
121 stars 18 forks source link

Enable a debugMode switch #15

Open sayedihashimi opened 10 years ago

sayedihashimi commented 10 years ago

After building the project it would be nice if we could inspect the resulting project file. To facilitate this let's add a -debugMode switch to Invoke-MSBuild that will use the MSBuild APIs to invoke the build and then return the build result as well as resulting ProjectInstance.

Since we will be calling the APIs instead of the command line we may not be able to understand all the properties but known ones should be passed in.

Tasks

sayedihashimi commented 10 years ago

Added related functionality via commit e63f4b2307ecf0c29291c5a47897553e3b678425

sayedihashimi commented 10 years ago

Now when you build you can pass in a new switch -debugMode this will cause the build to be executed using the MSBuild APIs. After executing the build the result will be passed back to the caller. This will include a ProjectInstance object which contains the project in the state when the build was completed.

PS> $bResult = Invoke-MSBuild .\temp.proj -debugMode

PS> $bResult.EvalProperty('someprop')
default

PS> $bResult.EvalItem('someitem')
temp.proj

PS> $bResult.ExpandString('$(someprop)')
default

PS> $bResult.ExpandString('@(someitem->''$(someprop)\%(Filename)%(Extension)'')')
default\temp.proj

You can get full access to the ProjectInstance object with the ProjectInstance property.

More functionality is available via the ProjectInstance object.

PS> $bResult.ProjectInstance.GetItems('someitem').EvaluatedInclude
temp.proj

You can get the BuildResuilt via the BuildResult parameter.

PS> $bResult.BuildResult.OverallResult
Failure