It might be caused by some of the files of the application that are still running, or being opened during the installation. Make sure all files are closed.
Another cause might be a virus scanner, try to disable scanning of the install location.
As Windows security gets more tight which each update, that might also cause trouble.
It is recommended to install in the users AppData directory, see:
ClickOnce installation issue after Windows 10 Update[
^]