Working with Visual Studio build logs can be difficult. If you ever need to turn on detailed logging when building your application in Visual Studio then chances are you’ll need a better place to view the log than just your output window.
You can select all of the build log text, copy and paste into a text editor but there may be too much data on the clipboard and Visual Studio will throw an out of memory error.
How to Save Visual Studio Build Logs?
You can actually just left-click in the output window and then hit CTL + S and you will be prompted with a save file prompt to save your build log output log to a text file.
To change the amount of information that is generated in your logs you need to update the verbosity level. In Visual Studio You can update the verbosity level under Tools > Options, then go to the Projects and Solutions page and select the Build and Run menu item.
From here you’ll have a number of options ranging from Quiet to Diagnostic which can help you track down any nasty bugs you’re dealing with.
A more in-depth look at your output build log
Advanced tip: If you’re still having trouble trying to track down a bug in the logging you can turn on Binary Logging.
The first thing to do is to install the Project System Tools extension. Go to Tools > Extensions and Updates. On the left-hand menu click Online. In the search box type Project System Tools. From the search results, click the download button to install the extension. You’ll need to close all Visual Studio instances to allow the installation to take place. Follow the prompts that the VSIX Installer displays to complete the installation.
Installing this extension will add some extra items to your View > Other Windows list. Select the Build Logging item and you will see a new pane. In the top left of the pane, there is a play button. Press this button and then build your project. When finished you will see a number of items in the Build Logging pane. Double-clicking one of these will bring up the .binlog in an editor window. In this window, you can expand each of the steps in the build process to get detailed information on your build.
You can see from the image that some of the build log line items are made bold to highlight important steps in the build. You can expand these items to show the dependencies that have been imported and the output DLL’s created in your bin folder. If you look at the Properties pane you can see various information related to the build step:
- time tasks started and finished
- parameters to the command
- output files and results to commands
The main advantages of binary logs are:
- faster builds
- smaller disk size
- easier to read/analyze
- programmatic access
- embedded source files
These advantages are all explained in detail at msbuildlog.com
These are all nice additions to the standard build log, but there is a lot more you can do with your .binlog file. Using the msbuildlog tool you can open and view the build log in a graphical interface that you can search both the log file and (if the log has embedded files) you can search all files and see the source code related to the build step. You can remove nodes to declutter your workspace when tracking down an issue. You can display target dependencies for each target and much more.
With the .binlog file, you can also replay the build by passing the file to MSBuild. You can then set the verbosity level to create the usual build log file for that verbosity level (without actually rebuilding the project). This means you could share your .binlog file with someone to help you investigate a build issue.
In most cases Visual Studio is good enough to investigate build issues, but when the time comes that you need some extra help, hopefully these tools will help.