I have been using VS 2015 and like the Class Diagram item. I recently upgraded to 2017 and can't seem to find the Class Diagram item. Anyone know how I get to it?
This question is related to
c#
visual-studio-2017
VS 2017 Professional edition- Go to Quick launch type "Class..." select Class designer and install it.
Once installed go to Add New Items search "Class Diagram" and you are ready to go.
In addition to @ericgol's answer: In the French version of Visual Studio Community 2017, type "Concepteur de classes" in the search bar.
the following procedure worked for me:
You need to install “Visual Studio extension development” workload and “Class Designer” optional component from the Visual Studio 2017 Installer to get the feature.
See: Visual Studio Community 2017 component directory
But this kind of item is not available on all project types. Just try for yourself:
In a Console App (.NET Framework) is available;
In a Console App (.NET Core) is not available.
I couldn't find more info on future availability also for .NET Core projects.
Open Visual Studio Installer from the Windows Start menu, or by selecting Tools > Get Tools and Features from the menu bar in Visual Studio.
Visual Studio Installer opens.
Select the Individual components tab, and then scroll down to the Code tools category.
Select Class Designer and then select Modify.
The Class Designer component starts installing.
For more details, visit this link: How to: Add class diagrams to projects
I am using VS 2017 Enterprise, you can find an option to install the class diagram extension using he Quick Launch in VS.
Woo-hoo! It works with some hack!
According to this comment you need to:
Manually edit Microsoft.CSharp.DesignTime.targets
located in C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\VisualStudio\Managed
(for VS Community edition, modify path for other editions), append ClassDesigner
value to ProjectCapability
(right pane):
Restart VS.
MyClasses.cd
with following content:
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>
Bingo. Now you may open this file in VS. You will see error message "Object reference not set to an instance of object" once after VS starts, but diagram works.
Checked on VS 2017 Community Edition, v15.3.0 with .NETCore 2.0 app/project:
GitHub issue expected to fix in v15.5
Noticed this in the beta and thought I had a bad install. The UI elements to add new Class Diagrams were missing and I was unable to open existing *.cd Class Diagram files in my solutions. Just upgraded to 2017 and found the problem remains. After some investigation it seems the Class Designer component is no longer installed by default.
Re-running the VS Installer and adding the Class Designer component restores both my ability to open and edit Class Diagrams as well as the UI elements needed to create new ones
A further note on Dmitry's 2017 answer. I opened up
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\MSBuild\Microsoft\VisualStudio\Managed\
Microsoft.CSharp.DesignTime.targets
and went to the <ProjectCapability>
element. I already had this:
<ProjectCapability Include="
CSharp;
Managed;
ClassDesigner**;**" />
with ClassDesigner already there, and yet I was still unable to drag items to my hack-made Diagram.cd using the XML editing method Dmitry mentioned (
Manually create text file, say MyClasses.cd with following content:
<?xml version="1.0" encoding="utf-8"?> <ClassDiagram MajorVersion="1"
> MinorVersion="1">
> <Font Name="Segoe UI" Size="9" /> </ClassDiagram>
). But when I took off the semicolon off 'ClassDesigner' in that element then reopened Visual Studio, voila, I was able to drag classes from my Solution Explorer to my Diagram.cd window.
So in conclusion, this element in Microsoft.CSharp.DesignTime.targets
worked:
<ProjectCapability Include="
CSharp;
Managed;
ClassDesigner" />
I am using VS 2019, version 16.1.5.
Source: Stackoverflow.com