Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 4961 [details]
I use Xamarin Studio with Mono for Android.
I have problem with obfuscation my Android application.
So, I add this external command in my project in Release mode, that it launch after Generation:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Command type="AfterBuild" command="Obfuscate.bat" workingdir="" externalConsole="True" />
My file Obfuscate.bat obfuscate the dll from Bin folder, after that I copy obfuscated file into Bin and Obj/assembly folder:
copy "obj\Release\assemblies\Mono.Android.dll" "bin\Release\Mono.Android.dll"
copy "obj\Release\assemblies\Mono.Android.Export.dll" "bin\Release\Mono.Android.Export.dll"
copy "obj\Release\assemblies\Mono.Android.Support.v4.dll" "bin\Release\Mono.Android.Support.v4.dll"
copy "obj\Release\assemblies\Mono.Security.dll" "bin\Release\Mono.Security.dll"
copy "obj\Release\assemblies\mscorlib.dll" "bin\Release\mscorlib.dll"
"C:\Program Files (x86)\LogicNP Software\Crypto Obfuscator For .Net 2013 R2\co.exe" projectfile= obfuscator.obproj
copy "CryptoObfuscator_Output\xx.dll" "bin\Release\assemblies\xx.dll"
copy "CryptoObfuscator_Output\xx.dll" "obj\Release\assemblies\xx.dll"
The external command is called, but when Xamarin Studio start create APK, new generation start without call my external command.
After that, the DLL into BIN and OBJ folder are not obfuscated.
Created attachment 4962 [details]
Android Tools Log
There are _three_ mechanisms to do post-build commands:
1. The <CustomCommands/> element, as is used here.
This is what Xamarin Studio's Build > Custom Commands section uses.
2. The $(PostBuildEvent) MSBuild property. This is what Visual Studio generates.
3. Overriding the $(BuildDependsOn) MSBuild property.
The problem is that (1) is only supported by the Xamarin Studio build system, not Visual Studio, MSBuild, or `xbuild`, and Xamarin.Android projects are always built with MSBuild/xbuild. Consequently, Obfuscate.bat will not be invoked except when using the Xamarin Studio Build command, which will not be the case when e.g. Running the application on a device.
Note: the Changing Xamarin Studio to use $(PostBuildEvent) is tracked at Bug #13865.
The fix is to use either (2) or (3).
Using $(PostBuildEvent) would consist of adding the following XML fragment as a child of the <Project/> element:
Using the $(BuildDependsOn) MSBuild property allows execution of MSBuild _targets_ (as opposed to commands), and requires two parts, setting the $(BuildDependsOn) property, and then providing the target.
The $(BuildDependsOn) property is set via a <PropertyGroup/>, and contains the MSBuild targets to execute:
The second part requires defining the target used in $(BuildDependsOn):
*** This bug has been marked as a duplicate of bug 13865 ***