0
votes

I'm building a Xamarin Forms app on vsts (via yml). Steps are almost identicals for iOS and Android. The whole solution builds fine on my machine and the iOS phase builds fine on VSTS.

However I get an error on the msbuild of the solution within the Android phase. The error is:

[error]C:\Program Files\dotnet\sdk\2.1.104\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(327,5): Error : Assets file 'D:\a\1\s\MyApp.Controls\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.

I understand that I first have to run dot net restore to generate the project.assets.json file and I do. Here are my corresponding yml tasks:

- task: NuGetToolInstaller@0
  displayName: 'Dot Net Restore'
  condition: succeeded()
  inputs:
      command: restore
      projects: |
       MyApp.*/*.csproj
       Platforms/MyApp.Android/*.csproj
       Platforms/MyApp.Controls.Android/*.csproj
- task: XamarinAndroid@1
  displayName: 'Building Android'
  inputs:
      solutionFile: '**/*.sln'
      configuration: 'Release'
      buildToolOption: msbuild

Note that MyApp.Controls.Android has a reference to MyApp.Controls (which is a .Net Standard library) and this is that project on which the error occurs.

1

1 Answers

0
votes

The NuGet restore task definied in your yml file is not correct, you should use the task NuGetCommand@2 for NuGet restore.

Below is an example for the YAML build file:

steps:
- task: NuGetToolInstaller@0
  inputs:
    versionSpec: 4.4.1
- task: NuGetCommand@2
  inputs:
    restoreSolution: '**/*.sln'
- task: VSBuild@1
  displayName: 'Building Android'
  inputs:
    solution: '**/*.sln'
    vsVersion: 15.0
    configuration: '$(BuildConfiguration)'
    logProjectEvents: false