0

enter image description here

As you can see in the above picture, I am trying to create a Xamarin Forms Application. The application is basically a retail utility app which will be targeted for the region US & Japan.

In the given Project structure SuppplyApp.Main is the Xamarin Forms entry project, which is being navigated from iOS and Android Project.

And SupplyApp.Japan & SupplyApp.US are the specific features for the regions US and Japan respectively.

In effect, I would like to use the combination of these based on the configuration.(eg:- SupplyApp.Main + SupplyApp.US OR SupplyApp.Main + SupplyApp.Japan)

I am using the combination of VSTS and Visual Studio App Center for my CICD & Distribution.

Here my doubt is during the time of build creation, is it possible to refer Projects (SupplyApp.US / SupplyApp.Japan) based on some build configuration. Or If it is not available through VSTS, how I can achieve the same using Visual Studio.

Can someone please guide me to solve this issue. I have found few solutions based on traditional .Net project, But I haven't find something similar for Xamarin.

StezPet
  • 2,430
  • 2
  • 27
  • 49

1 Answers1

1

The project reference information is stored in project file, so it’s better to configure it in project file per to different configuration (Right click project in VS >Unload project >Right click project >Edit xxx.proj), for example:

<ItemGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <ProjectReference Include="..\ClassLibrary2\ClassLibrary2.csproj">
      <Project>{08adf376-babd-4d9c-8d7b-9d40cf04745d}</Project>
      <Name>ClassLibrary2</Name>
    </ProjectReference>
  </ItemGroup>

You can create multiple configurations by right clicking the solution > Configuration Manager > Click dropdownlist control of configuration > New > Specify name and check Create a project configuration.

After that, you can specify different configuration in VSTS Build (e.g. Configuration and Platform in Visual Studio Build task)

starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53
  • I have created project configuration using Visual Studio; Now How & where I need to right script / configuration for adding the project to my build. ? I mean ClassLibrary2 to my main project (based on your example) – StezPet Apr 12 '18 at 11:20
  • 1
    @StezPet You just need to update main project file (csproj). Steps: 1. Add project references to your main project (Then the related ItemGroup will be generated) 2. Open main project file (csproj) through NotePad or Right click project in VS >Unload project >Right click project >Edit xxx.proj 3. Add condition property to related ItemGroup e.g. `Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU' "`. For my example, I added ClassLibrary2 project to main project, so I just need to add condition property to related ItemGroup. – starian chen-MSFT Apr 13 '18 at 01:21
  • Thanks Starian :) – StezPet Apr 13 '18 at 14:34