Can not open Visual Studio .Net 2003 project once added to SVN- Problem Resolved

This is an issue that has haunted me when I first started to use SVN, and it took me sometime to figure out why it is happening and how to get around it.

After first switching to SVN from visual source safe, I added all my .Net 2003 projects to SVN, but after I’ve added them in, a few days later, somehow mysteriously the project doesn’t open anymore and just displays the error message “Refreshing the project failed, unable to retrieve information from the server.” After some googling, I found the reason and the fix for it.

Basically there is a problem with .Net 2003, with SVN, basically it keeps track of what has changed by placing hidden folders and files in the .net project folder, the problem is these files starts with a “.”, and .Net 2003 doesn’t like it. So once it sees a folder with a “.” starting as the name, it just craps out.

The solution? rename the svn folders to something else, and then rename it back again.

So here is what you can do, first open notepad, and copy the following code to the notepad

@ECHO OFF
FOR /R %%f IN (.svn) DO IF EXIST “%%f” (
ATTRIB -h “%%f”
RENAME “%%f” _svn
)

Save the file with the name of hide.cmd, so it can run as an executable in windows.

Open a new notepad and copy the following code into the notepad

@ECHO OFF
FOR /R %%f IN (_svn) DO IF EXIST “%%f” (
RENAME “%%f” .svn
ATTRIB +h “%%~pf\.svn”
)

Save this file as restore_svn.cmd.

Place the hide and restore_svn files in the root folder of the project, normally this would be C:\Inetpub\wwwroot\projectname\

Basically the hide script will rename all the folder and files starting with the “.” to starting with a “_”, and the restored will rename it back.

So to use these scripts, before opening the .net project, run the hide.cmd file, then open the .net project, the error should have disappeared. Once the .net project has loaded in Visual Studio, run the restore_svn.cmd file, and rename the files back, so that we can still use SVN to keep track of the changes.

Just a note this problem was resolve in Visual Studio .Net 2005 so you won’t need the work around for that.

Advertisements

3 Responses

  1. Lisa-

    Instead of having the user run a script each time they need to open a project in VS ’03 and then run another script in order to commit their changes to version control, it is a lot easier to simply change the TortoiseSVN settings. If you right click on any folder under version control, goto the TortoiseSVN Menu, and click on “Settings”, you can place a check in the box that says “User _svn instead of .svn for directories”. Then simply click Apply and OK. That way everything is permanently changed and will load in VS ’03 without any issues and still be under version control. No scripts necessary.

    If you should have any further questions please feel free to contact me directly. Thank you and have a great day!


    Jason Salzman
    jsalzman@kitsolutions.net

  2. Thanks Jason, I didn’t know that function existed till now.

  3. Thanks for the script. I modified it to combine it into one script to toggle the .svn folders (lets see if this’ll paste right):

    @ECHO OFF

    IF EXIST .svn (
    ECHO “Renaming .svn folders to _svn (hiding SVN temporarily)”
    FOR /R %%f IN (.svn) DO IF EXIST “%%f” (
    ATTRIB -h “%%f”
    RENAME “%%f” _svn

    )
    ) ELSE (
    ECHO “Renaming _svn folders to .svn (fixing SVN to work again)”
    FOR /R %%f IN (_svn) DO IF EXIST “%%f” (
    RENAME “%%f” .svn
    ATTRIB +h “%%~pf\.svn”
    )
    )

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: