Xamarin.Android与TFS 2013的持续集成和测试

马赫迪(Mahdi Alirezaie)

对于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文档中的步骤,但似乎不适用于TFS2013:https : //developer.xamarin.com/guides/cross-platform/ci/tfs_walkthrough/add-build-definition/

马赫迪(Mahdi Alirezaie)

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

“高级”部分中的“ 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文档。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章