Click once not installing appsettings to users machine
Asked Answered
D

1

6

I'm new to using click once when publishing my applications, I've managed to get my application published. However, when I launch the application as a user I'm finding that the app settings file has not been pulled from the server to the user's device. This results in the application falling over on startup.

My question is how when publishing via Click once can I ensure that an app settings Json is copied to the user's machine?

I'm using .net core 3.1 for my application with Microsoft Visual Studio Community 2019 Version 16.8.3 for my IDE for complete context.

Daviddavida answered 15/1, 2021 at 14:25 Comment(0)
G
11

After adding appsettings.json (or any content file) make sure you set the build action to Content and set Copy to output directory to Copy Always (or copy if newer):

enter image description here

Then it will be automatically included as part of the deployment files. To make sure the file will be included in the deployment files, in the ClickOnce setup, in settings step, click on Application files and make sure the publish status is Include (Auto):

enter image description here

Gildea answered 15/1, 2021 at 14:51 Comment(6)
Thank you for taking the time to help me it worked as expected :)Daviddavida
Great! My pleasure :)Gildea
On WPF .NET 5.0 this does not work; the appsettings.json is not copied to the user's computer even with these settings.Hwahwan
@Hwahwan make sure you set the build action to Content and set Copy to output directory to Copy Always (or copy if newer).Gildea
@RezaAghaei I had already made sure that those settings were correct. What ended up being the issue is that, when I set the file to "Copy Always", Visual Studio added the line <ExcludeFromSingleFile>true</ExcludeFromSingleFile> which caused ClickOnce to not copy it to the output folder. When I published with the CLI, the file got copied anyway so I hadn't noticed the issue until I published with ClickOnce.Hwahwan
Good to hear that you have solved it. Take a look at this link as well: github.com/dotnet/sdk/issues/3469#issuecomment-516646041Gildea

© 2022 - 2024 — McMap. All rights reserved.