How to strong name assemblies when publishing to a single file (.exe) in Visual Studio

174 views Asked by At

I'm writing a desktop application in .NET 6 and using the User Settings feature to store some persistent configuration values. Because the application is portable, I sign the assembly with a strong name, so that if the executable changes location the user settings are still the same (like explained here). I use strong naming in Visual Studio with the following configuration:

strong naming settings

Then I publish the application to a folder via Visual Studio with the following profile settings:

publish profile settings

If I run the application, the user settings are saved with its path as identifier instead of the strong name.

But if I publish the application without the 'Produce single file' option activated, it will output the DLL's, runtime config and executable separately. If I run the application now, then the user settings are saved with the strong name as identifier.

Also, if I verify the files with the Strong Name Tool (sn -v) via the Visual Studio Developer Command Prompt, the DLL's are valid (the executable is not, but I think that is expected).

I expected the same when publishing to a single file. What changes with this option? And how do I get the same result as publishing to separate files?

0

There are 0 answers