1
votes

I have complex Xamarin solution with android, ios and nestandard core project (defined via Microsoft.NET.Sdk) and few other csprojs with some logic (some are defined via Microsoft.NET.Sdk as netstandard2.0. others defined via MSBuild.Sdk.Extras for multitargeting the netstandard2.0, xamarin.ios10, monoandroid10.0 and have some platform specific code) Local build on my macos with latest libraries is ok (both netcore 3 and 5, latest xamarin. tried on Rider and VS for mac). ADO build succeed on windows-2019 agent using msbuild (just regular CI with codechecks etc) ADO build on macos-10.15 agent (different jobs for ios and android packaging, using XamarinIos/XamarinAndroid tasks) fails with kind of strange behaviour: i see a lot of namespace errors in droid/ios projects for platform-specific libraries from my solution.

i've made some investigations and found out that msbuild runs platform specific builds of csprojs first, copies the outputs, then runs the netstandard build for the same csprojs and replace files in output with netstandard versions. which, obviously, didn't have any line of platform specific code.

so, the question is wtf? how am i suppose to fix this?

what i tried:

  • replace Xamarin tasks with msbuild calls
  • change Xamarin SDK version to 16_12_3 and 16_12_0 (current is 16_12_2)
  • change .net version to 5 (current is 3.1.x) both ways - via global.json and installing v5 using the UseDotNet@2 task
  • core project was converted to multitarget
  • remove everything from sln and add every project from the scratch

also i thought that msbuild, maybe, trying to make a nupkg from my libraries so i tried this in build props:

<PropertyGroup>
    <IsPackable>false</IsPackable>
    <GeneratePackageOnBuild>false</GeneratePackageOnBuild>
    <GenerateAssemblyInfo>true</GenerateAssemblyInfo>
</PropertyGroup>

also i have this

<PropertyGroup Label="Multiplatform" Condition=" '$(TargetsToBuild)' != 'All' ">
    <TargetFrameworks Condition=" '$(TargetsToBuild)' == 'Android' ">monoandroid10.0</TargetFrameworks>
    <TargetFrameworks Condition=" '$(TargetsToBuild)' == 'iOS' ">xamarin.ios10</TargetFrameworks>
</PropertyGroup>

and multitarget projects has this

<PropertyGroup Label="Multiplatform">
    <TargetFrameworks>netstandard2.0;xamarin.ios10;monoandroid10.0</TargetFrameworks>
</PropertyGroup>

of course i've tried to remove the tags above and build without them. no luck :(

1

1 Answers

0
votes

So the answer is: you should add csproj references to other projects in right order :/ order is matters for msbild