Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6209643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:01:22+00:00 2026-05-24T06:01:22+00:00

I have an engine library that is used by a game executable. That engine

  • 0

I have an “engine” library that is used by a game executable. That engine library is also used by an editor executable.

I want to build the engine lib with a preprocessor constant EDITOR when it’s built for editor.exe
When the engine lib is built for game, there is no “EDITOR” preprocessor constant.

Is there a way to say that a preprocessor constant from the referencing project should be used for dependency builds too?

I’ve tried this in the editor .csproj:

<Project ToolsVersion="4.0" DefaultTargets="Build">
  <PropertyGroup>
    <AssemblyName>MyEditor</AssemblyName>
    <DefineConstants>EDITOR</DefineConstants>
  ...

but that only applies to MyEditor.exe assembly. I want it to apply to all references too.

I hope this is clear enough 🙂

Edit: I can get this working from the command line with msbuild MyEditor.csproj /p:DefineConstants=EDITOR, but I don’t know how to get the same effect in Visual Studio

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:01:23+00:00Added an answer on May 24, 2026 at 6:01 am

    It is possible, but requires a bit of MSBuild trickery. The way referenced projects get built is that they end up in the @(ProjectReferenceWithConfiguration) item array, through manipulations in the Microsoft.Common.targets file. Now if the project were included in this item array like this, in one project but not from the other,

    <!-- pseudo-code for what Microsoft.Common.targets creates -->
    <ItemGroup>
       <ProjectReferenceWithConfiguration Include="ReferencedProject.csproj">
          <AdditionalProperties>DefineConstants=EDITOR</AdditionalProperties>
       </ProjectReferenceWithConfiguration>
    </ItemGroup>
    

    …it would get built the way you want. How do you set this up though? Well, you can wire into the creation of the @(ProjectReferenceWithConfiguration) item array with your own custom target and add the AdditionalProperties metadata value. Something like this…

    <!-- inside referencing project -->
    <Target Name="AddEditorConstant"
       AfterTargets="AssignProjectConfiguration"
       BeforeTargets="_SplitProjectReferencesByFileExistence">
       <ItemGroup>
          <ProjectReferenceWithConfiguration
             Condition="'%(Identity)' == 'ReferencedProject.csproj'>
             <AdditionalProperties>DefineConstants=EDITOR</AdditionalProperties>
          </ProjectReferenceWithConfiguration>
       </ItemGroup>
    </Target>
    

    (note, I didn’t actually run this, some experimentation may be required)

    For a more generic solution that reverses the location of the customization, placing it inside the reference project rather than inside the referencing, you could instead inject the parent project with the reference as a custom property into all references,

    <!-- somewhere common to all projects -->
    <Target Name="InjectReferencingProject"
       AfterTargets="AssignProjectConfiguration"
       BeforeTargets="_SplitProjectReferencesByFileExistence">
       <ItemGroup>
          <ProjectReferenceWithConfiguration>
             <AdditionalProperties>ReferencingProject=$(MSBuildProjectFile)</AdditionalProperties>
          </ProjectReferenceWithConfiguration>
       </ItemGroup>
    </Target>
    

    And then, inside the ReferencedProject.csproj, modify whatever you want based on which parent project has the reference,

    <!-- inside referenced project -->
    <PropertyGroup>
       <DefineConstants>default-constants</DefineConstants>
       <DefineConstants
          Condition="'$(ReferencingProject)' == 'SomeSpecialProject.csproj'"
          >$(DefineConstants);EDITOR</DefineConstants>
    </PropertyGroup>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a game engine that uses OpenGL for display. I coded a small
If have I have a game engine that has multiple threads that all work
I have developed direct3D video rendering library that is used for rendering video in
Suppose I have an component based game engine, and in that engine I have
We have an engine that loads dlls dynamically (whatever is located in a certain
I have an XPath engine implementation that needs to be tested. Is there a
I have a search engine that searches albums. For each music album, I have
I'm considering using JRuby on App Engine but have heard that Juby app on
I'm attempting to make a simple homebrew game engine/framework in android. I have the
I'm working on an LGPL game engine library and I prefer to code without

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.