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."
So now you open the project and get this:
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.
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.