Reason for partial rebuild on unchanged Xamarin Android project after each deploy
Follow

When I build my Xamarin Android project twice in a row, everything works as expected. The second build skips all targets and finished quickly.

When I press Run or Debug, the same build process happens, quickly skipping all targets. Then the "Select Deployment Target" dialog pops up, where I select an emulator (the same each time). Then the "Install" build target is executed to get the app on the device. This takes quite a while, because it is executing some build targets that were skipped during the build step.

When I stop running / debugging and build again, build is slow - it is executing the same build targets that were executed as part of the "Install" target.

Some shared target of the Install / Build tasks is executing with different parameters between these targets, which is causing build artefacts to change, causing a partial rebuild every time one of these targets is executed (i.e. every time I deploy the app), which is of course rather annoying. After going through the diagnostic build logs, the culprit appears to be the `_LinkAssembliesShrink` task, which is triggered because `obj/Debug/build.props` changes. Indeed that file is different between a build and an install.

I would like to know: does anyone know of any way I can prevent this? It would help a lot if a build for a deploy was executed with the same `build.props` parameter as the install target that follows, so the linker doesn't have to execute twice (the linker is slow..). I have no idea how to go about this though. A workaround would of course be to disable the linker, but since this is not an option for our production app I would very much like to have it enabled on Debug as well, because it'll otherwise lead to hard to diagnose bugs that won't show up during the development process.

Votes

Share

As it would turn out, there are several other tasks relying on `build.props` that lead to the redundant build steps. The solution really seems to be that `build.props` shouldn't change between a build / install. Checking what happens in VS4Mac, there is indeed no such difference, so this problem doesn't occur. Any ideas / workarounds are very welcome.