How to ignore only one line in svn?

I have a line of code in the configuration file:

<appSettings> <add key="Microsoft.ServiceBus.ConnectionString" value="Endpoint=sb://{ComputerName}/ServiceBusDefaultNamespace;StsEndpoint=https://{ComputerName}:9355/ServiceBusDefaultNamespace;RuntimePort=9354;ManagementPort=9355" /> </appSettings> 

and you can see {ComputerName} there. This name depends on the current computer name. And if I use any source code management tool, I get a problem because in another computer project it does not start with my connectionString.

How can I avoid this problem?

I cannot ignore this file in svn because I will change in the future and I may lose these changes.

Perhaps this problem can be solved at the svn level or in visual studio.

+4
source share
3 answers

You can use localhost instead of the computer name or have this placeholder and replace it at runtime.

Or you can put this key in a separate configuration file that is not included in the source code:

 <!-- In your regular app.config/web.config --> <appSettings file="user.config"> <!-- You can have normal stuff here --> </appSettings> <!-- In a file called user.config --> <appSettings> <add key="whatever" value="JoesMachine" /> </appSettings> 

user.config will not be in the source control at all, just need to live on each user's machine. This is an additional step when creating a new developer, but it may work for you. (If this is a Windows application and not a web application, make sure that you set Copy to Output Directory to copy Always on user.config to the project, so it will end up in the bin directory.)

+2
source

You cannot ignore one line.

Usually, when you have a configuration file that should be changed by everyone, you use this approach .

Since you are using Visual Studio, you can avoid this by creating various configurations for your collections and using them to modify the final configuration files during build.

+2
source

Have the placeholder text in the config, as it is now, and in the initialization of the code, use Environment.MachineName to replace the placeholder text. I would go so far as to designate the placeholder text as a configuration parameter, so you never encode it.

+1
source

All Articles