问题
I've installed the "ASP.NET and Web Tools 2013.1" in my Visual Studio 2012.
I have a solution which has an ASP.NET MVC 4 project with the following project type guids:
<ProjectTypeGuids>
{E3E379DF-F4C6-4180-9B81-6769533ABE47};
{349c5851-65df-11da-9384-00065b846f21};
{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
</ProjectTypeGuids>
These Guids are for: ASP.NET MVC 4.0 Web Application Windows (C#)
This is the usual configuration when you create a new ASP.NET 4.0 project. And it works fine.
The problem is that, for some strange reason, whenever I open my solution the first GUID (ASP.NET MVC 4.0) is deleted from the .csproj file, so I lose all the related tooling.
No matter how I try to edit it:
- if I close the solution, and edit this file manually, adding the missing GUID, when I open it again, the GUID is deleted
- if I unload the project, edit the .csproj and reload it, the GUID is also deleted.
- I have this project under version control (SVN), so I have also tried closing VS, updating the file in the SVN (using Tortoise) and reopening the solution. And you know what? The GUID is deleted when opening the solution !!!
If I create a new solution with an ASP.NET MVC 4.0 project, it works fine, and the GUIDs are kept.
Any idea why this can be happening and how I can solve it?
UPDATE
If I open VS in safe mode this doesn't happen. SO I suspect it must be an extension, but I don't know how to discover which is the offendign extension. Is there a way to know which extension can be responsible for this (apart from uninstall/try cycles...)
回答1:
I found a temporary workaround hack for this problem:
- Right click on the MVC project in Visual Studio and select "Unload Project"
- Right click on the project and select "Edit YourProjectName.csproj"
Replace the contents of the ProjectTypeGuids tag with the following and save the file changes:
{E3E379DF-F4C6-4180-9B81-6769533ABE47};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
Open up Window Explorer and find the csproj file. Open up properties on it and mark it as Read Only.
- In Visual Studio right click on the project and select Reload Project. You will be prompted to save as the csproj file. Hit Cancel when that comes up.
- Go back to Windows Explorer and take off the Read Only flag.
As long has you have this project open in Visual Studio, it will think it's an MVC project, and you will have options to Add Views and Controllers. Once you switch projects or restart Visual Studio, you'll have to do this again.
来源:https://stackoverflow.com/questions/22251165/vs2012-projecttypeguids-lost-when-opening-after-installing-asp-net-and-web-tools