I have a project which has the following in its .csproj file:
<AssemblyVersion>1.0.0.3</AssemblyVersion>
<FileVersion>1.0.0.4</FileVersion>
When right clicking and selecting properties for that project, I see the same information in the properties window, and both the properties window and the text file are reflecting changes properly when viewing the other way. However, after compiling and checking the properties -> details in file explorer, it shows 0.0.0.0 for file version.
Furthermore, on startup the application is adding the file version to the form's text:
Text = $"{Assembly.GetExecutingAssembly().GetName().Name} {Assembly.GetExecutingAssembly().GetName().Version}";
That information is also showing as 0.0.0.0 when running the application.
I'm not aware of any other places I can view or edit this information besides manually editing the csproj file or changing it on the project properties window, so I don't know what has gone wrong here.
I tried to reproduce this by creating another project and messing with manually changing those settings, but no other projects are showing this issue. It seems visual studio compiler is doing "something" behind the scenes that isn't directly visible to the users, but I have no idea what that "something" is. I've tried changing the numbers on both projects, and the one project always updates as expected and the other is just always zeroes.
It may be relevant that the "bad" project has been converted recently from .net framework 4.7.2 to .NET 8.0 using upgrade assistant, but since there's no documentation suggesting FileVersion or AssemblyVersion exists anywhere else, there's no way for me to see how that could be relevant (if it is).
I have seen some comments elsewhere that I could potentially modify the project to use an old-style assemblyinfo.cs file, but that seems like a workaround more than a fix or explanation of what is wrong with the intended usage, and this project does not currently have an assemblyinfo.cs file even after being converted. The conversion deleted the old file. Though I'm wondering if the compiler thinks for some reason that there is one. GenerateAssemblyInfo is also set to false.
Some documentation sources that describe the versioning but nothing on this issue: https://learn.microsoft.com/en-us/dotnet/standard/library-guidance/versioning How to specify the assembly version for a .NET Core project?
Am I missing something here? This is VS22 professional on 64bit windows 11 and compiling a .NET 8.0 project. If there's any other information needed here let me know and I'll be happy to provide whatever else is needed.
I figured this out after a couple more hours of investigating.
The problem was indeed .NET upgrade assistant. When upgrading from .NET framework 4.7.2 to .NET 8.0, upgrade assistant had set GenerateAssemblyInfo to False in the csproj file, but then deleted the assemblyinfo file and put the fileversion and assemblyversion into the csproj file instead.
I have no idea why it did that, but after deleting the GenerateAssemblyInfo False line (could also set it to true, but true is the default) the compiler was properly reading the csproj file for the assembly version information.
You could also manually copy/paste the old assemblyinfo file contents into a random file in your application as that apparently works now (I had placed it at the top of the Form1.cs file), but I think the intention going forward is to have that placed in the csproj file as propertygroup items. Copying the old assemblyinfo lines could lead to confusion later (and in fact could cause exceptions in some cases).
Honestly I think the compiler should warn about this missing information, but for now it doesn't, so it's something to be careful of.