views:

354

answers:

4

I have a web.config that occasionally I'll checkout and modify to use a hardcoded password instead of reading it from the registry.

How can I prevent myself from absent-mindedly checking it back in and annoying my co-workers?

I could achieve this in the past with Perforce by creating a separate pending changelist.

edit - I'd rather not make it writable, I was wondering if there's anything in TFS or planned for TFS to support this?

+5  A: 

Option 1: You could just make the web.config writeable locally without checking out (this would be helped by setting VS to prompt for checkout).

Option 2: Move the password out of the web.config. Using a configSource attribute to put that configuration into a local, not in TFS, file. Each developer then maintains their own copy.

E.g. in web.config:

<configuration>
  ...
  <connectionStrings configSource="LocalConnectionStrings.config"/>
</configuration>

and in LocalConnectionStrings.config:

<connectionStrings>
  <add name="MyConnectionString"
    connectionString="Data Source=.;Initial Catalog=Test1;Integrated Security=True"
    providerName="System.Data.SqlClient"/>
</connectionStrings>

NB. configSource is implemented by ASP.NET's config runtime and is supported on all configuration elements for ASP.NET (and, thus, not for arbitrary (including custom) configuration elements).

(Also note the <linkedConfiguration> Element provides anothe include mechanism, but is limited to assemblyBinding element.)

Richard
A: 

How about not doing a checkout of the file and just alter the file localy?

Lieven
+2  A: 

Here is a solution:

1) Right click on the file (in Source Control Explorer) and select properties.

2) Then go to security and add your self (make sure you select the user radio button)

3) Then deny yourself checkin rights. (Click the deny checkbox under checkin)

This will stop you from checking in the file. To be able to check it in later just do these steps again, but select the Allow check box.

Note: you may need to get your administrator to give you "Manipulate Security Settings" for that file (done the same as above, but in step 3 select allow under "Manipulate Security Setting".)

Vaccano
If I have the Manipulate Security Settings then this could be the best way. Will update tomorrow. thanks
koregan
+1 for an interesting idea.
Chris Lively
A: 

Source controlled items by TFS use the 'Read Only' attribute of the file to evaluate file status. You can go to the physical folder where the web.config exists in your machine through the explorer. Make sure your web.config is checked in before you begin. Then :

  1. Right click on the web.config file and select 'Properties'
  2. Uncheck the 'Read Only' checkbox. Click Ok/Apply
  3. Edit your web.config in notepad or other text editor and save the changes
  4. Right click on the web.config file and select 'Properties'
  5. Check the 'Read Only' checkbox. Click Ok/Apply

You would have to do a get specific on the file to get any changes from TFS after that.

AT

Console.WriteLine