Preventing mobile projects from using certain .cs files in a Shared Project

52 views Asked by At

I am making a mobile app. In my Solution I have a shared project. Some of the files I do not want to be used in my iOS or Android builds.

My code looks something like this:

#if __MOBILE__
#else
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Models;
using Azure.Storage.Queues;
using Azure.Storage.Queues.Models;
using System;

namespace Blah.Utils
{
   public static class AzureBlobService
   {
       public static async Task<string> CreateCloudQueue(string connectionString, string queueName)
       {
         // blah
       }
   }
}
#endif

This doesn't seem to be removing this file for my mobile apps. It still wants me to get those nuget Azure.Storage packages. How can I get that #if to work the way I want it to?

1

There are 1 answers

0
ashlar64 On

Well after struggling with this for a long time and thinking it must be some obscure setting somewhere...it was because my shared library was being referenced by a project in between my mobile app project.

So in other words the projects were referencing each other like this: Sharedproject <--- CoreLib proj <--- Mobile app proj

And I wasn't putting MOBILE in the 'Conditional Compilation Symbol' in the CoreLib proj properties.

ugh