首先,我是整个Xamarin生命周期的完整初学者,构建工具和术语,如果这在某些措辞中非常基本/不正确,那就很抱歉。
我们有一个Example.sln
文件,其中包含以下项目定义;一个用于Android,一个用于iOS:
Project("{...}") = "Example", "Example\Example\Example.csproj", "{...}"
EndProject
Project("{...}") = "Example.Droid", "Example\Example.Droid\Example.Droid.csproj", "{...}"
EndProject
Project("{...}") = "Example.iOS", "Example\Example.iOS\Example.iOS.csproj", "{...}"
EndProject
我目前正尝试在命令行上使用xbuild
构建仅iOS项目。我的问题是,是否有办法在xbuild
标志上指定此项;例如尝试了/t:Example.ios:Build
和类似的东西,没有运气。所以我只是尝试分拆Android项目并运行:
$ xbuild /p:Configuration="Ad-Hoc" \
/p:Platform="iPhone" \
/p:IpaPackageDir="./Builds" \
/t:Build Example.sln
我想,由于Droid项目在.sln
上之前仍然 iOS,因此在寻找Android SDK时失败了:
/Users/ci/Example-app/Example.sln (Build) ->
(Build target) ->
/Users/ci/Example-app/Example/Example.Droid/Example.Droid.csproj (default targets) ->
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets (_BuildSdkCache target) ->
: error XA5205: The Android SDK Directory could not be found. Please set via /p:AndroidSdkDirectory.
暂时从解决方案中移除Android项目可以解决问题(保留Example\Example.Droid
文件但注释掉2行),但这对我来说并不是最理想的,也就是说在某些其他CI工作中想要构建Android应用程序等。
谢谢!
答案 0 :(得分:1)
您可以通过Configuration manager (see Solution Configurations
section)禁用为Platform=iPhone
案例构建的Android项目。或者,您可以为您的解决方案创建单独的配置/平台组合,仅启用常见项目和iOS项目。
完成后,您可以在xbuild或msbuild的命令行中选择该配置和平台组合
xbuild /p:Configuration=.. /p:Platform=.. foo.sln
。
答案 1 :(得分:0)
我建议您从Xamarin iOS项目的文件夹中执行xbuild命令,或者为您的命令指定目标,如下所示:
xbuild /p:..... iOSProject/app.csproj
xbuild将构建项目或解决方案文件的路径作为 主要论点。如果没有指定文件,那么它会尝试构建任何文件 当前目录中的解决方案文件或项目文件,具有 * proj扩展。
如果您需要强制SDK或特定的构建工具路径,则必须指定:
/ P:AndroidSdkDirectory = $ YOUR_SDK_PATH
/p:AndroidSdkBuildToolsVersion=23.x.x