Will Comeaux
Will Comeaux

Reputation: 365

Azure DevOps Conditional Compilation

I am trying to setup a build in Azure DevOps with some projects that use conditional compilation symbols. The build keeps failing because it appears to not be seeing my symbol. Any ideas where to apply the setting?

I have two projects that share some code and the symbol is basically used to control some using statements between the projects.

It appears that Azure DevOps ignores what is in the tag of my csproj files. Here is a pic of the relevant csproj section. enter image description here

Here is a pic of the MSBuild task main configuration screen. enter image description here

Here is a pick of the code - sorry, I have to scrub the name of the library from everything. enter image description here

The build is throwing an error on this project saying "Microsoft.ServiceFabric" does not exist - and it shouldn't because the conditional compilation should make it use the XYZ_ServiceFabric which has the other using statement.

I can confirm that the project(s) build just fine with and without a constant definition.

Thanks for any help.

Upvotes: 4

Views: 2257

Answers (1)

Remco Brilstra
Remco Brilstra

Reputation: 828

The Visual Studio Build step should pickup your conditional compilation symbols. do make sure that they are setup for the 'Release' configuration not only for debug.

enter image description here

As they are set separately by default and the default behavior of Azure Piplines is to build in 'Release'.

if you wish to change that you can set the 'BuildConfiguration' variable of the build to 'debug' (but i wouldn't advise that).

Upvotes: 2

Related Questions