How can I trap warnings/errors when I try to build Nuget, Grunt, and Bower Packages from a TFS Build, PowerShell Script?
Here is the situation overview. We have a pre-build script that gets needed packages in place for MSBuild during our TFS build. The packages are created automatically when building through Visual Studio (2015), but apparently this is not done during compile using MSBuild. So, we came up with the script approach.
It is serving us fairly well, but the problem is that if warnings appear, they are sent back to the overall build, I guess, as a script error, bad exit code so the overall build process is seen as partially successful.
First off, here is the script code that carries out the operations...
&"C:\Program Files\Microsoft Team Foundation Server 14.0\Tools\Nuget.exe" restore $source\MyAppNet\MyAppWeb\MyAppWeb.sln
bower install -s
cmd.exe /c npm install
cmd.exe /c grunt concat
cmd.exe /c grunt less
And now an example of warnings...
In this particular example, the warnings are coming during the grunt operations.
I have tried directing output of the above commands to a file, but the contents do not contain these warnings. My hope is that I can find a way to see these warnings/errors in the PowerShell script and maybe send the results to a hashing function of some sort. Based on what I find, I'll set the script Exit code and handle that by modifying my XAML TFS Build Template to act accordingly.
So, the first part of my task, if possible is to notice WARN with the script. Does anyone know how I can capture messages such as these in my PowerShell script? Based on what they are the script's exit code will determine whether or not to terminate the entire build process.
I hope someone can help!
Thanks in advance!!