如何在 TeamCity 中使用 VisualStudio SignAndroidPackage? [英] How to use VisualStudio SignAndroidPackage in TeamCity?

查看:38
本文介绍了如何在 TeamCity 中使用 VisualStudio SignAndroidPackage?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 xamarin 表单,但在尝试自动构建我的解决方案时,我在 teamcity 中执行构建步骤之一时遇到困难.

谁能给我一个如何在 TeamCity 中使用 VisualStudio SignAndroidPackage 的示例?对于我在 teamcity 中的构建步骤之一,我选择了我的 runnertype 作为 Visual Studio,并将目标设置为 SignAndroidPackage,将配置设置为发布,我的 Visual Studio 设置为 visualstudio2017.

但我想知道在哪里以及如何指定用于此特定构建步骤的密钥库,就像我如何为 Visual Studio 对话框执行此操作一样,如下图所示.

我用谷歌搜索,我能得到的最接近的答案来自

但问题是当 xamarin.android 中没有 gradle 时,我该如何做同样的事情?

解决方案

您不需要 gradle 文件来使用 Xamarin 对 apk 进行签名,您只需将您的项目传递给具有指定构建目标的 msbuild,它将对您的.apk.

  1. 在项目属性 -> 正确配置下的Android Package Signing"(例如Release")中指定密钥库属性(启用复选框并填写密钥库/别名/密码).
  2. 添加 msbuild 构建步骤并选择您的 Android .csproj 作为构建文件路径.
  3. 在 Targets 中设置Build SignAndroidPackage"(不带引号),这将首先构建您的项目,然后对 .apk 进行签名.
  4. 在命令行参数中设置/p:Configuration=Release"(不带引号)以选择首选配置.如果您的配置包含空格,您可以输入/p:Configuration="Release Foo".

不要忘记在此构建步骤之前还原 NuGet 包.您还可以通过将命令参数传递给 msbuild 来设置或覆盖密钥库属性:/p:AndroidKeyStore="true"/p:AndroidSigningKeyStore ="foo.keystore" 等...

I am using xamarin forms but I got stuck doing one of the build steps in teamcity while trying to automate building my solution.

Anyone able to give me an example of how to use VisualStudio SignAndroidPackage in TeamCity? For one of my build steps in teamcity, I chose my runnertype as visual studio and set targets to be SignAndroidPackage, configuration as release and my visual studio as visualstudio2017.

But I would like to know where and how I could specify the keystore to use for this particular build step just like how i can do it for the visual studio dialog as shown in the picture below.

I googled and the closest answer I could get was from https://developer.android.com/studio/publish/app-signing#releasemode

But the thing is how do I do the same thing when there is no gradle in xamarin.android?

解决方案

You do not need a gradle file to sign the apk with Xamarin, you can just pass your project to msbuild with a specified build target which will sign and zipalign your .apk.

  1. Specify the keystore properties (enable checkbox and fill in keystore/alias/passwords) in the project properties -> "Android Package Signing" under the correct configuration (e.g. "Release").
  2. Add msbuild build step and select your Android .csproj as Build file path.
  3. Set "Build SignAndroidPackage" in Targets (without quotes), this first builds your project and then signs the .apk.
  4. Set "/p:Configuration=Release" in Command line parameters (without quotes) to select the preferred configuration. If your configuration contains spaces you can enter /p:Configuration="Release Foo".

Do not forget to restore the NuGet packages before this build step. You can also set or override the keystore properties by passing the command parameters to msbuild: /p:AndroidKeyStore="true" /p:AndroidSigningKeyStore ="foo.keystore" etc...

这篇关于如何在 TeamCity 中使用 VisualStudio SignAndroidPackage?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆