Error with Pre-Build event to change package name

I am developing an Android app in Xamarin.

I want to update package name in PreBuild Event. So I followed the example:

Recommended way to create a test version of an Android application

I did the following:

  • Created a new configuration named "DMS"

  • A new conditional compilation symbol is defined, i.e. DMS

  • Rename the existing AndroidManifest.xml to AndroidManifest-Template.xml

  • Created two .xslt files in the Properties folder

my manifest-transform.xslt

<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output indent="yes" />
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()" />
    </xsl:copy>
  </xsl:template>
  <xsl:template match="/manifest/@package">
    <xsl:attribute name="package">
      <xsl:value-of select="'your.mypackage.here'" />
    </xsl:attribute>
  </xsl:template>
</xsl:stylesheet>

      

and I added the following Pre-Build Event:

<Target Name="BeforeBuild">
  <XslTransformation 
    Condition="'$(Configuration)|$(Platform)' != 'DMS|AnyCPU'" 
    XslInputPath="Properties\manifest-copy.xslt" 
    XmlInputPaths="Properties\AndroidManifest-Template.xml" 
    OutputPaths="Properties\AndroidManifest.xml" />
  <XslTransformation 
    Condition="'$(Configuration)|$(Platform)' == 'DMS|AnyCPU'" 
    XslInputPath="Properties\manifest-transform.xslt" 
    XmlInputPaths="Properties\AndroidManifest-Template.xml" 
    OutputPaths="Properties\AndroidManifest.xml" />
</Target>

      

But when I build my project, I get the following error:

enter image description here

I have included "Build Diagnostics" and these are the messages:

1>Done building target "PrepareForBuild" in project "TBApp.Droid.csproj".: (TargetId:18)
1>Target "PreBuildEvent: (TargetId:19)" in file "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets" from project "C:\_Workspace\TBApp\trunk\TBApp\TBApp\TBApp.Droid\TBApp.Droid.csproj" (target "CoreBuild" depends on it):
1>Using "Exec" task from assembly "Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>Task "Exec" (TaskId:18)
1>  Task Parameter:WorkingDirectory=bin\DMS\ (TaskId:18)
1>  Task Parameter:Command=<Target Name="BeforeBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><XslTransformation Condition="'DMS|AnyCPU' != 'DMS|AnyCPU'" XslInputPath="Properties\manifest-copy.xslt" XmlInputPaths="Properties\AndroidManifest-Template.xml" OutputPaths="Properties\AndroidManifest.xml" /><XslTransformation Condition="'DMS|AnyCPU' == 'DMS|AnyCPU'" XslInputPath="Properties\manifest-transform.xslt" XmlInputPaths="Properties\AndroidManifest-Template.xml" OutputPaths="Properties\AndroidManifest.xml" /></Target> (TaskId:18)
1>  <Target Name="BeforeBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><XslTransformation Condition="'DMS|AnyCPU' != 'DMS|AnyCPU'" XslInputPath="Properties\manifest-copy.xslt" XmlInputPaths="Properties\AndroidManifest-Template.xml" OutputPaths="Properties\AndroidManifest.xml" /><XslTransformation Condition="'DMS|AnyCPU' == 'DMS|AnyCPU'" XslInputPath="Properties\manifest-transform.xslt" XmlInputPaths="Properties\AndroidManifest-Template.xml" OutputPaths="Properties\AndroidManifest.xml" /></Target> (TaskId:18)
1>  < was unexpected at this time. (TaskId:18)
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1250,5): error MSB3073: The command "<Target Name="BeforeBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><XslTransformation Condition="'DMS|AnyCPU' != 'DMS|AnyCPU'" XslInputPath="Properties\manifest-copy.xslt" XmlInputPaths="Properties\AndroidManifest-Template.xml" OutputPaths="Properties\AndroidManifest.xml" /><XslTransformation Condition="'DMS|AnyCPU' == 'DMS|AnyCPU'" XslInputPath="Properties\manifest-transform.xslt" XmlInputPaths="Properties\AndroidManifest-Template.xml" OutputPaths="Properties\AndroidManifest.xml" /></Target>" exited with code 255.
1>Done executing task "Exec" -- FAILED. (TaskId:18)
1>Done building target "PreBuildEvent" in project "TBApp.Droid.csproj" -- FAILED.: (TargetId:19)
1>Target "_CheckForCompileOutputs: (TargetId:20)" in file "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets" from project "C:\_Workspace\TBApp\trunk\TBApp\TBApp\TBApp.Droid\TBApp.Droid.csproj" (target "_CleanGetCurrentAndPriorFileWrites" depends on it):
1>Set Property: _DocumentationFileProduced=false
1>Set Property: _DebugSymbolsProduced=false
1>Done building target "_CheckForCompileOutputs" in project "TBApp.Droid.csproj".: (TargetId:20)
1>Target "_SGenCheckForOutputs" skipped, due to false condition; ('$(_SGenGenerateSerializationAssembliesConfig)' == 'On' or ('@(WebReferenceUrl)'!='' and '$(_SGenGenerateSerializationAssembliesConfig)' == 'Auto')) was evaluated as ('Off' == 'On' or (''!='' and 'Off' == 'Auto')).
1>Target "_CleanGetCurrentAndPriorFileWrites: (TargetId:21)" in file "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets" from project "C:\_Workspace\TBApp\trunk\TBApp\TBApp\TBApp.Droid\TBApp.Droid.csproj" (target "_CleanRecordFileWrites" depends on it):
1>Using "ReadLinesFromFile" task from assembly "Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>Task "ReadLinesFromFile" (TaskId:19)

      

Location of files:

enter image description here

0


source to share





All Articles