Reuse define statement from .h file in C# code

前端 未结 7 1894
广开言路
广开言路 2021-01-18 14:08

I have C++ project (VS2005) which includes header file with version number in #define directive. Now I need to include exactly the same number in twin C# project. What is th

7条回答
  •  星月不相逢
    2021-01-18 14:25

    You can achieve what you want in just a few steps:

    1. Create a MSBuild Task - http://msdn.microsoft.com/en-us/library/t9883dzc.aspx
    2. Update the project file to include a call to the task created prior to build

    The task receives a parameter with the location of the header .h file you referred. It then extracts the version and put that version in a C# placeholder file you previously have created. Or you can think using AssemblyInfo.cs that normally holds versions if that is ok for you.

    If you need extra information please feel free to comment.

提交回复
热议问题