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