question

David-7465 avatar image
0 Votes"
David-7465 asked David-7465 commented

Deploying Xamarin apps with different end points.

Hi

Can someone guide me on this?

I have got a Xamarin form with iOS and Android and I would like to know what is the best way for me to set it up so I can set up different endpoints for use with API calls depending on if it is release or debug when archiving for publishing.

I have got the code in Azure. For instance, I can use environment variables on app settings on Azure and get it pointing to any endpoint. What is the best approach for a xamarin app?

Thanks

dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JarvanZhang-MSFT avatar image
0 Votes"
JarvanZhang-MSFT answered David-7465 commented

Hello,​

Welcome to our Microsoft Q&A platform!

so I can set up different endpoints for use with API calls depending on if it is release or debug when archiving for publishing.

Do you mean execute different code in debug and release mode? If so, try using the conditional compilation of C# preprocessor directives.

private void Button_Clicked(object sender, EventArgs e)
{
    #if DEBUG
            //perform the work
    #else
            //perform the work
    #endif
}

Best Regards,

Jarvan Zhang


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @JarvanZhang-MSFT
Thanks for this.
What I meant is I have got a DEV/TESTING environment with one endpoint to a API server for developing and testing and another one for RELEASE with another endpoint to a different API server that gets published to the stores, and I wonder if there is a way to use the relevant endpoint when archiving for publishing the Xamarin app.

0 Votes 0 ·

What I meant is I have got a DEV/TESTING environment with one endpoint to a API server for developing and ...

Do you want to add breakpoints to debug the project in release mode? It's not possible. In release mode, the project has been generate an apk and VS cannot respond to the code any more.

I wonder if there is a way to use the relevant endpoint when archiving for publishing the Xamarin app

We cannot execute some code when archiving the app.

1 Vote 1 ·

I host the Xamarin project in Azure and I wanted to use pipelines to build the release. There will be one pipeline that will build the project for "testing" and one pipeline for "release" and both have different urls. It may not be possible.
Thanks

0 Votes 0 ·
Show more comments