94

Here's a snippet from my csproj file:

<ProjectReference Include="..\program_data\program_data.csproj" Condition="'$(Configuration)'=='Debug'">
      <Project>{4F9034E0-B8E3-448E-8794-CF9B9A5E7D46}</Project>
      <Name>program_data</Name>
</ProjectReference>

What I'd like to do is include program_data.dll for multiple build configurations, for example, both Release and Debug.

I tried doing the following

Condition="'$(Configuration)'=='Debug' || '$(Configuration)'=='Release'"

but Visual Studio chokes on this.

Is there a way I can do this, or must I have a separate <ProjectReference> for each build config?

1 Answer 1

149

You should use Or, not ||:

Condition="'$(Configuration)'=='Debug' Or '$(Configuration)'=='Release'"
8
  • @Charlie - I have linked to the MSBuild conditionals documentation.
    – Oded
    Jun 10, 2011 at 21:16
  • I noticed that, thanks. I find the MSDN library can be tricky unless you know what you're looking for. Jun 10, 2011 at 21:29
  • If you want your reference work for both Release and Debug, and you don't have any other configurations, it is simpler to make your ProjectReference unconditional by removing the "Condition" attribute.
    – Oleg
    Mar 16, 2016 at 18:50
  • 1
    @Oleg I would imagine they have more than just Debug and Release, otherwise no need for the question. I have a few solutions that also have Debug MONO and Release MONO.
    – DJH
    Mar 24, 2016 at 10:38
  • 1
    Can I have my own Condition? in case I only want to reference this library in case that condition is set? and if so how do I set it Aug 22, 2020 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.