Mattzz
Mattzz

Reputation: 1

using compilation symbols(?) in custom build events VS2013

I am trying to make a build event and I want to know if it is possible to use symbols that you define with #define TEST.

I am guessing it would have to be done using custom macros defined in the project file.

Thank you for your help

Upvotes: 0

Views: 594

Answers (1)

Lanorkin
Lanorkin

Reputation: 7534

It is not possible to directly import #define TEST constructions from your *.cs files (ok, it's possible, but I think it doesn't worth it).

Instead, you can define build configuration (or use standard Debug and Release), and add properties to your *.csproj project file like this:

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
    <TestDefined>yes</TestDefined>
</PropertyGroup>

Thus, you define a constant for Debug configuration. Then, you can use it in build event conditions like

if ('$(TestDefined)' == 'yes') ...

Alternatively, you can define constants using visual editor for project properties from inside VS.Net, they are stored & initialized in similar way by VS.Net:

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
    ...
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    ...
</PropertyGroup>

They require more coding to parse, but it's easier to edit constants themselves.

Upvotes: 1

Related Questions