Copy app.config for deployment
If I have projects that are deployed by copying files (executables, dll's and data files) to their destination folder, is it correct that I can ommit copying the app.config-file (executableName.config
) because it will created anyway on the first app startup per user in the users loc开发者_开发技巧al storage?
Or otherwise asked, is it right, that the app.config (executableName.config
) in the exeutables directory /bin/debug
or /bin/release
is only for debuging purposes there and could be deleted without any implications?
I have tested and used this without problems so far (deleting and not deploying the config file) but maybe there exist some side effects that are not obvious at the first glance?
My understanding from this article is the [AppName].exe.config file will be merged with the other configuration files (eg Machine.config, User.config) when configuration is requested by the code.
Thus, if you don't have any configuration and choose to omit the exe config you shouldn't have any issues.
The exe config is not used for debugging purposes.
The pdb files are for debugging and not the config file. Config files are for configuration. Since you are already creating it per user on startup, hence you can delete it.
There is no side effect of keeping the app.config file in some other location. Sometimes this is desirable. For instance you need to share app.config file between your projects then you can keep this file in the solution folder and use it in all three projects.
I've never seen .config
files generate themselves before. The most common approach is to use the application deployment framework
which takes the .config file used for development and modifies it based on the environment you're deploying to. Eg in our project we have:
web.config
web.development.config
web.testing.config
web.production.config
web.config has everything in it, the others contain transforms eg...
web.config
<connectionStrings>
<clear />
<add name="MyConnectionString" connectionString="<Dev connection string>" providerName="System.Data.SqlClient" />
</connectionStrings>
and in web.production.config
<connectionStrings>
<add name="MyConnectionString"
connectionString="<Production connection string>"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
So when I publish to production using the publish tool, it modifies my config file on-the-fly.
For more information, google AppDeploy
Hope this helps?
精彩评论