While there are likely many ways to answer this question, I decided to make use of Notepad++ since I already had it installed (it’s my go to text editor). So, how did I use Notepad++ to get the answer? Simple…
Step 1 – Copy Results to Notepad++
Open the build results for the build that you are interested in, select the PowerShell script task in the build results hierarchy, select the log text, copy it to the clipboard then paste it into Notepad++.
- Press Ctrl+F to display the Find dialog.
- Click on the Mark tab.
- Check the Bookmark line option.
- Check the Wrap around option.
- Select the Extended option. This is required to take advantage of the “\r” text entered in step 3 above.
- Finally, click the Mark All button and click Close.
You will notice that all files with the .js extension have been marked.
Step 3 – Remove Unwanted Lines
Finally, we want to remove all unmarked lines so we are left with only the filenames that we care about. To do this, select the Search->Bookmark->Removed Unmarked Lines menu option.
There is nothing magical to this approach and you might already have your favorite way to do a count of filenames by type. In my case, I was simply making use of a tool that I already had installed and it took me only a few seconds to get the answer I needed. If you know of an alternative, possibly better, way to achieve the same result, I’d love to hear about it below!
P.S. If you are curious as to how I generated the list of files within a directory on a hosted build agent, check out Get (more) Build Agent Details with PowerShell.