Thanks for replying but this doesn't address the issue.Using out-host in this
manner causes output to be buffered before it get to out-host, so it appears
in one big glob when msbuild is done, and all of the coloring that is done by
msbuild to it's output is also lost in this scenario.
Here's a little something I found though.
https://connect.microsoft.com/feedba...7986&SiteID=99
I think this addresses what I want, simply that msbuild writes to the
console directly, which would allow it to behave exactly as it did in cmd.exe.
"/\/\o\/\/ [MVP]" wrote:
> You are putting the output and the boolean to the pipeline
> (return is optional all output gets returned.
>
> you can use
>
> MSbuild | out-host
>
> this will output the test to the console but not the pipeline
>
> MowPS>Function test {
> >> ipconfig | out-host
> >> if( $LastErrorCode -eq 0 ) {
> >> return $true
> >> } else {
> >> return $false
> >> }
> >> }
> >>
> MowPS>test
>
> Windows IP Configuration
> Ethernet adapter Local Area Connection:
> ...
>
> False
>
> MowPS>$test = test
>
> Windows IP Configuration
> Ethernet adapter Local Area Connection:
>
> MowPS>$test
> False
>
> b.t.w. this also has the lineadding bug theat is bothering a lot of the
> powershell output.
>
> Greetings /\/\o\/\/
>
>
> "fuzzy333" wrote:
>
> > I'm trying to figure out how to run msbuild in a function and have this
> > function return true or false indicating msbuild's success or failure.
> > Also important, I want the normal output of the command (streaming and
> > with intended foregroung/background color) to appear in the console as
> > msbuild is running so, for example:
> >
> > # ---------------------------------
> > function Compile() {
> > msbuild
> > if( $LastErrorCode -eq 0 ) {
> > return $true
> > } else {
> > return $false
> > }
> > }
> >
> > #$compileSuccess = Compile
> > Compile
> >
> > Calling "Compile" without assigning it to a variable I get the behavior that
> > I'm looking for, but no return value. However calling Compile and assigning
> > the return value to $compileSucsess as in the commented line in the example
> > causes all output from msbuild from to be stored in $compileSuccess variable,
> > not just the boolean return value, and msbuild's output doesn't appear in the
> > console as intended.
> >
> > So how can I acheive the behavior I'm looking for? Is there a way to simply
> > return a value, not all output from the function?