Skip to content

Instantly share code, notes, and snippets.

@asklar
Created May 19, 2020 03:01
Show Gist options
  • Save asklar/f94fc2d1867cefe0f5d3c70d59c8ccba to your computer and use it in GitHub Desktop.
Save asklar/f94fc2d1867cefe0f5d3c70d59c8ccba to your computer and use it in GitHub Desktop.
Preprocess C++ to file
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Preprocess">
<Message Condition="'$(Source)'!=''" Text="Preprocessing: $(Source)"/>
<Error Condition="'$(Source)'==''" Text="To generate a pre-processed file, please specify a source file with msbuild /p:Source=nameOfTheSource.cpp"/>
<CL PreprocessToFile="true" Sources="$(Source)"
AdditionalIncludeDirectories="%(ClCompile.AdditionalIncludeDirectories)"
PreprocessorDefinitions="%(ClCompile.PreprocessorDefinitions)"
AdditionalOptions="%(ClCompile.AdditionalOptions) /d1PP"
PreprocessKeepComments="true"
PreprocessOutputPath="$(Source.Replace('.cpp', '.pp'))"
/>
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment