简体   繁体   中英

Solution does not recognize csproj as c# project

We have large solutions that have both vb and c# projects. We're on the path of converting some of vb to c#. After the conversion, when solution is opened using vs2017 project is still shows as vb. We can build it but code is unusable. We have the fix - remove project from solution and re-add it. Voila - it shows as csproj. But this creates new issue - since we're using DLL references, we have to manually set build order. Build order is broken when project is removed.

My thinking was that solution must be caches something somewhere. I removed .vs , cleaned solution, removed all obj folders, no matter what I cleaned out, until you re-add project, ac# project shows as vb project. I also checked c:\\users\\username\\... for any files that can relate to my solution and found nothing.

I hate do re-add and fix build order many times (conversions will not happen all at once). Why VS is not recognizing file right-away? After re-add, project file is not changed and solution doesn't have any sign of something different.

在此处输入图片说明

Found the issue

The GUID in solution file is actually project type GUID.

Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "projectname", "projectname.vbproj", "{7CC2FC9A-0D8F-4A26-A891-80B1D20C773D}"
EndProject

Above, Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") is project type GUID; and "{7CC2FC9A-0D8F-4A26-A891-80B1D20C773D}" is project ID GUID.

So, when in solution we change extension vbproj to csproj , we also need to change GUID with correct one. This solves the issue.

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