Conditional Compilation Symbols Propagation

AllanChin.6924AllanChin.6924 USUniversity ✭✭✭

I ran into a very confusing issue where pre-processor symbols were not being defined when building via xbuild. My investigations uncovered the fact that the the symbols defined by default when created within Visual Studio for Mac were not all propagated to the corresponding .csproj. Check this out.

Only the "DEBUG" symbol is defined in the .csproj file. And in Visual Studio, I have no idea where it's getting the UNIFIED and MACOS symbols.

To get them into the .csproj file without manually editing the .csproj file, I added a test symbol in both Release and Debug configurations within Visual Studio. And then I then removed the test symbol.

I've attached my barebones Mac Library project.

And here's my environment.

=== Visual Studio Community 2017 for Mac ===

Version 7.1.3 (build 1)
Installation UUID: 52841cf1-dbf0-469c-a714-a263f1d0573b
Mono (d15-3/14f2c81) (64-bit)
GTK+ 2.24.23 (Raleigh theme)

Package version: 502000224

=== NuGet ===


=== .NET Core ===

Runtime: Not installed
SDK: Not installed
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.5.5
Location: /Applications/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 8.3.3 (12175.1)
Build 8E3004b

=== Xamarin.iOS ===

Version: (Visual Studio Community)
Hash: 8a391069
Branch: d15-3
Build date: 2017-08-28 16:51:11-0400

=== Xamarin.Android ===

Version: (Visual Studio Community)
Android SDK: /Users/allan/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
6.0 (API level 23)
7.1 (API level 25)

SDK Tools Version: 25.2.5
SDK Platform Tools Version: 26.0.0
SDK Build Tools Version: 25.0.3

Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Android Designer EPL code available here:

=== Xamarin.Mac ===

Version: (Visual Studio Community)

=== Xamarin Inspector ===

Not Installed

=== Build Information ===

Release ID: 701030001
Git revision: ba94259b26824844f4d2c76c794738eb75b85726
Build date: 2017-08-25 16:28:43-04
Xamarin addins: ee499cfb63ae406b1e394bf6a159ad2953f7fab6
Build lane: monodevelop-lion-d15-3

=== Operating System ===

Mac OS X 10.12.6
Darwin 16.7.0 Darwin Kernel Version 16.7.0
Thu Jun 15 17:36:27 PDT 2017
root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64


  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai


    That's odd. I did note that if I add a new compiler symbol into the define Symbols field of the Compiler settings page then the new and the existing symbols do get propagated to the .csproj file.

    I filed a bug report for this issue here:

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    Moving to Visual Studio For Mac sub-forum

  • AllanChin.6924AllanChin.6924 USUniversity ✭✭✭

    Thanks Jon - yes that's what I did as well to get them propagated. It was quite a "odd" gotcha!

  • Abhijeet_SuryaAbhijeet_Surya USMember ✭✭✭
    edited February 2018

    @JGoldberger , @AllanChin.6924

    I have some issue with regards to Build configurations & compiler symbols I have created new build configurations - DEV, SIT, PROD & also defined the compiler symbols for particular build configurations in VS for mac. & written below mention code, which is not working as expected. Can you please help me on this? #if !STORE //Do Something #endif When I build using Store(Release) configuration I expect that "DO SOMETHING" should not be executed.

Sign In or Register to comment.