Is It Possible To Specify Package Name Dynamically During Build?
I'd like to deploy both Debug and Release builds to my device at the same time. I can do this if I manually change the package name in the manifest before I build, e.g. change <
Solution 1:
You'll need to create a custom Pre-Build Event for your project.
Right-click on your project and select Properties...
Then click on Build Events and add this to the Pre-build event textbox:
PowerShell -File "$(SolutionDir)Update-PackageName.ps1"$(ProjectDir)$(ConfigurationName)
Copy the following PowerShell script and save it in your solution folder as Update-PackageName.ps1
param ([string] $ProjectDir, [string] $ConfigurationName)
Write-Host "ProjectDir: $ProjectDir"
Write-Host "ConfigurationName: $ConfigurationName"$ManifestPath = $ProjectDir + "Properties\AndroidManifest.xml"
Write-Host "ManifestPath: $ManifestPath"
[xml] $xdoc = Get-Content $ManifestPath$package = $xdoc.manifest.package
If ($ConfigurationName -eq "Release" -and$package.EndsWith("DEBUG"))
{
$package = $package.Replace("DEBUG", "")
}
If ($ConfigurationName -eq "Debug" -and -not $package.EndsWith("DEBUG"))
{
$package = $package + "DEBUG"
}
If ($package -ne $xdoc.manifest.package)
{
$xdoc.manifest.package = $package$xdoc.Save($ManifestPath)
Write-Host "AndroidManifest.xml package name updated to $package"
}
Good luck!
Solution 2:
According to this question on Xamarin's forum you can change the Packaging Properties and specify different AndroidManifest.xml
files for each build.
In the droid.csproj
file add the <AndroidManifest>
tag like so, for each build configuration:
<PropertyGroupCondition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
...
<AndroidManifest>Properties\AndroidManifestDbg.xml</AndroidManifest>
...
Here's the Xamarin's documentation on it.
Post a Comment for "Is It Possible To Specify Package Name Dynamically During Build?"