Answer the question
In order to leave comments, you need to log in
How to properly set app.config in VisualStudio when using GIT?
There is a WPF project, a desktop application.
It contains 3 files with local paths to servers/files, they are different on each machine of programmers:
BuildTestingProject\app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="BuildTestingProject.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<BuildTestingProject.Properties.Settings>
<setting name="Path1" serializeAs="String">
<value>Тестовый путь к локальному файлу при разработке</value>
</setting>
<setting name="Server1" serializeAs="String">
<value>Путь к локальному серверу при разработке</value>
</setting>
</BuildTestingProject.Properties.Settings>
</userSettings>
</configuration>
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="BuildTestingProject.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="Path1" Type="System.String" Scope="User">
<Value Profile="(Default)">Тестовый путь к локальному файлу при разработке</Value>
</Setting>
<Setting Name="Server1" Type="System.String" Scope="User">
<Value Profile="(Default)">Путь к локальному серверу при разработке</Value>
</Setting>
</Settings>
</SettingsFile>
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace BuildTestingProject.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Тестовый путь к локальному файлу при разработке")]
public string Path1 {
get {
return ((string)(this["Path1"]));
}
set {
this["Path1"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Путь к локальному серверу при разработке")]
public string Server1 {
get {
return ((string)(this["Server1"]));
}
set {
this["Server1"] = value;
}
}
}
}
Answer the question
In order to leave comments, you need to log in
This is more of an organizational issue.
Proposed solutions:
1. Give programmers a hat, tk. refuse to turn on the head.
2. Make a single custom config
2.1 Make a test remote server that the config looks at.
3. Locally on his computer, the developer has the right to do anything, provided that it does not get into the repository and does not harm others
4. For the mess in the code, making confusion, refusing to turn on the head - anal punishments and mass executions.
As an option: put that part of the config, in which all sorts of paths are written, into a separate file. And in the main config, just use the link to this file. After that, it is necessary that each of the developers exclude this file (assume paths.config) from updating the git with the command git update-index --skip-worktree paths.config. Now this file can be changed locally and its changes will not be tracked.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question