0

I am trying to setup a Azure Pipeline to build my Xamarin solution. The solution contains an Azure function project so I was trying to build by using project instead of solution. The Android project builds perfectly fine but the iOS project fails with error. 'The OutputPath property is not set for project 'MyProject.iOS.csproj'" There is a solution file but I build my android project from the project file without errors and wanted to do the iOS project the same way.

YAML for iOS build task:

- task: XamariniOS@2
inputs:
  solutionFile: '**/*iOS.csproj'
  configuration: '$(buildConfiguration)'
  buildForSimulator: true
  packageApp: false

Error from Azure build using system.debug=true.

Build started 6/10/2021 1:56:58 PM.

Project "/Users/runner/work/1/s/MyProject/MyProject.iOS/MyProject.iOS.csproj" on node 1 (default targets). /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(793,5): error : The OutputPath property is not set for project 'MyProject.iOS.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='$(buildConfiguration)' Platform='iPhoneSimulator'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project. [/Users/runner/work/1/s/MyProject/MyProject.iOS/MyProject.iOS.csproj] Done Building Project "/Users/runner/work/1/s/MyProject/MyProject.iOS/MyProject.iOS.csproj" (default targets) -- FAILED.

Build FAILED.

Can someone help with why I am getting this error with iOS?

Update: Do I need to add a second solution file that only has everything that iOS needs so that Azure pipeline will work?

Orgbrat

Chris F Carroll
  • 11,146
  • 3
  • 53
  • 61
Orgbrat
  • 331
  • 6
  • 20
  • I've added msbuild and xamarin tags , it might be good to add the mono tag too - they 3 may get you more help than the azure tags do – Chris F Carroll Jun 10 '21 at 20:17

1 Answers1

0

It looks like the combination of Configuration,Platform that your yml lines:

configuration: '$(buildConfiguration)'
buildForSimulator: true

generate might be one for which your csproj file has no matching PropertyGroup section. For instance if buildConfiguration is Release then setting buildForSimulator to false not true might get you a successful build.

So:

Open up your csproj file in a text editor and look for the PropertyGroup sections for different Configuration|Platform combinations:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
  <DebugSymbols>true</DebugSymbols>
  <DebugType>full</DebugType>
  <Optimize>false</Optimize>
  <OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
  <DefineConstants>DEBUG;ENABLE_TEST_CLOUD;</DefineConstants>
  <ErrorReport>prompt</ErrorReport>
  <WarningLevel>4</WarningLevel>
  <CodesignKey>iPhone Developer</CodesignKey>
  <MtouchDebug>true</MtouchDebug>
  <MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
  <MtouchFastDev>true</MtouchFastDev>
  <IOSDebuggerPort>63613</IOSDebuggerPort>
  <MtouchLink>None</MtouchLink>
  <MtouchArch>x86_64</MtouchArch>
  <MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
   … etc …
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
   … etc …
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
   … etc …

You can see the the OutputPath property is set inside each of these PropertyGroups and that each PropertyGroup has a Condition attached. You have to match one of the conditions to get the build to work.

So, either change your yml to match the csproj file; or copy-paste a PropertyGroup to create a new section for the combination of '$(Configuration)|$(Platform)' that your yml is generating.

(NB if you open the .sln file in a text editor, you will also see that it lists matching combinations. Building the solution file might also be a simple fix.)

Chris F Carroll
  • 11,146
  • 3
  • 53
  • 61
  • The iOS project has a section for 'Release|iPhoneSimulator' and has a item for OutputPath. none true bin\iPhoneSimulator\Release prompt 4 None x86_64 false ---- – Orgbrat Jun 10 '21 at 18:53
  • Then I think that gets you into the world of `msbuild` debugging. Does the pipeline raw output log the values of `$(Configuration)` and `$(Platform)` that it's using? If not my next 2 steps would be (1) run `msbuild` commandline on local machine and (2) start adding `` tasks https://learn.microsoft.com/en-us/visualstudio/msbuild/message-task?view=vs-2019 to the csproj file to print the variable values or it might be that `msbuild -v:d` shows all the variable values. Either way you can try adding `args: -v:d` to the pipeline task to see if that shows you the variable values? – Chris F Carroll Jun 10 '21 at 20:13
  • NB: The XamariniOS@2 docs page says “Standard configurations are Ad-Hoc, AppStore, Debug, Release” so the output might show you that Configuration=Ad-Hoc or somesuch? – Chris F Carroll Jun 10 '21 at 20:24