How to Set AutoGenerateBindingRedirects in Visual Studio for Mac?
Finally fixed this warning, and the solution was rather counterintuitive.
Despite the warning saying specifically "Please set the "AutoGenerateBindingRedirects" property to true in the
project file", the warning will only go away if you change <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
to <AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
.
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
My experience was that we need <AutoGenerateBindingRedirects>
to be true
.
My Dev Environment:
- macOS Mojave 10.14.2 (18C54)
- VisualStudio for Mac Professional Version 7.7.4 (Build 1)
#Solution:
What I did is followed the instructions as given in following MS Doc(link).
- Unload the
MyBeautifulApp.Xamarin.iOS.csproj
from the Visual Studio Xamarin Forms solution. - Edit the
MyBeautifulApp.Xamarin.iOS.csproj
file manually using TextEdit and add the following line<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
to the PropertyGroup which is related to your Build Config which you were trying to build and was giving the error. - Save the
.csproj
file. Then close the file and reload the Project in your VS Solution Explorer. - Then clean and try to build, and it should successfully build without giving any warnings or errors. -----> For me this worked.
Note: I edited the .csproj
file of my Xamarin.Forms iOS App project only. Because Android project which was within the Xamarin.Forms solution were already built successfully.
After editing my MyBeautifulApp.Xamarin.iOS.csproj
file manually it looked like following:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{asdf-7AC6-asdf-9890-asdf}</ProjectGuid>
<ProjectTypeGuids>{asdfasd-340asdf5-455asdfC-asdf-asdf};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TemplateGuid>{6143fdea-f3c2-4a09-aafa-6e230626515e}</TemplateGuid>
<OutputType>Exe</OutputType>
<RootNamespace>MyBeautifulApp.Xamarin.iOS</RootNamespace>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
<AssemblyName>MyBeautifulApp.Xamarin.iOS</AssemblyName>
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
**<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>**
</PropertyGroup>
<PropertyGroup>
....For another build configuration related property group...
Further More: The question now I have is should I do this change for all the other PropertyGroups of that .iOS.csproj file which are related to other Build configurations? I would be glad to know from someone out there. But for now I have decided not to touch those until it gives me a warning/error in the future.
Hope this will be helpful to anybody out there.