Deterministic automatically generated AssemblyFileVersion?
Hello,
I have been trying to use MSI installers for my application.
With the following installer Properties, the installer should overwrite the old files when new installer version is started on the client's machine:
- RemovePreviousVersions = true
- Version = larger than in previous installer version
- ProductCode = changed for every installer version
- UpgradeCode = preserved for all installer versions
Now this does not ovewrite the application file when installed. It keeps the old application file even if the new installer completes. That was not expected.
The issue was that AssemblyFileVersion needs to change in AssemblyInfo.cs of every project in the application whose .dll or .exe needs to be overwritten by the new installer version.
If there are multiple projects, it is impractical to change AssemblyFileVersion in all changed projects by hand each time I want to release a new installer version.
This can be solved by deleting the AssemblyFileVersion and setting AssemblyVersion to format: Major.Minor.* (e.g. 1.0.*)
When AssemblyFileVersion is deleted, it is in fact copied from AssemblyVersion which can be auto-geneated using wildcards.
This will generate AssemblyVersion's Build and Revision fields as "days since 2000" and "seconds since midnight" respectively resulting in a unique build each 2 seconds even if Major and Minor are not updated.
Now this creates an issue that the project build is not deterministic ("Error CS8357 The specified version string contains wildcards, which are not compatible with determinism. Either remove wildcards from the version string, or disable determinism for this compilation" in Visual Studio).
I believe that deterministic builds quicken build times and the impact increases with the number of projects in solution (projects which have not been modified don't have to be rebuilt - am I right?).
A possible solution of the error could be to set the projects to <Deterministic>False</Deterministic>. This will disable the detection of unchanged projects and will result in a rebuild of every project on "Rebuild All" even if their code was not changed in VS and that will be slow in VS if there are a lot of complex projects, right?
Now this article speaks about automatic increment of the version by 1 upon each build of a changed project:
https://learn.microsoft.com/en-us/troubleshoot/visualstudio/general/assembly-version-assembly-file-version ("Providing a () in place of absolute number makes compiler increase the number by one every time you build.")
How can that be achieved? Is the documentation page wrong? I suppose that the wildcard () will result in the behavior of "days since 2000" and "seconds since midnight" which I described before.
Is there any way to have both automatical MSI installer updated projects (must be done via AssemblyFileVersion) support and determnistic build?
Could you please provide a post-build event which will allow deterministic build but will update AssemblyFileVersion for each build?
Is there a way to achieve that without post-build events in Visual Studio?
Thank you!