I have a WPF project. Its .csproj
file contains a <PostBuildEvent>
- there runs a script which produces some extra files. The size of one of them is almost 20 MB, and the project itself is pretty large - it may be important to reproduce the issue.
I would like to deploy these files along with the project via ClickOnce. So later in the .csproj
I write:
<Content Include="$(PathToDirectoryWithProducedFiles)\**\*">
<Link>$(PathRelativeToOutput)\%(RecursiveDir)%(Filename)%(Extension)</Link>
<Visible>false</Visible>
</Content>
This does usually work, but not always.
Sometimes the files just are not put into the publish
folder, and sometimes ClickOnce installer produces an error "File, [filewhichweights20MB], has a different computed hash than specified in manifest"
.
I have a clear feeling there is a race condition between ClickOnce deployment process and the script inside <PostBuildEvent>
. Sometimes the script produces all files in time, and sometimes ClickOnce tries to copy the directory before they are completely generated.
I've tried to specify each file in different <Content>
tags separately, but it doesn't work. Moreover, in theory there may be a situtation when the script produces different files, so this workaround will become useless.
The questions are:
- When (after what stage of build process) does ClickOnce exactly copy
<Content>
files and folders into thepublish
folder? - Why there is a race condition there, as in theory
<PostBuildEvent>
is a part of build process? - [The main one] How do I include files produced inside the
<PostBuildEvent>
script into the deploy correctly to get rid of infrequent but very annoying deployment errors? (And not to usemage.exe
as using it would be more complicated)