简体   繁体   中英

I cannot get projects to load into Visual Studio 2013 with the same name as their directory and I cannot rename the projects in Solution Explorer

I had two problems that don't seem to be addressed anywhere.

A website project whose directory I'd renamed from ProjectB to ProjectA kept loading into a VS 2013 solution as ProjectB after the rename. F2, rt-click and long clicking the project name did not enable me to rename it. I have no csproj file. I deleted all non-source files then imported into a new, empty solution. A full text search of the directory showed the name only in the .suo file, which I'd deleted.

I fixed this (solution below), then imported a website in directory ProjectB into the solution. When I did, it was given the name ProjectB(2) , ProjectB(3) , ProjectB(4) , despite that there was nothing called ProjectB any more. Again I couldn't manually rename to just ProjectB . There was no folder or file that conflicted. I even restarted Windows after deleting the temporary files, but the next time I imported the project, it came in as ProjectB(8) . Solution below.

I then re-opened the same solution on another computer, and ProjectB (in directory ProjectB ) was renamed to ProjectA(2) , despite having never been named that anywhere. Solution below.

[Later edit: If you are getting these problems, first thing I'd try is closing VS2013 and then exiting IISExpress in the system tray, then moving the IISExpress directory:

C:\Users\chris\Documents\IISExpress

(replace with your username) to somewhere different, then opening VS2013 and your solution, which will recreate that directory.]

The first problem was solved by deleting all files that weren't source files or DLLs (sln, suo, etc), deleting all files in C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\Temporary ASP.NET Files , renaming the parent directory of the solution folder, and creating a new solution. Only after all these steps would the project load with the same name as the project directory. (Nothing less than this worked - the project always loaded with the old project name, different to the directory name.) Ie, the solution was to rename a folder ABOVE that of the project.

For example the file structure was originally:

C:\Dev\Client\Solution\ProjectA

(and the project name in VS2013 was ProjectB). I renamed a path above the solution path, ie:

C:\DevXYZ\Client\Solution\ProjectA

Then the project would load into Visual Studio 2013 as ProjectA .

The second problem was IIS Express - it never seems to delete virtual directories. I went to the following file (replace with your username):

C:\\Users\\chris\\Documents\\IISExpress\\config\\applicationhost.config

And deleted all site tags within <sites> , ie,

    <sites>
        <site name="projectname" id="1">
...
        <site name="projectname(2)" id="4">
...
        <site name="otherprojects" id="7">
    </sites>

becomes

    <sites>
    </sites>

I then restarted Visual Studio, re-opened the same solution file that was getting ProjectB(2) , and it loaded as ProjectB .

When I then re-opened the same solution on VS2013 on another computer, initially it renamed ProjectB to ProjectA , then renamed ProjectA to ProjectA(1) . I had to delete the sites in applicationhost.config then re-open the solution, and the projects loaded with their directory names.

I then got an IIS Express error on opening the solution. The solution to this was to close VS2013 and kill IISExpress in the system tray (took a minute to die), then delete the entire IISExpress directory in My Documents . (From this answer Unable to launch the IIS Express Web server )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM