I want to specify a string parameter from MSBuild commandline.
I define a string type macro in c++ project like:
#define MYSTRING "hoge"
MYSTRING
is assigned to a CString variable like:
CString str = MYSTRING;
And I want to pass this macro parameter via msbuild command line instead defining it on code.
I refered to this similar question, MSBuild C++ - command line - can pass defines? I added the parameter with /D option in the AdditionalOptions of ClCompile:
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>/D MYSTRING=$(MyString) %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup>
And then, with msbuild.exe invoked as:
msbuild /p:MyString="hoge" MyProject.vcxproj
But the error occured on line CString str = MYSTRING;
:
error C2065: 'hoge': undeclared identifier
Do you know why this kind of error occurs ?
Is there any workaround?