Skip to content

assarbad/msvc-undoc

Repository files navigation

Undocumented MSVC

Environment variables

  • LOG_BUILD_COMMANDLINES, see below.

Used internally (requiring further research)

  • MSC_CMD_FLAGS

Findings by others

Additional resources

Useful tips

Use LOG_BUILD_COMMANDLINES to log build command lines

Ever wondered what command lines get effectively executed "behind" those response files used by Visual Studio and MSBuild?

LOG_BUILD_COMMANDLINES has the answer. The environment variable should be set to a file path, which will be a plain text log file receiving all those build command lines. This works even for those command lines that actually end up being invoked using response files due to command line length limitations on Windows.

The following Directory.Build.props provides a simple example of how to use this method. It uses the SetEnv MSBuild target to ensure that the environment variable gets set prior to invocation of the tools that honor the presence of this variable.

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets="LogBuild">
	<PropertyGroup>
		<ThisProjectBuildLogFileName Condition="'$(MSBuildProjectName)' == ''">$(MSBuildThisFileDirectory)BuildCommandLines.log</ThisProjectBuildLogFileName>
		<ThisProjectBuildLogFileName Condition="'$(MSBuildProjectName)' != ''">$(MSBuildThisFileDirectory)BuildCommandLines-$(MSBuildProjectName).log</ThisProjectBuildLogFileName>
	</PropertyGroup>
	<Target Name="LogBuild" BeforeTargets="SetUserMacroEnvironmentVariables;SetBuildDefaultEnvironmentVariables">
		<Message Text="Setting LOG_BUILD_COMMANDLINES='$(ThisProjectBuildLogFileName)'" />
		<SetEnv Name="LOG_BUILD_COMMANDLINES" Value="$(ThisProjectBuildLogFileName)" Prefix="false" />
	</Target>
</Project>

ETW-related GUIDs

  • GUID_MSVC_PROVIDER: {9C642431-C036-7958-4B0E-FE163528322B}