2016-12-06 121 views
0

對於TFS 2013(以及舊的XAML構建配置),您如何爲Android項目生成APK文件?我一直在構建項目,但是在日誌文件夾中出現此錯誤,即使構建「發佈」配置Xamarin.Android與TFS 2013的持續集成和測試

1> C:\ Program Files(x86)\ MSBuild \ 12.0 \ bin \ Microsoft.Common .CurrentVersion.targets(618,5):警告:OutputPath屬性未爲項目「Project.Android.csproj」設置。請檢查以確保您已爲該項目指定了Configuration和Platform的有效組合。配置='發佈'平臺='混合平臺'。您可能會看到此消息,因爲您正在嘗試構建沒有解決方案文件的項目,並且指定了此項目不存在的非默認配置或平臺。

該文件夾中沒有任何東西存在。我遵循Xamarin文檔中的步驟,但它似乎不適用於TFS2013: https://developer.xamarin.com/guides/cross-platform/ci/tfs_walkthrough/add-build-definition/

回答

0

配置構建定義時,TFS2013的用戶界面非常相似。你有「5.高級」小標題下提供一些額外的參數的MSBuild:

MSBuild Arguments in Advanced Section

,因爲你沒有指定爲構建輸出路徑你所得到的「OutputPath」的錯誤。現在的APK,在命令行建立的時候,你必須提供一個額外的參數:「/ T:PackageForAndroid」

你必須把這個與其他的MSBuild論據是這樣的組合:

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

如果你沒有任何其他錯誤,你的構建應該是成功的!這是我們從Xamarin論壇爲例PowerShell腳本(2013年左右),其中包括簽署和拉鍊對準以及:

# 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 

對於簽名和拉鍊心,你可以參考Xamarin.Android docs on this matter.

+0

您可以標記它作爲答案 –