microsoft / ConcordExtensibilitySamples

Visual Studio Debug Engine Extensibility Samples
Other
122 stars 50 forks source link

CppCustomVisualizer doesn't install in VS2019 #52

Closed pps83 closed 4 years ago

pps83 commented 4 years ago

If you build it, resulting CppCustomVisualizer.vsix doesn't install in vs2019. Also, there seem to be x64 versions, but .vsix doesn't build with x64 version.

maxruben commented 4 years ago

Change the source.extension.vsixmanifest file to this and it will install in visual studio professional 2019:

<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
  <Metadata>
    <Identity Id="8F12C6F5-BE35-4DDD-B452-44811F0A3A4D" Version="1.0" Language="en-US" Publisher="Sample" />
    <DisplayName>CppCustomVisualizer Debugger Sample</DisplayName>
    <Description xml:space="preserve">CppCustomVisualizer Debugger Sample</Description>
  </Metadata>
  <Installation InstalledByMsi="false">
    <InstallationTarget Id="Microsoft.VisualStudio.Pro" Version="[14.0, 17.0)" />
  </Installation>
  <Prerequisites>
    <Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0,)" DisplayName="Visual Studio core editor" />
  </Prerequisites>
  <Assets>
    <Asset Type="DebuggerEngineExtension" Path="CppCustomVisualizer.vsdconfig" d:Source="File" />
    <Asset Type="NativeVisualizer" Path="CppCustomVisualizer.natvis"  />
  </Assets>
</PackageManifest>

/Ruben

Edit; It seems like formatting of the xml code isn't preserved properly in the editor.

pps83 commented 4 years ago

use 3 backticks to paste as-is

gregg-miskelly commented 4 years ago

Also, there seem to be x64 versions, but .vsix doesn't build with x64 version.

The x86 solution configuration will build the custom visualizer project for both x86 and x64 and include both in the VSIX. See step 2 from here.

pps83 commented 4 years ago

Also, there seem to be x64 versions, but .vsix doesn't build with x64 version.

The x86 solution configuration will build the custom visualizer project for both x86 and x64 and include both in the VSIX. See step 2 from here.

Thanks, I've figured it out after I posted it here (and how to make it run on vs2019)

pps83 commented 4 years ago

I wanted to write my own visualizer and the only place to start is CppCustomVisualizer, I wasn't able to find anything else. In hopes to make it better I'll share my experience/feedback:

maxruben commented 4 years ago

The good thing about the CppCustomVisualizer sample is that it actually starts a new Visual Studio instance with the TargetApp and the visualizer dll installed via the .vsix (startup) project when running a debug session on the CppCustomVisualizer project. When starting the debugger for the TargetApp, you can set breakpoints in the dll code in the other Visual Studio instance to see whats happening. No need to keep installing and uninstalling the .vsix file. Just close down the debugging for the TargetApp and the Visualizer dll will be installed from fresh in the next debugging session. Very nice.

I would like to have some more insight in how you would go about to do custom visualizers for more than one type/class in the same dll.

/Ruben

gregg-miskelly commented 4 years ago

@pps83 as maxruben mentioned, you shouldn't need to install/uninstall a .vsix for normal development-time debugging. The VSIX project's build will take care of 'installing' the vsix into the 'experimental instance' of VS. In case you didn't see them, there are instructions here.

pps83 commented 4 years ago

@gregg-miskelly I tried to follow Running the Sample in Visual Studio but it doesn't work. When I hit F5, I get a new vs2019 started but it doesn't load TargetApp.sln and offers me to open a project. If I open TargetApp.sln manually and try to debug, I don't get visualizers working for FILETIME.

Also, as @maxruben mentioned, it's not clear how to make visualizers that work for multiple types. That should be explained/shown in the example.

gregg-miskelly commented 4 years ago

@pps83 For the issue of F5'ing not working, can you open a new issue? Please include:

For the second question (multiple types): There are probably many different answers depending on how separate you want your implementations to be, but in the most simple case, just add the additional type to your natvis. You should be able to either reuse the same VisualizerId, or declare a new one. If you decide to declare a new one, you could either declare multiple classes (one for each VisualizerId) or you could have one class that handles them all. In the later case, your .vsdconfigxml would look like this:

<Implements>
        <InterfaceGroup>
          <Filter>
             <!-- Example of supporting three different visualizers. -->
            <VisualizerId RequiredValue="D3C901B3-8005-435E-803D-DF43E6C3ED29"/>
            <VisualizerId RequiredValue="748F6A19-A624-4026-A39C-8019532B586E"/>
            <VisualizerId RequiredValue="D6DFE1A0-4A83-4BAC-B3BB-0FB8BF9149DA"/>
          </Filter>
          <Interface Name="IDkmCustomVisualizer"/>
        </InterfaceGroup>
      </Implements>

Example screen capture: vsix-launch