Is there a way to convert something like this:
#define ERROR_LOG_LEVEL 5
Into something that msbuild via command line will pass to its projects?
msbuild.exe {???}ERROR_LOG_LEVEL=5 target
I've read the responses to similar questions, and it looks like the answer is no, just want to double-check in case some genius has found a workaround.
Use MSBuild at a command prompt To run MSBuild at a command prompt, pass a project file to MSBuild.exe, together with the appropriate command-line options. Command-line options let you set properties, execute specific targets, and set other options that control the build process.
Builds the targets in the project file that you specify. If you don't specify a project file, MSBuild searches the current working directory for a file name extension that ends in proj and uses that file. You can also specify a Visual Studio solution file for this argument.
This walkthrough demonstrates how to use MSBuild in a command prompt to build a Visual Studio C++ project. You'll learn how to create an XML-based . vcxproj project file for a Visual C++ console application. After building the project, you'll learn how to customize the build process.
By default, MSBuild will attempt to only run the TypeScript compiler when the project's source files have been updated since the last compilation.
Macros may be defined by passing the /D
option to the compiler. You can specify the /D
option from MSBuild using the AdditionalOptions
of ClCompile
:
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>/DERROR_LOG_LEVEL=5 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup>
If you want to be able to pass the value for the macro via a call to msbuild.exe, you can easily do that too:
<ItemDefinitionGroup Condition="'$(ErrorLogLevel)' != ''">
<ClCompile>
<AdditionalOptions>/DERROR_LOG_LEVEL=$(ErrorLogLevel) %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup>
with msbuild.exe invoked as:
msbuild /p:ErrorLogLevel=5 MyProject.vcxproj
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With