首页 > 解决方案 > 天蓝色管道中的“AndroidManifest 文件不存在”错误

问题描述

我正在尝试使用 azure devops 为我的 xamarin android 应用程序设置自动构建。我使用了默认的 Xamarin.Android 构建模板

# Xamarin.Android
# Build a Xamarin.Android project.
# Add steps that test, sign, and distribute an app, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/xamarin

trigger:
- master

pool:
  vmImage: 'windows-latest'
  demands:
  - MSBuild
  - Xamarin.Android
  - JDK

variables:
  buildConfiguration: 'Release'
  outputDirectory: '$(build.binariesDirectory)/$(buildConfiguration)'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '**/*.sln'

- task: XamarinAndroid@1
  inputs:
    projectFile: '**/*droid*.csproj'
    outputDirectory: '$(outputDirectory)'
    configuration: '$(buildConfiguration)'

这给了我一个构建错误

2020-03-26T09:12:32.2752297Z Generating MSBuild file d:\a\1\s\XamarinFormsTry\XamarinFormsTry.Android\obj\XamarinFormsTry.Android.csproj.nuget.g.props.
2020-03-26T09:12:32.2752837Z Generating MSBuild file d:\a\1\s\XamarinFormsTry\XamarinFormsTry.Android\obj\XamarinFormsTry.Android.csproj.nuget.g.targets.
2020-03-26T09:12:32.2753312Z Writing assets file to disk. Path: d:\a\1\s\XamarinFormsTryStandard\obj\project.assets.json
2020-03-26T09:12:32.2753766Z Writing assets file to disk. Path: d:\a\1\s\XamarinFormsTry\XamarinFormsTry.Android\obj\project.assets.json
2020-03-26T09:12:32.2754231Z Writing cache file to disk. Path: d:\a\1\s\XamarinFormsTryStandard\obj\project.nuget.cache
2020-03-26T09:12:32.2754658Z Restore completed in 47.34 sec for d:\a\1\s\XamarinFormsTryStandard\XamarinFormsTry.csproj.
2020-03-26T09:12:32.2755110Z Writing cache file to disk. Path: d:\a\1\s\XamarinFormsTry\XamarinFormsTry.Android\obj\project.nuget.cache
2020-03-26T09:12:32.2755614Z Restore completed in 47.57 sec for d:\a\1\s\XamarinFormsTry\XamarinFormsTry.Android\XamarinFormsTry.Android.csproj.
2020-03-26T09:12:32.2755964Z 
2020-03-26T09:12:32.2756107Z NuGet Config files used:
2020-03-26T09:12:32.2756322Z     d:\a\1\Nuget\tempNuGet_19.config
2020-03-26T09:12:32.2756470Z 
2020-03-26T09:12:32.2756630Z Feeds used:
2020-03-26T09:12:32.2756825Z     https://api.nuget.org/v3/index.json
2020-03-26T09:12:32.2756980Z 
2020-03-26T09:12:32.2757113Z Installed:
2020-03-26T09:12:32.2757302Z     1 package(s) to packages.config projects
2020-03-26T09:12:32.2757610Z     13 package(s) to d:\a\1\s\XamarinFormsTryStandard\XamarinFormsTry.csproj
2020-03-26T09:12:32.2758035Z     169 package(s) to d:\a\1\s\XamarinFormsTry\XamarinFormsTry.Android\XamarinFormsTry.Android.csproj
2020-03-26T09:12:32.2773237Z ##[section]Finishing: NuGetCommand
2020-03-26T09:12:32.2807591Z ##[section]Starting: XamarinAndroid
2020-03-26T09:12:32.2947509Z ==============================================================================
2020-03-26T09:12:32.2947864Z Task         : Xamarin.Android
2020-03-26T09:12:32.2948151Z Description  : Build an Android app with Xamarin
2020-03-26T09:12:32.2948500Z Version      : 1.166.0
2020-03-26T09:12:32.2948736Z Author       : Microsoft Corporation
2020-03-26T09:12:32.2949074Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/xamarin-android
2020-03-26T09:12:32.2949464Z ==============================================================================
2020-03-26T09:12:34.4220559Z ##[command]"D:\a\_tasks\XamarinAndroid_27edd013-36fd-43aa-96a3-7d73e1e35285\1.166.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [15.0,16.0) -latest -format json
2020-03-26T09:12:34.4661105Z ##[command]"D:\a\_tasks\XamarinAndroid_27edd013-36fd-43aa-96a3-7d73e1e35285\1.166.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [15.0,16.0) -products Microsoft.VisualStudio.Product.BuildTools -latest -format json
2020-03-26T09:12:34.5348014Z ##[command]"D:\a\_tasks\XamarinAndroid_27edd013-36fd-43aa-96a3-7d73e1e35285\1.166.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [16.0,17.0) -latest -format json
2020-03-26T09:12:34.7801263Z ##[warning]Unable to find MSBuild version '15.0' for architecture 'x86'. Falling back to version '16.0'.
2020-03-26T09:12:34.8662182Z ##[command]"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" "d:\a\1\s\MigrationBackup\b36c964d\XamarinFormsTry.Android\XamarinFormsTry.Android.csproj" /nologo /nr:false /dl:CentralLogger,"D:\a\_tasks\XamarinAndroid_27edd013-36fd-43aa-96a3-7d73e1e35285\1.166.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=b1e39c46-8802-47e2-b5ab-4bec5fda9203|SolutionDir=d:\a\1\s\MigrationBackup\b36c964d\XamarinFormsTry.Android"*ForwardingLogger,"D:\a\_tasks\XamarinAndroid_27edd013-36fd-43aa-96a3-7d73e1e35285\1.166.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"  /p:configuration="Release" /p:_MSDeployUserAgent="VSTS_efe7950b-580b-467b-8a98-19b6043eee2e_build_1_0" /t:PackageForAndroid /p:OutputPath="d:\a\1\b/Release"
2020-03-26T09:12:34.9957257Z Build started 3/26/2020 9:12:34 AM.
2020-03-26T09:12:35.2054286Z Project "d:\a\1\s\MigrationBackup\b36c964d\XamarinFormsTry.Android\XamarinFormsTry.Android.csproj" on node 1 (PackageForAndroid target(s)).
2020-03-26T09:12:35.2062946Z _CleanIntermediateIfNuGetsChange:
2020-03-26T09:12:35.2066241Z   Creating directory "obj\Release\90\stamp\".
2020-03-26T09:12:35.2070062Z   Creating "obj\Release\90\stamp\_CleanIntermediateIfNuGetsChange.stamp" because "AlwaysCreate" was specified.
2020-03-26T09:12:35.8847743Z _ResolveSdks:
2020-03-26T09:12:35.8850229Z   Found Java SDK version 1.8.0.
2020-03-26T09:12:36.3595388Z   Found Java SDK version 1.8.0.
2020-03-26T09:12:36.8133556Z ##[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(752,2): Error : AndroidManifest file does not exist
2020-03-26T09:12:36.8136850Z C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(752,2): error : AndroidManifest file does not exist [d:\a\1\s\MigrationBackup\b36c964d\XamarinFormsTry.Android\XamarinFormsTry.Android.csproj]
2020-03-26T09:12:36.8167951Z Done Building Project "d:\a\1\s\MigrationBackup\b36c964d\XamarinFormsTry.Android\XamarinFormsTry.Android.csproj" (PackageForAndroid target(s)) -- FAILED.
2020-03-26T09:12:36.8205677Z 
2020-03-26T09:12:36.8208249Z Build FAILED.
2020-03-26T09:12:36.8258005Z 
2020-03-26T09:12:36.8270145Z "d:\a\1\s\MigrationBackup\b36c964d\XamarinFormsTry.Android\XamarinFormsTry.Android.csproj" (PackageForAndroid target) (1) ->
2020-03-26T09:12:36.8274063Z (_ValidateAndroidPackageProperties target) -> 
2020-03-26T09:12:36.8277799Z   C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(752,2): error : AndroidManifest file does not exist [d:\a\1\s\MigrationBackup\b36c964d\XamarinFormsTry.Android\XamarinFormsTry.Android.csproj]
2020-03-26T09:12:36.8279308Z 
2020-03-26T09:12:36.8281145Z     0 Warning(s)
2020-03-26T09:12:36.8284488Z     1 Error(s)
2020-03-26T09:12:36.8286684Z 
2020-03-26T09:12:36.8290589Z Time Elapsed 00:00:01.83
2020-03-26T09:12:36.9547149Z ##[error]Process 'msbuild.exe' exited with code '1'.
2020-03-26T09:12:37.1765717Z ##[section]Finishing: XamarinAndroid
2020-03-26T09:12:44.6607030Z ##[section]Starting: Checkout XamarinFormsTry@master to s
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(752,2): Error : AndroidManifest file does not exist 
Process 'msbuild.exe' exited with code '1'. 

我知道我的项目构建得很好,因为我可以使用 Visual Studio for mac 和 Visual Studio 2019 在我的 Mac 和 pc 上构建它,我还使用https://appcenter.ms (Microsoft AppCenter) 进行分析,这也提供了一个建立在提交选项上。即使使用类似的构建代理过程也可以很好地构建。

我尝试制作 AndroidManifest.xml 的副本并将其放在根目录中,但这也不起作用。

这是 Xamarin.Android 项目的 .proj 文件中的配置块

  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>8.0.30703</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{C6CD5F2A-47C8-4A53-9729-91C88CEEB870}</ProjectGuid>
    <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>XamarinFormsTry.Droid</RootNamespace>
    <AssemblyName>XamarinFormsTry.Android</AssemblyName>
    <FileAlignment>512</FileAlignment>
    <AndroidApplication>true</AndroidApplication>
    <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
    <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
    <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
    <TargetFrameworkVersion>v10.0</TargetFrameworkVersion>
    <AndroidStoreUncompressedFileExtensions />
    <MandroidI18n />
    <JavaMaximumHeapSize />
    <JavaOptions />
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
    <AndroidKeyStore>false</AndroidKeyStore>
    <AndroidSigningKeyStore>*******</AndroidSigningKeyStore>
    <AndroidSigningStorePass />
    <AndroidLinkMode>None</AndroidLinkMode>
    <AndroidEnableMultiDex>true</AndroidEnableMultiDex>
  </PropertyGroup>

存储库中相对路径的 AndroidManifest.xml 文件

这对我来说可能很愚蠢,但我无法在谷歌上找到帮助或自己弄清楚。

标签: visual-studioxamarin.androidazure-devopsmsbuildazure-pipelines

解决方案


因此,对于任何拥有 xamarin.forms .net 标准方式的项目并且遇到类似错误的人来说,这就是为我解决的问题。

原始管道

# Xamarin.Android
# Build a Xamarin.Android project.
# Add steps that test, sign, and distribute an app, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/xamarin

trigger:
- master

pool:
  vmImage: 'windows-latest'
  demands:
  - MSBuild
  - Xamarin.Android
  - JDK

variables:
  buildConfiguration: 'Release'
  outputDirectory: '$(build.binariesDirectory)/$(buildConfiguration)'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '**/*.sln'

- task: XamarinAndroid@1
  inputs:
    projectFile: '**/*droid*.csproj'
    outputDirectory: '$(outputDirectory)'
    configuration: '$(buildConfiguration)'

固定管道(是的,错误在管道中)

# Xamarin.Android
# Build a Xamarin.Android project.
# Add steps that test, sign, and distribute an app, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/xamarin

trigger:
- master

pool:
  vmImage: 'windows-latest'
  demands:
  - MSBuild
  - Xamarin.Android
  - JDK

variables:
  buildConfiguration: 'Release'
  outputDirectory: '$(build.binariesDirectory)/$(buildConfiguration)'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '**/*.sln'

- task: XamarinAndroid@1
  inputs:
    projectFile: 'XamarinFormsTry/XamarinFormsTry.Android/XamarinFormsTry.Android.csproj'
    outputDirectory: '$(outputDirectory)'
    configuration: '$(buildConfiguration)'

所以不是它没有找到 AndroidManifest 文件,而是它没有找到正确的 proj 文件。改变projectFile: '**/*droid*.csproj'工作projectFile: 'XamarinFormsTry/XamarinFormsTry.Android/XamarinFormsTry.Android.csproj' 。找到了正确的 proj 文件,并且 proj 构建成功。在这种情况下,我猜错误和日志有点误导


推荐阅读