Class Diagrams in VS 2017 - c#

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?

Using VS2017 Enterprise:
Go to the Quick Launch Bar (top right) Ctrl + Q
Type "Class Designer" and an install link will pop up
Click install, restart, and your off to the races... Enjoy!

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

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.

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.
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>
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

the following procedure worked for me:
Close VS.
Run Visual Studio Installer.
Click on the 'Modify' button under 'Visual Studio Professional 2017'
In the new window, scroll down and select 'Visual Studio Extension Development' under 'Other Toolsets'.
Then on the right, if not selected yet, click on 'Class Designer'
Click on 'Modify' to confirm

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.

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.

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.

Related

Visual Studio : can't find "resource file" in list of items to add to project

I'm on VS Community 2017 RC.
I'd like to add a resource file (.resx) to my project but this item type is not listed in the items
Have I missed something ? Do I need to install anything on top of my Visual Studio to be able to manage resource files ?
At the top right corner you have a searchbox, try typing it there and see if it finds anything.
If it doesn't, create a text file from the new item dialog and change the extension to
resx
It should now open the new file with the resources designer. Now open the properties pane for that file (right click it in the solution explorer) and make sure it has the following set:
Build Action: Embedded resource
Custom tool: ResXFileCodeGenerator (or PublicResXFileCodeGenerator to generate a designer class with public visibility)
NOTE:
According to the link Chris posted, my suggestion may not help if you have the express edition of visual studio.
Visual Studio Express editions do not support Resource View's. It is commonly recommended that you make your way to the Visual Studio Community editions to take full advantage of such features.
Here is the MSDN link that notes the feature not being supported.
Additionally, maybe you can try this:
Right click your project and go to properties >
Click 'Resources' > and then you may see:
"This project does not contain a default resources file. Click here to create one."
Some Visual Studio 2017 and 2019 workloads apparently don't include this feature, notably the ASP.NET workload. The solution, as detailed here, is to run the Visual Studio Installer and add the desktop development workload.
Using VS 2015 Enterprise Edition, had this problem when I downloaded from our Git repository at work. Nobody knew what happened to those ".resx" files.
I edited in Notepad++ the other (not missing ones) .resx files and found they all had the very same content. So I created new .resx files from scratch with that same content, reopened the solution and Build and Rebuild Solution worked like a charm.

Unity solution not compatible with visual studio

Since updating to the most recent version of Unity 5.4.0f3, whenever I doubleclick on a script, it launches both Visual Studio and Monodevelop, but I get an error saying that the this version of VS (Community 2015) is unable to open my project. Monodevelop displays it's own, somewhat less clear error message. Please see the screen shots below.
I can still manually open my script using Visual Studio's file menu, but the intellisense code completion no longer works. Anyone know how to fix this? I have Visual Studio's Tools for Unity installed.
I was having similar issues when doing a clean download of an existing Unity project onto a fresh install of Visual Studio Community 2019.
In the end the issue for me was that, although the correct version of VS Tools for Unity was installed, it was 'Disabled' by default in VS's Manage Extensions dialog (Extensions -> Manage Extensions). Just had to click 'Enable', restart Visual Studio, and all worked as expected again.
Turns out it was an issue with my existing install of Visual Studio Tools for Unity (VSTU).
I found a thread where users had experienced similar problems due to an unsupported version of VSTU running on Unity5.2 and beyond. Unity 5.2+ requires VSTU 2.1 or later for VS to work correctly with Unity, more information for anyone interested is available in the documentation here.
I had VSTU 2.3 installed, but removing and reinstalling VSTU resolved the issue, so there must have been a problem with my install. If anyone else has this or a similar issue you can download the latest installer for VSTU here. Thanks to all who chimed in your responses helped me look in the right place!
Please try following steps:
Delete old *.csproj and *.sln files on project's root folder
Check "Edit > Preferences > External Tools" and make sure you've selected "Visual Studio"
Re-open solution by "Assets > Open C# Project" menu
For me it was enough to right click the solution in Solution Explorer and run "Resolve errors".
I will complete what is said above. I experienced this issue today and it took me a while. In my case it was relative to a new install of the Unity Editor.
For some unknown reason the unity tool used on VS (intellisense) was uninstalled. I had to reinstall this : open Visual Studio Installer, select your project and reach the Gaming section where reside the tool for Unity.
The extension "Visual Studio 2019 Tools for Unity" seems no longer available for download via the extension manager. Luckily I recalled that I saw some game development features in the Visual Studio installer, so I picked that one:
It works for VS 2019 (16.11.11) and VS 2022 (17.2.0 Preview 1).

Missing Extensiblity Item template on a VSIX project

I have just installed VS 2013 SDK to my computer which runs Windows 7 beside VisualStudio 2013 ultimate.
So I have all Extensibility project templates listed on "Add Project" dialogue box. But there is no Extensibility node hence corresponding Item Template on "Add Item" dialogue box.
I have reinstalled SDK as well as installing Update 5 on Visual Studio but it didn't work.
By the way my project's target framework is 4.5
Do you have any idea what the catch is ?
Visual studio appears to use the <ProjectTypeGuids> list in the *proj file to determine what to show in the add item dialog.
I had the same problem in VS 2017 with a project that was updated from 2013 to 2015 and now to 2017. In the first property group element, see if your project type guids matches this...
<ProjectTypeGuids>{82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
... my project was totally absent this element. You may or may not also need to add <MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion> and possibly others. If the problem continues, try creating a new VSIX project and comparing the two proj files for any other substantive differences.

Templatizing a project in Visual Studio

I have created a windows mobile application in Visual Studio. I want to templatize this project so that one can open this as a template as opposed to a project.
Is this possible in Visual Studio? I read that there is something called as "VSX (Visual Studio Extension)" which may achieve this. I have Visual Studio Ultimate installed in my system and was trying to install the VS2010 SDK. But its not getting installed telling that i dont have MS Visual Studio 2010 which I apparently do.
Am I going in the right direction? If not what would be the correct way to go ?
Yes it is possible like this: File > Export Template than click next :) It will save your code too
This is what I was looking for and it came really handy too.
Export Template Wizard
This exports a project directly as VSIX extension using a wizard.
I would recommend using the TemplateBuilder NuGet package inside of either a VSIX Project or a Visual Studio package. I've created a 6 minute video showing you how you can: Create a VSIX containing a project template, and then editing the template. Checkit out at https://www.youtube.com/watch?v=z33jOo75CH4.
FYI TemplateBuilder is open source at https://github.com/ligershark/template-builder. If you've heard of SideWaffle it relies on TemplateBuilder.

How to remove/uninstall item templates in Visual Studio 2010

I have an item template that I did wrong and want to delete. I deleted the zip file from the output location and ran devenv /installvstemplates and devenv /setup and when I opened VS and tried to add a new item it was still there. stranger still, I can still use it and create copies of the file, so it must exist somewhere. Is there somewhere that visual studio stores the files after being installed that I need to delete? I also cant change the template, it stays the same no matter what I do.
Edit: If it makes a difference I am using XNA GS 4.0
There are several places the Visual Studio might store a template. Deleting the .zip file from any of the locations below should remove it from the list:
%LocalAppData%\Microsoft\VisualStudio\10.0\Extensions
%LocalAppData%\Microsoft\VisualStudio\10.0\ -> ProjectTemplatesCache_{xx}
%UserProfile%\My Documents\Visual Studio 2010\Templates
If the Template was installed via an extension, you can clear it out from the top directory above, or you can follow the official instructions:
Tools -> Extension Manager -> Installed Extensions -> Templates -> YourTemplate -> [Uninstall|Disable]
I finally found out what was happening. For some reason, when VS 2010 installed the templates it copied the zip file to my old 2008 folder. I can't imagine why it would do this but I've put it out there for anyone with the same problem.
Because the duplicate question is really about Visual Studio 2008 (although it contains answers for 2010), I decided to also post the answer for Visual Studio 2010 (found in a comment).
You can find custom templates at the following location:
C:\Users[user]\Documents\Visual Studio 2010\Templates\ItemTemplates
Delete the zip files and they should be removed from Visual Studio.
For those who use VS 2019 or VS 2022, you could also try this:
dotnet new --uninstall <PATH|NUGET_ID>
It works for me in VS 2019 and VS 2020 to uninstall Avalonia templates. Maybe it will work for older VS versions, but I haven't tried.
Description
The dotnet new --uninstall command uninstalls a template package at the PATH or NUGET_ID provided. When the <PATH|NUGET_ID> value isn't specified, all currently installed template packages and their associated templates are displayed. When specifying NUGET_ID, don't include the version number.
Examples
Uninstall the Avalonia templates
dotnet new --uninstall Avalonia.Templates
From MicrosoftDocs

Categories

Resources