Visual studio 2017 not treating csproj as a valid project file after conversion from netstandard to framework

10

The following was done in VS Enterprise 2017 15.8.2. I had converted a .NET Framework project (C#) into netstandard and then had to convert it back due to a build issue. The conversion was done by restoring a previous commit from git. However, now VS does not recognize the project as a valid project. The linked unit test project generates the warning

the referenced component '< project name >' could not be found.

Attempts to view the project properties produces the error

An error occurred trying to load the project properties window. Close the window and try again. Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))

The build selection options disappear from the build menu and the build/debug options are gone from the project context menu. The dependencies node of the solution explorer is empty. I have seen other posts in which people describe a similar condition that is resolved by either reopenning the solution or changing the mode of vs to a different type of development or deleting bin/obj. None of these worked, nor a full reboot. Given that this project file used to be framework I suspect there is something cached somewhere that is covered by my .gitignore which needs to be deleted.

visual-studio-2017
asked on Stack Overflow Sep 4, 2018 by Tedford

2 Answers

22

Ran into the same issue myself. Appears to be an issue with the solution file. I removed the project from the solution then added it back again. This cause VS to recognize this as the correct project type. Hope this helps somebody else from spending too much time on this issue.

answered on Stack Overflow Feb 6, 2019 by bbent
5

Low level alternative to @bbent. Results in the same end result.

Open the sln file with a text editor and specify the matching PROJECT-TYPE-GUID for your project. the format is:

Format:

Project("<PROJECT-TYPE-GUID>") = "<proj name>", "<proj file path>", "<unique project guid>"
EndProject

Example for Classic C# Project:

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibOne", "LibOne\LibOne.csproj", "{D5590E95-BFCC-4939-9D15-685D25B6BBE7}"
EndProject

Example for netcore, respective SDK-Style Project:

Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibTwo", "LibTwo\LibTwo.csproj", "{D5590E95-BFCC-4939-9D15-685D25B6BBE7}"
EndProject

The project-type-guid is a GUID (defined my MS) which stands for ('c#', 'c++', 'xna', 'folder', 'web site', etc).

excerpt:

C#          {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
folder      {2150E333-8FDC-42A3-9474-1A3956D46DE8}
core        {9A19103F-16F7-4668-BE54-9A1E7A4F7556}
wpf         {60DC8134-EBA5-43B8-BCC9-BB4BC16C2548}

There's nothing official from microsoft though! The complete list is probably only in the Visual Studio sourcecode. But the IDs don't change, at least not in the last decade.

answered on Stack Overflow Jan 6, 2020 by juwens • edited Feb 26, 2020 by juwens

User contributions licensed under CC BY-SA 3.0