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 5612 [details]
Basic New Android Project with BeforeBuild target added to csproj
Due to bug 13865, the way to single source a pre-build command for Visual and Xamarin Studio is to use the MSBuild BeforeBuild target. However, when I run the app, this target runs twice. I have attached a sample project demonstrating this. It's just a new Android project from Visual Studio with the following lines added at the bottom of the .csproj file:
<Message Text="### BeforeBuild target called ###" />
After clicking the start button (or F5) to start debugging, look in the build output. You will see the text
### BeforeBuild target called ###
appear twice (Actually 3 times, but it looks like the last two are the same -- the SignAndroidPackage output is just appended a second time as the build start time is the same).
The BeforeBuild target should only run once, as the app should only be built once. In the Xamarin.Android.Common.targets file, the SignAndroidPackage target depends on Build. I don't know what the fix is, but since the app was just built, there seems to be a bug in the dependency scheduler that actually does the Build twice and thus causes the BeforeBuild target to run twice.
I'm using the BeforeBuild target to increment the version in AndroidManifest.xml, so this is particularly problematic because the version increments twice. I think the workaround I'm going to use is the MSBuild PreBuildEvent and only build our versioned release from Visual Studio.
Actually, upon further investigation, the PreBuildEvent is also called twice. I don't currently know of a workaround for this issue.
Unfortunately, we’re unable to reproduce this report. If this issue is still occurring for you, please reopen this issue and attach a reproduction to the bug by starting with a clean Xamarin.Android project adding just the code necessary to demonstrate the issue.