【问题标题】:Xamarin.Android Continuous Integration and Testing with TFS 2013Xamarin.Android 与 TFS 2013 的持续集成和测试
【发布时间】:2016-12-07 06:11:10
【问题描述】:

对于 TFS 2013(以及旧的 XAML 构建配置),如何为 Android 项目生成 APK 文件?我一直在构建项目,但在日志文件夹中出现此错误,即使我构建了“发布”配置

1>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(618,5):警告:未为项目“Project.Android.csproj”设置 OutputPath 属性.请检查以确保您为此项目指定了有效的配置和平台组合。配置='发布'平台='混合平台'。您可能会看到此消息,因为您正在尝试构建一个没有解决方案文件的项目,并且指定了该项目不存在的非默认配置或平台。

文件夹中没有任何内容。我已按照 Xamarin Docs 中的步骤进行操作,但似乎不适用于 TFS2013: https://developer.xamarin.com/guides/cross-platform/ci/tfs_walkthrough/add-build-definition/

【问题讨论】:

    标签: xamarin.android continuous-integration


    【解决方案1】:

    配置构建定义时,TFS2013 的 UI 非常相似。您必须在“5. Advanced”子标题下为 MSBuild 提供一些额外的参数:

    您收到“OutputPath”错误,因为您没有为构建指定输出路径。现在对于 APK,从命令行构建时,您必须提供一个附加参数:“/t:PackageForAndroid”

    您必须将它与其他 MSBuild 参数结合起来,以实现如下所示:

    /p:AndroidSdkDirectory=c:\android-sdk /p:Configuration=Release
    /p:Platform="AnyCPU" /p:OutputPath="bin/Release" /t:PackageForAndroid
    

    如果您没有任何其他错误,那么您的构建应该会成功!这是来自我们的 Xamarin 论坛(大约 2013 年)的示例 PowerShell 脚本,其中还包括签名和 zip 对齐:

    # First clean the Release target.
    msbuild.exe HelloWorld.csproj /p:Configuration=Release /t:Clean
    
    # Now build the project, using the Release target.
    msbuild.exe HelloWorld.csproj /p:Configuration=Release /t:PackageForAndroid /p:Platform="AnyCPU" /p:OutputPath="bin/Release"
    
    # At this point there is only the unsigned APK - sign it.
    # The script will pause here as jarsigner prompts for the password.
    # It is possible to provide they keystore password for jarsigner.exe by adding an extra command line parameter -storepass, for example
    #    -storepass <MY_SECRET_PASSWORD>
    # If this script is to be checked in to source code control then it is not recommended to include the password as part of this script.
    
    & 'C:\Program Files\Java\jdk1.8.x.x\bin\jarsigner.exe' -verbose -sigalg MD5withRSA -digestalg SHA1  
    -keystore ./xample.keystore -signedjar
    ./bin/Release/helloworld-signed.apk
    ./bin/Release/helloworld.apk publishingdoc
    
    # Now zipalign it.  The -v parameter tells zipalign to verify the APK afterwards.
    
    & 'C:\Program Files\Android\android-sdk\tools\zipalign.exe' -f -v 4
    ./bin/Release/helloworld.apk ./newAPK.apk
    

    签名和zip对齐,可以参考Xamarin.Android docs on this matter.

    【讨论】:

      猜你喜欢
      • 2014-08-14
      • 2012-10-21
      • 1970-01-01
      • 2017-06-30
      • 1970-01-01
      • 2010-11-27
      • 1970-01-01
      • 2014-04-24
      • 1970-01-01
      相关资源
      最近更新 更多