是否有人使用gitlab ci成功构建了Xamarin.Forms?
我正在与Xamarin.Forms合作一个pet项目,我想知道是否有人有成功配置gitlab-ci.yml构建的经验。一般来说,关于为.NET构建进行配置的资料似乎有限,在将两个构建串联在一起之前,我尝试成功构建一个。已针对生成路径尝试了每个project.csproj 如有任何见解和经验,将不胜感激 Current.gitlab-ci.yml是否有人使用gitlab ci成功构建了Xamarin.Forms?,xamarin,xamarin.forms,continuous-integration,gitlab-ci,continuous-deployment,Xamarin,Xamarin.forms,Continuous Integration,Gitlab Ci,Continuous Deployment,我正在与Xamarin.Forms合作一个pet项目,我想知道是否有人有成功配置gitlab-ci.yml构建的经验。一般来说,关于为.NET构建进行配置的资料似乎有限,在将两个构建串联在一起之前,我尝试成功构建一个。已针对生成路径尝试了每个project.csproj 如有任何见解和经验,将不胜感激 Current.gitlab-ci.yml image: mono variables: Solution: Solution.sln stages: - build - tes
image: mono
variables:
Solution: Solution.sln
stages:
- build
- test
- deploy
before_script:
- nuget restore $Solution
build:
stage: build
script:
- MONO_IOMAP=case xbuild /p:Configuration="Release" /p:Platform="iPhone" /t:Build $Solution
还没有,很遗憾,您需要一台windows计算机,前提条件:
- 窗户
- 是的。NET Framework仅在Windows操作系统中工作,因此您要使用的计算机需要使用Windows
- 吉特
- 你认为我们需要安装Git吗?好吧,这是一个笑话,很明显我们需要git,顺便说一下,我们要使用GitLab李>
- MSBuild
- 为了能够构建和发布应用程序,我们需要安装MSBuild
您可以获得更多关于在.Net上构建新Xamarin表单所依赖的信息。是的,我们让它可以完美地工作,而无需使用boots或AzureDevops。正如@AkashKava所提到的,我必须让它在Mac构建代理/运行程序上运行,我使用它的分发部分,在那里我还存储了我的证书、密钥库和配置文件 因此,在一切运行之前,请确保还原nuget软件包并安装必要的库
nuget
,msbuild
,appcenter
,…:
before_script:
- nuget restore
然后,要创建Android QA apk文件:
android_dev_apk:
stage: build
dependencies: []
tags:
- xamarin
script:
- msbuild {AppName}.sln $BUILD_VERBOSITY /t:Clean /p:Configuration=Dev
- msbuild {AppName}.sln $BUILD_VERBOSITY /t:Build /p:Configuration=Dev
- msbuild {AppName}.Android/{AppName}.Android.csproj $BUILD_VERBOSITY /t:PackageForAndroid /t:SignAndroidPackage /p:Configuration=Dev /p:AndroidKeyStore=True
只需将{AppName}替换为应用程序的文件夹名/应用程序名,这与我的情况相同。iOS也是如此
ios_qa_app:
stage: build
dependencies: []
tags:
- xamarin
script:
- rm -rf {AppName}.iOS/bin/iPhone/QA
- msbuild {AppName}.sln $BUILD_VERBOSITY /t:Clean /p:Platform=iPhone /p:Configuration=QA
- msbuild {AppName}.sln $BUILD_VERBOSITY /t:Build /p:Platform=iPhone /p:ArchiveOnBuild=true /p:Configuration=QA
artifacts:
paths:
- {AppName}.iOS/bin/iPhone/QA/{AppName}.ipa
- {AppName}.iOS/bin/iPhone/QA/{AppName}.app.dSYM
expire_in: 10 day
when: on_success
only:
- schedules
except:
variables:
- $ProdBuild == "true"
请注意,在script
下,所有操作都与使用终端时一样,因此您也可以键入ls
之类的内容,以便在输出日志中打印该文件夹中的文件列表,或键入cd..
或cd DirectoryName
以更改文件夹
因此,要分发Android工件,请在您的Android脚本中添加以下内容:
- appcenter distribute release --app {CompanyInAppCenter}/{AndroidAppNameInAppCenter} --group "Collaborators" --file {AppName}.Android/bin/QA/{BundleIdentifier}-Signed.apk --token=${APPCENTER_API_TOKEN}
最后,要分发iOS工件,请在iOS脚本中添加以下内容:
- appcenter distribute release --app {CompanyInAppCenter}/{iOSAppNameInAppCenter} --group "Collaborators" --file {AppName}.iOS/bin/iPhone/QA/{AppName}.ipa --token=${APPCENTER_API_TOKEN}
PS:我写了一篇文章,介绍了如何在不使用自己的构建代理的情况下完成这些工作。成功了吗?@jzeferino在GitLab repo for.NET示例中有一个问题,评论中有一些示例。除了一些好的起点,还没有什么东西融合在一起。我会看一看,但我计划使用cake。这里有一个由@bravecobra制作的cake示例,可能会对哈哈有所帮助。对于Xamarin.Forms,您需要windows或mac build agent,我认为gitlab没有这些示例。你可以免费使用它。谢谢你的回答,萨默!我已经好几年没有接触过Xamarin了,也没有机会验证我自己,但如果其他人接触过,请告诉我,我会接受mark。别担心@Shazbot!我仔细研究了Xamarin最古老的未回答问题,发现了这个。并意识到我确实在Xamarin iOS和Android应用程序的CI/CD中使用了GitLab。所以我想我会和大家分享,特别是因为很多人似乎都在寻找答案:)