Search code examples
.netvisual-studio.net-assembly.net-5

Assembly for .NET core 5.0 and application version control


Using Visual studio 2019 Preview and .NET 5.0, Packaging MSIX In the process of releasing an application I noticed that my settings was not carried over between publishes. So if you type in an APIkey you would have to retype it if I were to push a update. These settings are stored in Settings.cs and works perfectly every time you run the program if a new version is not pushed.

The assembly file is nowhere to be found so i can not find a way to access [assembly: AssemblyFileVersion("1.0.0.0")]. Not under properties -> Application (No button there). Not when searching all files for "AssemblyFileVersion" or "1.0.0.0" or "Assembly".

My objective would be to use the following code to update the settings with previous settings (Upgrade being in settings.cs and a bool)

private void SettingsLoadedEventHandler(object sender, System.Configuration.SettingsLoadedEventArgs e) {
            if(Upgrade == true)
            {
                Upgrade();
                Upgrade = false;
                Save();
            }
        }

More info: The settings are stored in new folders under AppData/Local/(AppName)/(The new folder made each new publish)/1.0.0.0. Last one being the .exe version number in this case.

When I tried making my own assemblyinfo file it said that the properties were duplicates.


Solution

  • My mistake(s) was not creating a project.skd file on signing to get a StrongName. So you would go under project properties -> Signing - check "Sign the assembly" and add new on the drop down (I did not use Password protection here so feel free to leave a feedback on that if somebody attempts it). By again going under properties and package you can set assembly version and file version manually. I have not found a automatic way to increment that. Use the code above in your settings-file generated by clicking view code under settings in properties -> settings (<>View Code is an option on the top bar).

    Hopefully this can help someone else!