I am integrating our internal project tool with Visual studio

Kumar PH, Punith (E/CAIN-B1) 5 Reputation points
2026-10-28T09:59:46.4033333+00:00

I am integrating our internal project tool with Visual studio, I want to create a context menu, when I right click on particular test we get option like run, debug etc as mentioned in the screen shot now I want to create another context menu just below Run option called Run with XXX monitor. for that how should I proceed with I tried reverse engineering the different APIs but didn't find proper one and how to proceed

User's image

Developer technologies | Visual Studio | Extensions
0 comments No comments

3 answers

Sort by: Most helpful
  1. Brian Pham (WICLOUD CORPORATION) 1,090 Reputation points Microsoft External Staff Moderator
    2026-10-28T11:23:48.52+00:00

    Hi @Kumar PH, Punith (E/CAIN-B1) ,

    Thank you for raising this question. I understand that you would like to integrate your internal tool with Visual Studio by adding a “Run with XXX monitor” command to the Test Explorer context menu, ideally directly below Run, and have that command operate on the test(s) currently selected in Test Explorer.

    Based on the Microsoft documentation I reviewed and research , Visual Studio officially supports extensibility through custom commands, menus, and command groups. Microsoft also documents GUIDs and IDs for various Visual Studio menus and groups that can be used as placement targets for extension commands.

    For your specific requirement, the published GUIDs and IDs of Visual Studio menus reference covers the documented menu and group placement targets available for Visual Studio extensions.Your “Run** with XXX **monitor” scenario requires additional Test Explorer-specific functionality, including placement within the selected-test context menu and access to the selected test(s), which is not covered in the published documentation I reviewed.

    Please note that the guidance I can provide here is based on publicly available Microsoft documentation. Since this specific scenario is not explicitly documented as supported or unsupported, you may also raise your question through the Visual Studio Developer Community.

    If you found my response helpful or informative, I would greatly appreciate it if you could follow this guide for your confirmation.

    Thank you.

    Was this answer helpful?

    1 person found this answer helpful.

  2. gekka 14,716 Reputation points MVP Volunteer Moderator
    2026-10-29T23:28:28.87+00:00

    By creating a VSIX project and a .vsct file, you will be able to place your command menu in the desired context menu location.

    <?xml version="1.0" encoding="utf-8"?>
    <CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    
    	<Extern href="stdidcmd.h"/>
    	<Extern href="vsshlids.h"/>
    	
    	<Commands package="guid_YOUR_PACKAGE">
    		<Buttons>
    			<Button guid="guid_YOUR_PACKAGE_CmdSet" id="TestCommandId" priority="0x0011" type="Button">
    				<Parent guid="guid_VS_TestExplore_CmdSet" id="IDG_VS_TestExplore_A" />
    				<!-- <CommandFlag>TextChanges DefaultDisabled</CommandFlag> -->
    				<Strings>
    					<ButtonText>☺Run with XXX</ButtonText>
    				</Strings>
    			</Button>
    		</Buttons>
    	</Commands>
    
    	<Symbols>
    		<!-- Symbol and Ids for TestExplore context menu -->
    		<GuidSymbol name="guid_VS_TestExplore_CmdSet" value="{1E198C22-5980-4E7E-92F3-F73168D1FB63}">
    			<IDSymbol name="IDM_VS_CTXT_TestExplore" value="0x0002"  />
    			<IDSymbol name="IDG_VS_TestExplore_A" value="0x0101"  />
    		</GuidSymbol>
    
    
    		<!-- Symbol and Ids for your package -->
    		<GuidSymbol name="guid_YOUR_PACKAGE" value="{ YOUR-PACKAGE-GUID }" />
    		<GuidSymbol name="guid_YOUR_PACKAGE_CmdSet" value="{YOUR-COMMANDSET-GUID}">
    			<IDSymbol name="TestCommandId" value="0x0100" />
    		</GuidSymbol>
    
    	</Symbols>
    </CommandTable>
    

    Was this answer helpful?

    0 comments No comments

  3. AI answer

    2026-10-28T10:01:43.94+00:00

    A publicly documented placement point for inserting a command directly below Run in Test Explorer—and an API for obtaining its selected tests—could not be verified, so implement Run with XXX monitor in a documented menu location unless Microsoft confirms a supported Test Explorer extension point.

    Supported implementation

    Create a Visual Studio extension command and place it under Extensions or Tools. The newer VisualStudio.Extensibility model supports those known placements; other locations require the documented GUID and ID of an existing VSCT group. Priority only controls ordering among commands in the same group.^1^

    A minimal command is:

    using Microsoft.VisualStudio.Extensibility;
    using Microsoft.VisualStudio.Extensibility.Commands;
    using Microsoft.VisualStudio.Extensibility.Shell;
    using System.Diagnostics;
    
    [VisualStudioContribution]
    public class RunWithMonitorCommand : Command
    {
        public RunWithMonitorCommand(VisualStudioExtensibility extensibility)
            : base(extensibility) { }
    
        public override CommandConfiguration CommandConfiguration =>
            new("%RunWithMonitor.DisplayName%")
            {
                Placements = [CommandPlacement.KnownPlacements.ExtensionsMenu]
            };
    
        public override Task ExecuteCommandAsync(
            IClientContext context, CancellationToken cancellationToken)
        {
            Process.Start(new ProcessStartInfo("xxx-monitor.exe")
                { UseShellExecute = true });
            return Task.CompletedTask;
        }
    }
    

    Replace the Process.Start body with application-specific orchestration that:

    1. Starts XXX monitor.
    2. Runs the appropriate test runner with a user-supplied test filter.
    3. Stops the monitor in a finally block.
    4. Reports the test runner’s exit code.

    This route does not automatically receive the tests selected in Test Explorer. The current documentation describes Test Explorer’s built-in right-click operations, but does not document an extension-facing selected-test command target or selection API.^2^

    Why a VSCT entry cannot yet be specified

    Traditional in-process VSSDK extensions define commands, groups, and menu placement in a .vsct file.^3^ A typical custom command requires:

    • A Button for the command.
    • A Group that hosts it.
    • A Parent or CommandPlacement targeting a documented menu/group GUID and ID.
    • A priority controlling its relative position within that group.^4^

    The published Visual Studio menu/group ID list does not provide a Test Explorer selected-test context-menu group in the material available here.^5^ Consequently, there is no documented GUID/ID that can safely be supplied for this exact placement.

    Do not substitute IDs discovered by reverse engineering or command-inspection tools for a documented extension point. They may be implementation details and can change between Visual Studio updates. The inference is that this exact location is undocumented or unsupported; only Microsoft can confirm whether a private placement has a supported public equivalent.

    If exact placement is mandatory

    Open a Visual Studio extensibility support request or feature request and ask Microsoft to confirm both:

    1. A supported VSCT GUID/group ID for the Test Explorer selected-test context menu.
    2. A supported API that returns the selected test identities to the invoked command.

    Both are required. A menu placement alone would display the command but would not provide enough documented information to run the selected tests.

    If Microsoft supplies a supported parent, use either:

    • CommandPlacement.VsctParent(parentGuid, parentId, priority) in the newer extensibility model, or
    • a .vsct Parent/CommandPlacement in a traditional VSPackage.

    Keep these two extension models separate rather than combining their project setup or command registration.

    Conditional alternative

    If XXX monitor must wrap every run rather than only an explicitly selected command, integration with the particular test framework, adapter, or external test runner may be more appropriate. That depends on whether the monitor supports setup/teardown hooks and whether the framework exposes run-level lifecycle integration; the available documentation does not establish those details for your internal tool.


    References

    1. Add Visual Studio commands
    2. Run Unit Tests with Test Explorer - Visual Studio (Windows)
    3. Extend menus and commands
    4. Author .vsct files
    5. GUIDs and IDs of Visual Studio menus
    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.