Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';t在Azure管道中构建Xamarin Android项目_Xamarin_Xamarin.forms_Xamarin.android_Nuget_Azure Pipelines - Fatal编程技术网

Can';t在Azure管道中构建Xamarin Android项目

Can';t在Azure管道中构建Xamarin Android项目,xamarin,xamarin.forms,xamarin.android,nuget,azure-pipelines,Xamarin,Xamarin.forms,Xamarin.android,Nuget,Azure Pipelines,我正在尝试在Azure DevOps中创建一个基本的构建管道,它构建了一个Visual Studio解决方案,其中包括.NET Core/.NET标准项目和一个Xamarin.Android项目。解决方案在VS 2019本地生成,没有问题,但在生成代理上总是失败,并出现以下生成错误: Error APT2260: resource style/Theme.AppCompat.Light.Dialog (aka com.companyname.obrien.connect.forms:style/

我正在尝试在Azure DevOps中创建一个基本的构建管道,它构建了一个Visual Studio解决方案,其中包括.NET Core/.NET标准项目和一个Xamarin.Android项目。解决方案在VS 2019本地生成,没有问题,但在生成代理上总是失败,并出现以下生成错误:

Error APT2260: resource style/Theme.AppCompat.Light.Dialog (aka com.companyname.obrien.connect.forms:style/Theme.AppCompat.Light.Dialog) not found.

Source\Obrien.Connect.Forms.Android\Resources\values\styles.xml(4,0): Error APT2260: style attribute 'attr/colorAccent (aka com.companyname.obrien.connect.forms:attr/colorAccent)' not found.

Error APT2260: resource style/Theme.AppCompat.Light.DarkActionBar (aka com.companyname.obrien.connect.forms:style/Theme.AppCompat.Light.DarkActionBar) not found.

Source\Obrien.Connect.Forms.Android\Resources\values\styles.xml(2,0): Error APT2260: style attribute 'attr/windowNoTitle (aka com.companyname.obrien.connect.forms:attr/windowNoTitle)' not found.

Source\Obrien.Connect.Forms.Android\Resources\values\styles.xml(2,0): Error APT2260: style attribute 'attr/windowActionBar (aka com.companyname.obrien.connect.forms:attr/windowActionBar)' not found.

Source\Obrien.Connect.Forms.Android\Resources\values\styles.xml(2,0): Error APT2260: style attribute 'attr/colorPrimary (aka com.companyname.obrien.connect.forms:attr/colorPrimary)' not found.

Source\Obrien.Connect.Forms.Android\Resources\values\styles.xml(2,0): Error APT2260: style attribute 'attr/colorPrimaryDark (aka com.companyname.obrien.connect.forms:attr/colorPrimaryDark)' not found.

Source\Obrien.Connect.Forms.Android\Resources\values\styles.xml(3,0): Error APT2260: style attribute 'attr/colorAccent (aka com.companyname.obrien.connect.forms:attr/colorAccent)' not found.

Source\Obrien.Connect.Forms.Android\Resources\values\styles.xml(4,0): Error APT2260: style attribute 'attr/windowActionModeOverlay (aka com.companyname.obrien.connect.forms:attr/windowActionModeOverlay)' not found.

C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Aapt2.targets(155,3): Error APT2260: resource style/TextAppearance.AppCompat.Button (aka com.companyname.obrien.connect.forms:style/TextAppearance.AppCompat.Button) not foun
这是管道的YAML:

trigger:
- develop
- feature/*

pool:
  vmImage: 'windows-2019'

variables:
- group: 'ci-build'

steps:
- task: NuGetToolInstaller@1
  displayName: 'Install NuGet 5.4.0' 
  inputs:
    versionSpec: '5.4.0'

- task: DotNetCoreCLI@2
  displayName: 'Restore .NET Packages'
  inputs:
    command: restore
    projects: '**/OBrien.Connect.Forms*/*.csproj'
    verbosityRestore: minimal

- task: NuGetCommand@2
  displayName: 'Restore Android Packages'
  inputs:
    command: 'restore'
    restoreSolution: '**/OBrien.Connect.Forms.sln'

- task: VSBuild@1
  displayName: 'Build Solution'
  inputs:    
    solution: '**/$(solutionName)' 
    vsVersion: '16.0'
    configuration: '$(buildConfiguration)'
我需要首先在解决方案中的项目上使用
dotnet restore
,这样我就可以在后续的VSBuild任务中构建它们,这很好。但是,这不会还原Xamarin.Android项目所需的任何包,因为它基于Mono,在第一次还原时会被忽略

这就是为什么我在整个解决方案上添加了第二个NuGet restore,但这从来没有做过任何事情-没有错误,只有以下输出:

##[section]Starting: Restore Android Packages
==============================================================================
Task         : NuGet
Description  : Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and authenticated feeds like Azure Artifacts and MyGet. Uses NuGet.exe and works with .NET Framework apps. For .NET Core and .NET Standard apps, use the .NET Core task.
Version      : 2.161.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/nuget
==============================================================================
SYSTEMVSSCONNECTION exists true
SYSTEMVSSCONNECTION exists true
[command]C:\windows\system32\chcp.com 65001
Active code page: 65001
Detected NuGet version 5.4.0.6315 / 5.4.0+d790b66be476cd901a56bd46ada037162097ee21.d790b66be476cd901a56bd46ada037162097ee21
SYSTEMVSSCONNECTION exists true
Saving NuGet.config to a temporary config file.
[command]C:\hostedtoolcache\windows\NuGet\5.4.0\x64\nuget.exe sources Add -NonInteractive -Name NuGetOrg -Source https://api.nuget.org/v3/index.json -ConfigFile D:\a\1\Nuget\tempNuGet_552.config
Package source with Name: NuGetOrg added successfully.
##[section]Finishing: Restore Android Packages

我试过使用XamarinAndroid@1生成任务而不是生成整个解决方案,但它有完全相同的生成错误。

我从一位同事那里找到了一个很好的解决方案,他有完全相同的问题,就是从VSBuild任务触发还原目标,而不是执行NuGet Restore/dotnet还原,下面是YAML:

- task: VSBuild@1
  displayName: 'Restore Packages'
  inputs:
    solution: '**/$(solutionName)'
    configuration: '$(buildConfiguration)'
    vsVersion: '16.0'
    msbuildArgs: '/t:Restore'

这非常适用于构建整个解决方案。

删除项目中的文件夹
bin
obj
,然后清理并重建它。尝试将其添加到macos vm时,它表示该任务无法在此操作系统上运行。理想的情况是在需要macos的同一个构建vm上一个接一个地构建android和ios:(不过它在windows vm上也能工作。我想我必须为ios构建创建一个使用macos映像的新作业。这救了我一命!我不知道它怎么会被破坏这么久。我想这是在7月份更新Xamarin.Forms包后发生的。