1
我想從versionName自動生成versionCode。 我想刪除所有的點。和替換X的爲00的MSBuild搜索並替換爲xml文件
從2.05.X.20所以 - > 2050020
我已經開始tackeling的X 00更換 所以我已經添加了follwoing BeforeBuild目標VS的csproj文件:
<Target Name="BeforeBuild">
<!-- find the versionName in the file -->
<XmlPeek XmlInputPath="Properties\AndroidManifest.xml" Namespaces="<Namespace Prefix='android' Uri='http://schemas.android.com/apk/res/android' />" Query="manifest/@android:versionName">
<Output TaskParameter="Result" ItemName="FoundVersionName" />
</XmlPeek>
<!-- write the replaced versioncode to the file -->
<XmlPoke XmlInputPath="Properties\AndroidManifest.xml" Namespaces="<Namespace Prefix='android' Uri='http://schemas.android.com/apk/res/android' />" Query="manifest/@android:versionCode"
Value="$([System.String]::Copy($(FoundVersionName)).Replace('X','00')) " />
</Target>
不過,這樣的輸出看起來像
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="$(FoundVersionName)" android:versionName="2.05.X.20" android:installLocation="auto" package="mtdata_taxi_tablet.mtdata_taxi_tablet">
我試過
- $([System.String] ::複製($ {FoundVersionName})。替換( 'X', '00'))
- $([System.String] ::複製($(FoundVersionName) ).Replace('X','00'))
- $([System.String] :: Copy($ FoundVersionName).Replace('X','00'))
- $([System。字符串] ::複製(@FoundVersionName).Replace('X','00'))
- $([System.String] :: Copy(FoundVersionName).Replace('X','00'))
但他們都沒有工作
如果我使用
- $(FoundVersionName)
安卓的versionCode被替換2.05.X.20
有什麼想法?
謝謝你改變了這個!就是這樣。 – clogwog