gpt4 book ai didi

visual-studio - 缓慢的应用程序构建 - Xamarin for Visual Studio

转载 作者:行者123 更新时间:2023-12-03 11:59:26 27 4
gpt4 key购买 nike

这些天,我的 Xamarin.Android 应用程序的构建/部署速度非常缓慢。我不记得以前这么慢。

我已启用:

  • 使用共享运行时
  • 快速部署

  • 启用或禁用这些设置没有任何区别。在这两种情况下,构建/部署我的应用程序大约需要 2 分 20 秒(最多超过 3 分钟!)。
    使用真实设备或适用于 Android 的 Visual Studio 模拟器也没有什么不同。

    为什么这会如此缓慢?我没有使用正确的设置吗?

    更新 2

    昨天(11 月 14 日)我将 Xamarin.VS 更新为 4.2.1.58。构建持续时间没有改进。

    我们正在使用 TeamCity 构建我们应用程序的发布版本,TeamCity 统计数据完美地显示了我在说什么。

    在下图中,我选择了上一季度作为日期范围。查看构建持续时间的主要增加。现在,我不介意为发布版本等待 3 分钟,但在调试时这是 Not Acceptable 。

    Nov. 7, before installing latest Xamarin update
    Nov. 8, after installing update and targetting Android 7

    更新 3

    乔恩,谢谢你的帮助。

    与此同时,我自己在构建日志中进行了一些研究,并发现了每个构建任务的持续时间。我发现不知何故 GetAdditionalResourcesFromAssemblies需要很多时间。

    我在应用程序中拥有的资源量没有发生太大变化,所以这让我开始思考:它会不会是我正在使用的另一个程序集..

    然后,我检查了修订版 1029(这是最后一个大约需要一分钟构建的修订版),并尝试在更新的环境中对其进行调试。它仍然在 1 分 30 秒内建成......

    所以:
  • 这可能不是 VS Xamarin 更新(否则修订版 1029 也会构建缓慢)
  • 可能不是快速部署,构建过程中持续时间增加

  • 那么我的应用程序的修订版 1029 和 1030 之间发生了什么变化?
  • 将 Visual Studio 的 Xamarin 更新至 4.2.0.719
  • 在 Android SDK Manager
  • 中安装了 Android 7.0 SDK 平台
  • 已更改 Compile using Android version到项目属性中的 Android 7.0
  • 将 Xamarin.Android 支持库从 23.4.0.1 更新到 24.2.1

  • 更改 4 这就是我首先更新的原因,我想使用 Bottomsheet ,在第 24 版中得到了改进。但是支持库 nugets 针对的是 Android 7.0,所以我必须执行 1-3 才能更新支持库。

    导致这一切的支持库绑定(bind)是否发生了变化?我在互联网上查看了其他有此问题的开发人员,发现 this在 Xamarin 论坛中。设置 AndroidExplicitCrunch建房到 true似乎在那里修复它,但是当我尝试这样做时,我得到了另一个构建错误。

    无论如何,这就是我在此期间尝试过的。现在,根据要求,这是我的诊断构建日志:
    1>Project Performance Summary:
    1> 3 ms C:\Development\Apps\FieldService-trunk\OverAllField.XamarinAndroid\OverAll.App.Shared\OverAll.App.Shared.csproj 3 calls
    1> 1 ms GetTargetPath 1 calls
    1> 0 ms GetNativeManifest 1 calls
    1> 2 ms GetCopyToOutputDirectoryItems 1 calls
    1> 4 ms C:\Development\Apps\FieldService-trunk\OverAllField.XamarinAndroid\OverAllField.XamarinAndroid.DataLayer\OverAllField.XamarinAndroid.DataLayer.csproj 3 calls
    1> 1 ms GetTargetPath 1 calls
    1> 0 ms GetNativeManifest 1 calls
    1> 3 ms GetCopyToOutputDirectoryItems 1 calls
    1> 40103 ms C:\Development\Apps\FieldService-trunk\OverAllField.XamarinAndroid\OverAllField.XamarinAndroid.ServiceClient\OverAllField.XamarinAndroid.ServiceClient.csproj 1 calls
    1>
    1>Target Performance Summary:
    1> 0 ms Compile 1 calls
    1> 0 ms ResolveReferences 1 calls
    1> 0 ms BclBuildGetTargetPath 1 calls
    1> 0 ms EnsureNuGetPackageBuildImports 1 calls
    1> 0 ms AfterResGen 1 calls
    1> 0 ms ResolveCodeAnalysisRuleSet 1 calls
    1> 0 ms _CreatePropertiesCache 1 calls
    1> 0 ms _SetTargetFrameworkMonikerAttribute 1 calls
    1> 0 ms BeforeResGen 1 calls
    1> 0 ms ModifyUnitTestPlatformVersion 1 calls
    1> 0 ms CreateCustomManifestResourceNames 1 calls
    1> 0 ms BclBuildAddProjectReferenceProperties 1 calls
    1> 0 ms _ResolveMonoAndroidFramework 1 calls
    1> 0 ms UpdateAndroidResources 1 calls
    1> 0 ms CoreBuild 1 calls
    1> 0 ms ExpressionBuildExtension 1 calls
    1> 0 ms _CheckTargetFramework 1 calls
    1> 0 ms _CopyAppConfigFile 1 calls
    1> 0 ms Build 1 calls
    1> 0 ms DeleteBuildInfoFile 1 calls
    1> 0 ms CleanXsdCodeGen 1 calls
    1> 0 ms _SetupInstantRun 1 calls
    1> 0 ms GetFrameworkPaths 1 calls
    1> 0 ms DeleteBuildInfoResource 1 calls
    1> 0 ms _AddAndroidDefines 1 calls
    1> 0 ms BuildOnlySettings 1 calls
    1> 0 ms ComputeIntermediateSatelliteAssemblies 1 calls
    1> 0 ms ValidationExtension 1 calls
    1> 0 ms AfterCompile 1 calls
    1> 0 ms _CheckInstantRunCondition 1 calls
    1> 0 ms _GenerateSatelliteAssemblyInputs 1 calls
    1> 0 ms _SetupApplicationJavaClass 1 calls
    1> 0 ms _SetupDesignTimeBuildForIntellisense 1 calls
    1> 0 ms SetWin32ManifestProperties 1 calls
    1> 0 ms CreateSatelliteAssemblies 1 calls
    1> 0 ms _CopySourceItemsToOutputDirectory 1 calls
    1> 0 ms GetInstalledSDKLocations 1 calls
    1> 0 ms _AddAndroidEnvironmentToCompile 1 calls
    1> 0 ms _CheckForContent 1 calls
    1> 0 ms _SeparateAppExtensionReferences 1 calls
    1> 0 ms AfterResolveReferences 1 calls
    1> 0 ms BeforeResolveReferences 1 calls
    1> 0 ms PrepareResources 1 calls
    1> 0 ms ResolveSDKReferences 1 calls
    1> 0 ms _CheckForDeletedResourceFile 1 calls
    1> 0 ms BeforeCompile 1 calls
    1> 0 ms UpdateAndroidAssets 1 calls
    1> 0 ms DesignTimeXamlMarkupCompilation 1 calls
    1> 0 ms _AddMultiDexDependencyJars 1 calls
    1> 0 ms PrepareForRun 1 calls
    1> 0 ms ResGen 1 calls
    1> 0 ms _GenerateAndroidAssetsDir 1 calls
    1> 0 ms AfterBuild 1 calls
    1> 0 ms BclBuildSetRunningFullBuild 1 calls
    1> 0 ms GetNativeManifest 2 calls
    1> 0 ms ExpandSDKReferences 1 calls
    1> 0 ms GenerateTargetFrameworkMonikerAttribute 1 calls
    1> 0 ms _GenerateAndroidResourceDir 1 calls
    1> 0 ms CreateManifestResourceNames 1 calls
    1> 0 ms BeforeBuild 1 calls
    1> 0 ms _GenerateCompileInputs 1 calls
    1> 0 ms _SetupDesignTimeBuildForBuild 1 calls
    1> 0 ms PrepareResourceNames 1 calls
    1> 0 ms _AddNativeLibraryArchiveToCompile 1 calls
    1> 1 ms GetCopyToOutputDirectoryXamlAppDefs 3 calls
    1> 1 ms _GenerateJavaDesignerForComponent 1 calls
    1> 1 ms _CollectMonoAndroidOutputs 1 calls
    1> 1 ms _SetEmbeddedWin32ManifestProperties 1 calls
    1> 1 ms CoreResGen 1 calls
    1> 1 ms _ValidateLinkMode 1 calls
    1> 1 ms _GetLibraryImports 1 calls
    1> 1 ms _CheckForCompileOutputs 1 calls
    1> 1 ms _ReadPropertiesCache 1 calls
    1> 1 ms GetTargetPath 2 calls
    1> 1 ms _ComputeAndroidResourcePaths 1 calls
    1> 1 ms SetBuildInfoDefaults 1 calls
    1> 1 ms SplitResourcesByCulture 1 calls
    1> 1 ms _SplitProjectReferencesByFileExistence 3 calls
    1> 1 ms GenerateCompiledExpressionsTempFile 1 calls
    1> 1 ms BclBuildDetermineReferencesToRedirect 1 calls
    1> 1 ms _GetReferenceAssemblyPaths 1 calls
    1> 1 ms PreXsdCodeGen 1 calls
    1> 2 ms _RegisterMdbFilesWithFileWrites 1 calls
    1> 2 ms PrepareForBuild 1 calls
    1> 2 ms _BuildSdkCache 1 calls
    1> 2 ms _CalculateAdditionalResourceCacheDirectories 1 calls
    1> 2 ms AssignProjectConfiguration 1 calls
    1> 2 ms _CreateAdditionalResourceCache 1 calls
    1> 2 ms GetReferenceAssemblyPaths 1 calls
    1> 3 ms _GetAdditionalResourcesFromAssemblies 1 calls
    1> 3 ms _CheckDuplicateJavaLibraries 1 calls
    1> 3 ms _CollectAdditionalResourceFiles 1 calls
    1> 3 ms _ExtractLibraryProjectImports 1 calls
    1> 3 ms _ComputeAndroidAssetsPaths 1 calls
    1> 3 ms AssignTargetPaths 3 calls
    1> 3 ms CopyFilesToOutputDirectory 1 calls
    1> 4 ms _ValidateResourceCache 1 calls
    1> 4 ms _ValidateAndroidPackageProperties 1 calls
    1> 5 ms IncrementalClean 1 calls
    1> 7 ms _ResolveMonoAndroidSdks 1 calls
    1> 9 ms _CheckForInvalidConfigurationAndPlatform 3 calls
    1> 10 ms GetCopyToOutputDirectoryItems 3 calls
    1> 11 ms _CopyFilesMarkedCopyLocal 1 calls
    1> 11 ms _CleanGetCurrentAndPriorFileWrites 1 calls
    1> 12 ms _AddLibraryProjectsEmbeddedResourceToProject 1 calls
    1> 18 ms ImplicitlyExpandDesignTimeFacades 1 calls
    1> 29 ms _BuildLibraryImportsCache 1 calls
    1> 41 ms ResolveProjectReferences 1 calls
    1> 70 ms _SetLatestTargetFrameworkVersion 1 calls
    1> 114 ms _ResolveLibraryProjectImports 1 calls
    1> 138 ms ResolveAssemblyReferences 1 calls
    1> 207 ms _UpdateAndroidResgen 1 calls
    1> 356 ms _GetPrimaryCpuAbi 1 calls
    1> 803 ms CoreCompile 1 calls
    1> 38202 ms _BuildAdditionalResourcesCache 1 calls
    1>
    1>Task Performance Summary:
    1> 0 ms CreateCSharpManifestResourceName 1 calls
    1> 0 ms Delete 2 calls
    1> 0 ms FindAppConfigFile 1 calls
    1> 0 ms ResolveCodeAnalysisRuleSet 1 calls
    1> 0 ms CallTarget 1 calls
    1> 0 ms ResolveNonMSBuildProjectOutput 1 calls
    1> 0 ms AssignCulture 1 calls
    1> 1 ms GetFrameworkPath 1 calls
    1> 1 ms GetAndroidPackageName 1 calls
    1> 1 ms AssignProjectConfiguration 1 calls
    1> 1 ms ReadImportedLibrariesCache 1 calls
    1> 1 ms ReadLinesFromFile 2 calls
    1> 1 ms GetAppSettingsDirectory 1 calls
    1> 1 ms AssignTargetPath 18 calls
    1> 1 ms CreateTemporaryDirectory 1 calls
    1> 1 ms GetReferenceAssemblyPaths 2 calls
    1> 2 ms Message 20 calls
    1> 2 ms CalculateAdditionalResourceCacheDirectories 1 calls
    1> 2 ms GetJavaPlatformJar 1 calls
    1> 2 ms MakeDir 2 calls
    1> 2 ms WriteLinesToFile 1 calls
    1> 2 ms ConvertToAbsolutePath 1 calls
    1> 3 ms RemoveDuplicates 2 calls
    1> 3 ms CopyIfChanged 1 calls
    1> 3 ms CheckDuplicateJavaLibraries 1 calls
    1> 3 ms AndroidComputeResPaths 2 calls
    1> 3 ms ReadLibraryProjectImportsCache 1 calls
    1> 3 ms CreateProperty 41 calls
    1> 4 ms CopyGeneratedJavaResourceClasses 1 calls
    1> 4 ms GetExtraPackages 1 calls
    1> 4 ms GetAndroidDefineConstants 1 calls
    1> 4 ms CreateAndroidResourceStamp 1 calls
    1> 5 ms FindUnderPath 5 calls
    1> 5 ms ReadAdditionalResourcesFromAssemblyCache 2 calls
    1> 5 ms CreateResgenManifest 1 calls
    1> 6 ms CreateItem 23 calls
    1> 6 ms RemoveDirFixed 1 calls
    1> 12 ms CreateManagedLibraryResourceArchive 1 calls
    1> 14 ms Copy 3 calls
    1> 16 ms ConvertResourcesCases 1 calls
    1> 21 ms GenerateResourceDesigner 1 calls
    1> 28 ms GetImportedLibraries 1 calls
    1> 49 ms MSBuild 3 calls
    1> 49 ms ReadResolvedSdksCache 1 calls
    1> 114 ms ResolveLibraryProjectImports 1 calls
    1> 137 ms ResolveAssemblyReference 1 calls
    1> 142 ms Aapt 1 calls
    1> 347 ms GetPrimaryCpuAbi 1 calls
    1> 792 ms Csc 1 calls
    1> 38201 ms GetAdditionalResourcesFromAssemblies 1 calls
    1>
    1>Build succeeded.
    1>
    1>Time Elapsed 00:00:40.09

    还有第二个摘要(日志以某种方式包含其中两个摘要),但我不能将其包含在问题中,因为它会超出正文字符限制。
    第二个总结的小版本:
    2>Project Performance Summary:
    2> 6 ms C:\Development\Apps\FieldService-trunk\OverAllField.XamarinAndroid\OverAll.App.Shared\OverAll.App.Shared.csproj 5 calls
    2> 0 ms GetTargetPath 1 calls
    2> 0 ms GetNativeManifest 1 calls
    2> 1 ms GetCopyToOutputDirectoryItems 1 calls
    2> 5 ms GetBuiltProjectOutputRecursive 2 calls
    2> 9 ms C:\Development\Apps\FieldService-trunk\OverAllField.XamarinAndroid\OverAllField.XamarinAndroid.BarcodeScanner\OverAllField.XamarinAndroid.BarcodeScanner.csproj 4 calls
    2> 0 ms GetTargetPath 1 calls
    2> 2 ms GetNativeManifest 1 calls
    2> 3 ms GetCopyToOutputDirectoryItems 1 calls
    2> 4 ms GetBuiltProjectOutputRecursive 1 calls
    2> 17 ms C:\Development\Apps\FieldService-trunk\OverAllField.XamarinAndroid\OverAllField.XamarinAndroid.DataLayer\OverAllField.XamarinAndroid.DataLayer.csproj 5 calls
    2> 9 ms GetTargetPath 1 calls
    2> 1 ms GetNativeManifest 1 calls
    2> 2 ms GetCopyToOutputDirectoryItems 1 calls
    2> 5 ms GetBuiltProjectOutputRecursive 2 calls
    2> 46 ms C:\Development\Apps\FieldService-trunk\OverAllField.XamarinAndroid\OverAllField.XamarinAndroid.ServiceClient\OverAllField.XamarinAndroid.ServiceClient.csproj 4 calls
    2> 21 ms GetTargetPath 1 calls
    2> 0 ms GetNativeManifest 1 calls
    2> 2 ms GetCopyToOutputDirectoryItems 1 calls
    2> 23 ms GetBuiltProjectOutputRecursive 1 calls
    2> 87736 ms C:\Development\Apps\FieldService-trunk\OverAllField.XamarinAndroid\OverAllField.Android\OverAllField.XamarinAndroid.csproj 1 calls

    第二个目标性能摘要:(删除任何 <1000 ms 以减少字符)
    2>     1955 ms  _GenerateJavaStubs                         1 calls
    2> 3083 ms _CreateBaseApk 1 calls
    2> 3467 ms _UpdateAndroidResgen 1 calls
    2> 8944 ms _CompileToDalvikWithDx 1 calls
    2> 66321 ms _BuildAdditionalResourcesCache 1 calls

    第二个任务性能摘要:(再次,删除任何 <1000 ms 以减少字符)
    2>     1245 ms  GenerateJavaStubs                          1 calls
    2> 2334 ms ConvertResourcesCases 3 calls
    2> 4637 ms Aapt 2 calls
    2> 8941 ms CompileToDalvik 1 calls
    2> 66320 ms GetAdditionalResourcesFromAssemblies 1 calls
    2>
    2>Build succeeded.
    2>
    2>Time Elapsed 00:01:27.73

    完整的诊断构建日志 here

    更新 4

    带有 Android 支持版本 23 的完整诊断构建日志 here

    构建时间之间存在显着差异。
    支持版本 24:
    1>Project Performance Summary:
    1> 40103 ms C:\Development\Apps\trunk\App.Droid\App.Droid.ServiceClient\App.Droid.ServiceClient.csproj 1 calls
    ...
    2>Project Performance Summary:
    2> 87736 ms C:\Development\Apps\trunk\App.Droid\App.Droid\App.Droid.csproj 1 calls

    支持版本 23:
    1>Project Performance Summary:
    1> 962 ms C:\Development\Apps\trunk-r1029\App.Droid\App.Droid.ServiceClient\App.Droid.ServiceClient.csproj 1 calls
    2>Project Performance Summary:
    2> 18214 ms C:\Development\Apps\trunk-r1029\App.Droid\App.Droid\App.Droid.csproj 1 calls

    两者都是使用目标 Android 7.0 和相同的 Xamarin 版本构建的,唯一的区别是 Android 支持库版本。这不是一个巨大的增长吗?

    提前致谢!

    最佳答案

    虽然这是一个非常“难以”回答的问题,因为构建时间可能取决于许多不同的因素,但我可以引导您确定 的方法。什么在您的构建中导致延迟。在大多数情况下,这通常是因为未优化 Resources .这可以是真正应该针对移动设备进行优化的原始图像/音频/视频等资源。

    至于您提到的实验性功能,您可以在此处查看发行说明:

    https://developer.xamarin.com/releases/android/xamarin.android_7/xamarin.android_7.0/#Improved_Fast_Deployment

    注:这是实验性的,因此不能保证它足够稳定以用于生产。

    至于构建时间,我们需要知道项目中的瓶颈在哪里。为此,您需要启用 Diagnostic Build Output在您的构建代理的命令中。这很简单,MSBuild通过:
    /v:diag/verbosity:diagnostic (或任何你想要的组合)


    /clp:PerformanceSummary - 这将告诉使用每个任务的性能时间

    https://msdn.microsoft.com/en-us/library/ms164311.aspx

    例如:构建文件->新建 Android 项目:

    1>Project Performance Summary:
    1> 4087 ms c:\users\dougl\documents\visual studio 2015\Projects\App26\App26\App26.csproj 1 calls
    1> 4087 ms Rebuild 1 calls
    1>
    1>Target Performance Summary:
    1> 0 ms GetCopyToOutputDirectoryXamlAppDefs 1 calls
    1> 0 ms BeforeRebuild 1 calls
    1> 0 ms PrepareResources 1 calls
    1> 0 ms _DefineBuildTargetAbis 1 calls
    1> 0 ms UpdateAndroidAssets 1 calls
    1> 0 ms AfterBuild 1 calls
    1> 0 ms AfterCompile 1 calls
    1> 0 ms BeforeCompile 1 calls
    1> 0 ms ExpressionBuildExtension 1 calls
    1> 0 ms _GenerateCompileInputs 1 calls
    1> 0 ms ResolveCodeAnalysisRuleSet 1 calls
    1> 0 ms _LinkAssemblies 1 calls
    1> 0 ms GetTargetPath 1 calls
    1> 0 ms Build 1 calls
    1> 0 ms GenerateCompiledExpressionsTempFile 1 calls
    1> 0 ms _CopyConfigFiles 1 calls
    1> 0 ms Compile 1 calls
    1> 0 ms Rebuild 1 calls
    1> 0 ms ModifyUnitTestPlatformVersion 1 calls
    1> 0 ms _RegisterMdbFilesWithFileWrites 1 calls
    1> 0 ms _CheckForCompileOutputs 1 calls
    1> 0 ms _SetupDesignTimeBuildForIntellisense 1 calls
    1> 0 ms _SetTargetFrameworkMonikerAttribute 1 calls
    1> 0 ms _GenerateAndroidAssetsDir 1 calls
    1> 0 ms _AddMultiDexDependencyJars 1 calls
    1> 0 ms AfterResolveReferences 1 calls
    1> 0 ms UpdateAndroidResources 1 calls
    1> 0 ms _CheckInstantRunCondition 1 calls
    1> 0 ms CleanPublishFolder 1 calls
    1> 0 ms _CheckTargetFramework 1 calls
    1> 0 ms _CollectMonoAndroidOutputs 1 calls
    1> 0 ms _CopySourceItemsToOutputDirectory 1 calls
    1> 0 ms CompileRdlFiles 1 calls
    1> 0 ms _CreateAdditionalResourceCache 4 calls
    1> 0 ms DesignTimeXamlMarkupCompilation 1 calls
    1> 0 ms AfterRebuild 1 calls
    1> 0 ms _SeparateAppExtensionReferences 1 calls
    1> 0 ms ExpandSDKReferences 1 calls
    1> 0 ms _ReadPropertiesCache 1 calls
    1> 0 ms AfterResGen 1 calls
    1> 0 ms CleanReferencedProjects 1 calls
    1> 0 ms _CollectPCLPdbFiles 1 calls
    1> 0 ms Clean 1 calls
    1> 0 ms SetWin32ManifestProperties 1 calls
    1> 0 ms ResolveSDKReferences 1 calls
    1> 0 ms CreateSatelliteAssemblies 1 calls
    1> 0 ms DeleteBuildInfoResource 1 calls
    1> 0 ms _ResolveMonoAndroidFramework 1 calls
    1> 0 ms PrepareResourceNames 1 calls
    1> 0 ms _SetupInstantRun 1 calls
    1> 0 ms _SetupDesignTimeBuildForBuild 1 calls
    1> 0 ms CoreBuild 1 calls
    1> 0 ms _CheckForDeletedResourceFile 1 calls
    1> 0 ms GetFrameworkPaths 1 calls
    1> 0 ms _ValidateLinkMode 1 calls
    1> 0 ms DeleteBuildInfoFile 1 calls
    1> 0 ms _CollectPCLMdbFiles 1 calls
    1> 0 ms _CompileDex 1 calls
    1> 0 ms GetInstalledSDKLocations 1 calls
    1> 0 ms BeforeClean 1 calls
    1> 0 ms BuildOnlySettings 1 calls
    1> 0 ms _ValidateResourceCache 1 calls
    1> 0 ms BeforeResolveReferences 1 calls
    1> 0 ms _CheckForContent 1 calls
    1> 0 ms BeforeResGen 1 calls
    1> 0 ms PrepareRdlFiles 1 calls
    1> 0 ms AfterClean 1 calls
    1> 0 ms _SetupApplicationJavaClass 1 calls
    1> 0 ms ValidationExtension 1 calls
    1> 0 ms _IncludeInstanceRunReference 1 calls
    1> 0 ms ResolveReferences 1 calls
    1> 0 ms CreateCustomManifestResourceNames 1 calls
    1> 0 ms ResGen 1 calls
    1> 0 ms BeforeBuild 1 calls
    1> 1 ms _SplitProjectReferencesByFileExistence 1 calls
    1> 1 ms _GenerateSatelliteAssemblyInputs 1 calls
    1> 1 ms PrepareForRun 1 calls
    1> 1 ms CleanXsdCodeGen 1 calls
    1> 1 ms GenerateTargetFrameworkMonikerAttribute 1 calls
    1> 1 ms ResolveProjectReferences 1 calls
    1> 1 ms AssignTargetPaths 1 calls
    1> 1 ms _CreateIntermediateAssembliesDir 1 calls
    1> 1 ms GetCopyToOutputDirectoryItems 1 calls
    1> 1 ms PreXsdCodeGen 1 calls
    1> 1 ms _GetReferenceAssemblyPaths 1 calls
    1> 1 ms CoreResGen 1 calls
    1> 1 ms _CleanGeneratedDeploymentFiles 1 calls
    1> 1 ms SetBuildInfoDefaults 1 calls
    1> 1 ms AssignProjectConfiguration 1 calls
    1> 1 ms _CreatePackageWorkspace 1 calls
    1> 1 ms _GetMonoPlatformJarPath 1 calls
    1> 1 ms PrepareForBuild 1 calls
    1> 1 ms _CalculateAdditionalResourceCacheDirectories 1 calls
    1> 1 ms _ComputeAndroidResourcePaths 1 calls
    1> 1 ms _SetEmbeddedWin32ManifestProperties 1 calls
    1> 1 ms _GetAddOnPlatformLibraries 1 calls
    1> 1 ms _GetLibraryImports 1 calls
    1> 1 ms SplitResourcesByCulture 1 calls
    1> 1 ms GetReferenceAssemblyPaths 1 calls
    1> 1 ms _CheckProjectItems 1 calls
    1> 1 ms _AdjustJavacVersionArguments 1 calls
    1> 1 ms _CleanGeneratedDebuggingFiles 1 calls
    1> 2 ms _PrepareAssemblies 1 calls
    1> 2 ms _FindJavaStubFiles 1 calls
    1> 2 ms _ExtractLibraryProjectImports 1 calls
    1> 2 ms _StripEmbeddedLibraries 1 calls
    1> 2 ms _CleanGetCurrentAndPriorFileWrites 1 calls
    1> 2 ms _GetAdditionalResourcesFromAssemblies 1 calls
    1> 2 ms _FindCompiledJavaFiles 1 calls
    1> 2 ms _CheckDuplicateJavaLibraries 1 calls
    1> 2 ms _AddLibraryProjectsEmbeddedResourceToProject 1 calls
    1> 3 ms _ComputeAndroidAssetsPaths 1 calls
    1> 3 ms CopyFilesToOutputDirectory 1 calls
    1> 3 ms CoreClean 1 calls
    1> 3 ms _CollectPdbFiles 1 calls
    1> 3 ms GetBuiltProjectOutputRecursive 1 calls
    1> 3 ms _CollectConfigFiles 1 calls
    1> 3 ms _ValidateAndroidPackageProperties 1 calls
    1> 3 ms _WriteResolvedAssemblies 1 calls
    1> 4 ms _CreatePropertiesCache 1 calls
    1> 4 ms _ResolveMonoAndroidSdks 1 calls
    1> 4 ms _AddDebugStaticResources 1 calls
    1> 4 ms _BuildLibraryImportsCache 1 calls
    1> 4 ms _CollectMdbFiles 1 calls
    1> 5 ms _CheckForInvalidConfigurationAndPlatform 1 calls
    1> 7 ms _ResolveSatellitePaths 1 calls
    1> 7 ms _GeneratePackageManagerJava 1 calls
    1> 8 ms _DetermineJavaLibrariesToCompile 1 calls
    1> 9 ms IncrementalClean 1 calls
    1> 10 ms _AddStaticResources 1 calls
    1> 11 ms _CleanMonoAndroidIntermediateDir 1 calls
    1> 11 ms _GenerateAndroidResourceDir 1 calls
    1> 12 ms _CleanMsymArchive 1 calls
    1> 18 ms _SetLatestTargetFrameworkVersion 1 calls
    1> 20 ms ResolveAssemblyReferences 1 calls
    1> 27 ms ImplicitlyExpandDesignTimeFacades 1 calls
    1> 30 ms _BuildSdkCache 1 calls
    1> 35 ms _ConvertPdbFiles 1 calls
    1> 45 ms _CheckTargetFrameworks 1 calls
    1> 46 ms _ResolveLibraryProjectImports 1 calls
    1> 52 ms _CreateBaseApk 1 calls
    1> 66 ms _BuildAdditionalResourcesCache 1 calls
    1> 72 ms _CopyMdbFiles 1 calls
    1> 78 ms _ResolveAssemblies 1 calls
    1> 115 ms _UpdateAndroidResgen 1 calls
    1> 167 ms _GenerateJavaStubs 1 calls
    1> 189 ms _GetPrimaryCpuAbi 1 calls
    1> 453 ms _CopyIntermediateAssemblies 1 calls
    1> 515 ms _LinkAssembliesNoShrink 1 calls
    1> 657 ms _CompileToDalvikWithDx 1 calls
    1> 664 ms _CompileJava 1 calls
    1> 677 ms CoreCompile 1 calls
    1>
    1>Task Performance Summary:
    1> 0 ms CallTarget 1 calls
    1> 0 ms MSBuild 1 calls
    1> 0 ms ResolveCodeAnalysisRuleSet 1 calls
    1> 0 ms ReadLinesFromFile 2 calls
    1> 0 ms GetFrameworkPath 1 calls
    1> 0 ms FindAppConfigFile 1 calls
    1> 0 ms AssignCulture 1 calls
    1> 1 ms GetAppSettingsDirectory 1 calls
    1> 1 ms ConvertToAbsolutePath 1 calls
    1> 1 ms RemoveDuplicates 3 calls
    1> 1 ms AssignTargetPath 6 calls
    1> 1 ms CollectLibraryAssets 1 calls
    1> 1 ms AssignProjectConfiguration 1 calls
    1> 1 ms GetMonoPlatformJar 1 calls
    1> 1 ms CalculateAdditionalResourceCacheDirectories 1 calls
    1> 1 ms CreateTemporaryDirectory 2 calls
    1> 1 ms GetAndroidDefineConstants 1 calls
    1> 1 ms GetAddOnPlatformLibraries 1 calls
    1> 1 ms ReadImportedLibrariesCache 1 calls
    1> 1 ms ReadAdditionalResourcesFromAssemblyCache 1 calls
    1> 1 ms CheckProjectItems 1 calls
    1> 1 ms GetReferenceAssemblyPaths 2 calls
    1> 1 ms AdjustJavacVersionArguments 1 calls
    1> 2 ms FindUnderPath 7 calls
    1> 2 ms Message 17 calls
    1> 2 ms ReadLibraryProjectImportsCache 1 calls
    1> 2 ms MakeDir 6 calls
    1> 2 ms CreateAndroidResourceStamp 1 calls
    1> 2 ms CreateProperty 42 calls
    1> 2 ms CopyIfChanged 1 calls
    1> 2 ms GetAndroidPackageName 2 calls
    1> 2 ms GetJavaPlatformJar 1 calls
    1> 2 ms GetExtraPackages 2 calls
    1> 2 ms CheckDuplicateJavaLibraries 1 calls
    1> 2 ms CreateManagedLibraryResourceArchive 1 calls
    1> 3 ms RemoveUnknownFiles 1 calls
    1> 3 ms AndroidComputeResPaths 2 calls
    1> 3 ms CreateResgenManifest 1 calls
    1> 4 ms GetImportedLibraries 1 calls
    1> 4 ms GetFilesThatExist 3 calls
    1> 6 ms Touch 7 calls
    1> 6 ms CopyGeneratedJavaResourceClasses 2 calls
    1> 7 ms CreateItem 20 calls
    1> 7 ms GeneratePackageManagerJava 1 calls
    1> 7 ms DetermineJavaLibrariesToCompile 1 calls
    1> 8 ms Delete 28 calls
    1> 10 ms CopyResource 4 calls
    1> 11 ms RemoveDirFixed 5 calls
    1> 12 ms WriteLinesToFile 5 calls
    1> 17 ms ReadResolvedSdksCache 1 calls
    1> 27 ms ResolveAssemblyReference 2 calls
    1> 29 ms GenerateResourceDesigner 1 calls
    1> 29 ms ResolveSdks 1 calls
    1> 29 ms ConvertResourcesCases 3 calls
    1> 35 ms ConvertDebuggingFiles 1 calls
    1> 45 ms CheckTargetFrameworks 1 calls
    1> 45 ms ResolveLibraryProjectImports 1 calls
    1> 52 ms CopyMdbFiles 1 calls
    1> 65 ms GetAdditionalResourcesFromAssemblies 1 calls
    1> 77 ms ResolveAssemblies 1 calls
    1> 92 ms Aapt 2 calls
    1> 161 ms GenerateJavaStubs 1 calls
    1> 186 ms GetPrimaryCpuAbi 1 calls
    1> 479 ms Copy 7 calls
    1> 513 ms LinkAssemblies 1 calls
    1> 655 ms CompileToDalvik 1 calls
    1> 660 ms Csc 1 calls
    1> 664 ms Javac 1 calls
    1>
    1>Build succeeded.
    1>
    1>Time Elapsed 00:00:04.08

    请注意,我们可以知道此构建花费了多长时间: 4 秒 .但是,这并不能回答您的情况,但是有了这样的适当日志,我们就可以调查 TargetTask并找出您的项目遇到的瓶颈。我的猜测是 aapt , 但这只是因为即使是 Android Studio 也会卡在这里,因为此工具位于 Android SDK 中。它负责打包android Assets 。

    编辑:

    看起来这个构建花了大约 2 分钟来构建 2 个项目。一个在 C:\Development\Apps\trunk\App.Droid\App.Droid.ServiceClient\App.Droid.ServiceClient.csproj另一个在 C:\Development\Apps\trunk\App.Droid\App.Droid\App.Droid.csproj (分别为 40/87 秒)。对于一个对 Android 支持/Google Play 有这么多第三方依赖的项目来说,这似乎很正常。您可以搜索字符串 Task "GetAdditionalResourcesFromAssemblies显示 6 个定义此内容的地方。由于 2 个 Android 项目,此处调用了 2 个任务。

    可能值得将 Android Studio 项目与这么多外部依赖项进行比较并比较时间。我知道我们目前有很多关于 GetAdditionalResourcesFromAssemblies 的工作正在进行中。任务。然而,这项工作要到第 9-10 周期才能使用。这项工作目前是拉取请求的一部分:

    https://github.com/xamarin/xamarin-android/pull/296

    (由于提交时间,您可以说它几乎是全新的)。

    从这个任务中可以看出,将有以下改进:

    The current Task always downloads data from google. This is regardless of whether the files exist in the Android sdk directory already. This commit changes the GetAdditionalResourcesFromAssemblies task to look in the "extras" folder in the android sdk for the required .aar file. This will mean if a user has an up to date sdk, there will be almost no need to download the files from the internet.



    还有一个 PR - https://github.com/xamarin/xamarin-android/pull/292 (感谢@Mikhail)

    哪些地址重用计算的哈希值,这也可以降低构建时间。

    TLDR; GetAdditionalResourcesFromAssemblies需要更多的工作才能缩短构建时间。这目前正在进行中。

    编辑 2:

    这目前在包含对 https://www.nuget.org/packages/Xamarin.Build.Download/ 的依赖项的支持库中得到解决。

    关于visual-studio - 缓慢的应用程序构建 - Xamarin for Visual Studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40523414/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com