TFS 2012/MSBuild: adding additional conditional compilation symbols to the ones already defined in project file csproj C#

StackOverflow https://stackoverflow.com/questions/20490450

Frage

I have a large solution, and (external library dependencies) I have set up project properties where based on a conditional symbol I either link against an old (symbol missing) or a new version (symbol present), with also a few code changes based on changed interface.

I had it running as a TFS build as well for quite a while (old, stable version) but now have the need to have the new version run as well in parallel. So I added the /p:DefineConstants="NEW_LIBRARY" as an MSBuild Argument.

The problem here is that I already have conditional symbols in the solution at other places and want to retain those, but they are overriden by that argument.

How can I add the conditional symbol in the one build and not in the other (ok, not adding it is trivial) while leaving the symbols already defined in each project's properties untouched?

Many thanks

War es hilfreich?

Lösung

Create a new project configuration so you could just pass the Configuration property, i.e. ReleaseNewLib:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseNewLib|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>TRACE;NEW_LIBRARY</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>

>

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top