How can I specify my app to not overwrite the app.config on the client machines when the app is updated by clickonce?
当clickonce更新应用程序时,如何指定我的应用程序不会覆盖客户端计算机上的app.config?
4 个解决方案
#1
if i am not mistaken you need something like this
如果我没有弄错你需要这样的东西
Persisting app.config variables in updates via Click once deployment
通过单击一次部署在更新中保留app.config变量
#2
Background
I asked in the question's comments if users were manually editing the app.config file on their machine after deployment. The original poster responded that they are doing that.
背景我在问题的评论中询问用户是否在部署后手动编辑其计算机上的app.config文件。原始海报回复说他们正在这样做。
Answer
It looks like the poster wants ClickOnce to deploy the app.config file initially and then not deploy it with future updates to the application. This is a bad misuse of ClickOnce. I don't think there's an easy way to do it, and even if there were I would advise against it. What if in the future you want to add a new setting to your app.config file? How will users get that new setting if the app.config is no longer being updated on their machine?
回答看起来海报希望ClickOnce最初部署app.config文件,然后不将其与应用程序的未来更新一起部署。这是对ClickOnce的误操作。我认为没有一种简单的方法可以做到这一点,即使有我会建议反对它。如果您将来要为app.config文件添加新设置,该怎么办?如果app.config不再在其计算机上更新,用户将如何获得新设置?
What I would do instead is store the connection strings as UserSettings. That's exactly what user settings were made for, things that vary from user to user. On top of that, I would probably provide them with a simple form to edit those settings. It would make me nervous having all my users mucking around with their installation files.
我要做的是将连接字符串存储为UserSettings。这正是用户设置的用途,因用户而异。最重要的是,我可能会为他们提供一个简单的表单来编辑这些设置。让我的所有用户都不知道他们的安装文件会让我感到紧张。
#3
Move your settings to a different config for each environment you deploy to such as:
将您的设置移动到您部署的每个环境的不同配置,例如:
app.development.config
app.staging.config
app.production.config
app.development.config app.staging.config app.production.config
Keep all the settings common to these in your app.config
在app.config中保留这些常用的所有设置
#4
Are you trying to preserve settings during an update? If so, look at the application and user settings (in the properties of your project). They are not overwritten during each update.
您是否尝试在更新期间保留设置?如果是这样,请查看应用程序和用户设置(在项目的属性中)。每次更新时都不会覆盖它们。
#1
if i am not mistaken you need something like this
如果我没有弄错你需要这样的东西
Persisting app.config variables in updates via Click once deployment
通过单击一次部署在更新中保留app.config变量
#2
Background
I asked in the question's comments if users were manually editing the app.config file on their machine after deployment. The original poster responded that they are doing that.
背景我在问题的评论中询问用户是否在部署后手动编辑其计算机上的app.config文件。原始海报回复说他们正在这样做。
Answer
It looks like the poster wants ClickOnce to deploy the app.config file initially and then not deploy it with future updates to the application. This is a bad misuse of ClickOnce. I don't think there's an easy way to do it, and even if there were I would advise against it. What if in the future you want to add a new setting to your app.config file? How will users get that new setting if the app.config is no longer being updated on their machine?
回答看起来海报希望ClickOnce最初部署app.config文件,然后不将其与应用程序的未来更新一起部署。这是对ClickOnce的误操作。我认为没有一种简单的方法可以做到这一点,即使有我会建议反对它。如果您将来要为app.config文件添加新设置,该怎么办?如果app.config不再在其计算机上更新,用户将如何获得新设置?
What I would do instead is store the connection strings as UserSettings. That's exactly what user settings were made for, things that vary from user to user. On top of that, I would probably provide them with a simple form to edit those settings. It would make me nervous having all my users mucking around with their installation files.
我要做的是将连接字符串存储为UserSettings。这正是用户设置的用途,因用户而异。最重要的是,我可能会为他们提供一个简单的表单来编辑这些设置。让我的所有用户都不知道他们的安装文件会让我感到紧张。
#3
Move your settings to a different config for each environment you deploy to such as:
将您的设置移动到您部署的每个环境的不同配置,例如:
app.development.config
app.staging.config
app.production.config
app.development.config app.staging.config app.production.config
Keep all the settings common to these in your app.config
在app.config中保留这些常用的所有设置
#4
Are you trying to preserve settings during an update? If so, look at the application and user settings (in the properties of your project). They are not overwritten during each update.
您是否尝试在更新期间保留设置?如果是这样,请查看应用程序和用户设置(在项目的属性中)。每次更新时都不会覆盖它们。