Solution Files: Change Project Directory Location

Posted Wed, Jun 30 2010 16:21 by Deborah Kurata

Renaming or moving files in Visual Studio is never an easy task. But one of the lesser known enhancements in Visual Studio 2010 is the ability to change the directory location of a project.

Here is the scenario. The team decides that the projects need to be renamed. To keep things consistent, the directory file locations for those projects are also renamed. In this example, the projects and project folders were all renamed to include a prefix of "ACM."

image

So now you open the project and get this:

image

Notice that all of the projects are marked as "unavailable". This is because the solution file contains a path to each of the projects and that path is not longer correct because it was renamed.

In prior versions of Visual Studio, you would then need to manually edit the solution file to fix these issues. But Visual Studio 2010 provides an editable File path property. So you can edit the location of the files directly from within Visual Studio.

Select the project to update. Then view the Properties Window. Click on the … icon in the File path property to edit the project path and/or file name.

image

NOTE: The File path property is ONLY available for edit if the project is shown as "(unavailable)" in the Solution Explorer. In all other cases, the File path property is read-only.

After you are finished editing the path, right-click on the project in Solution Explorer and select Reload Project.

This is much easier (and less error prone) than hand-editing the project file.

Enjoy!

EDIT: Added a note to make it clear that this is ONLY available if the project is defined as "unavailable". Otherwise the File path property is read-only.

Filed under: , , , ,

Comments

# re: Solution Files: Change Project Directory Location

Wednesday, July 07, 2010 11:23 AM by bug

When I do this, the properties for the project are simply unavailable and there's no way to edit the path.

# re: Solution Files: Change Project Directory Location

Wednesday, July 07, 2010 1:21 PM by Deborah Kurata

Hi "bug" -

I edited the post to make this more clear. It *only* works if the project is defined as "unavailable". Otherwise this field is read-only.

Is that the issue? Or do you have some other scenario?

# re: Solution Files: Change Project Directory Location

Thursday, January 20, 2011 5:30 AM by Robin

Hello,

I found you nice instruction on how to solve directory changes. I know this solution from VS 2008, but in 2010 the "File Path"-property ALWAYS is read-only although my project is "unavailable" ...

Do you know about this problem?

Thx, Robin

# re: Solution Files: Change Project Directory Location

Monday, March 21, 2011 9:57 AM by Ariel Lishu

Hi, maybe you can help me.

I have installed the VS2010 and i am having a problem.

All my documents are in the Z: Drive.

The problem is when i create a project and the manager ask me, where i want to save it.

Just the C and D drives are available.

Can you help me to solve this?

Thanks!

# re: Solution Files: Change Project Directory Location

Thursday, March 31, 2011 11:29 PM by Mohan

If you are using TFS,

Go to View -> Other Windows -> Source Control Explorer

Select your folder containing the soultion file

Select Add items to folder -> This opens up a Add to Source control window with list of your projects in the folder

Add project which your want

Checkin the files into TFS

Get the latest using solution explorer

Hope this helps

# re: Solution Files: Change Project Directory Location

Tuesday, June 21, 2011 4:58 AM by dave

hi,

i've a vs2010 asp.net project copied from another computer to my laptop. when i click on any commandbutton server control, a popup say 'unable to complete the task' and the code-behind file does not open. also, if i make any change to the controls, errors occur on build and the build is unsuccessful. pls help..

# re: Solution Files: Change Project Directory Location

Wednesday, September 07, 2011 10:12 AM by Mike

Thanks for this as I was really struggling to find the place to do that. Why does Microsoft always insist on hiding these things! I was needing to make a duplication of a project but using a different company name!

Thanks for making a note of this as just saved me having swear a lot more :)

Leave a Comment

(required) 
(required) 
(optional)
(required) 
If you can't read this number refresh your screen
Enter the numbers above: