Comments (2)
Hey,
that's a bit late, but I ran into the same kind of issues. And after quite a bit of investigation I was able to understand what's going on.
So first, the c++ project system doesn't load the debugger extension on project load (I don't even know if it happens with other project types). If you want your extension to be loaded, you can use
[Export(ExportContractNames.Scopes.ConfiguredProject, typeof(IProjectDynamicLoadComponent))]
If you do that you will see that the LoadAsync/UnloadAsync are called if you have the right capability (you can try with "VisualC").
Even though that's unintuitive, the list of available debuggers is not defined by the exported MEF debuggers, but by the rules registered for the project.
When you click the debug button, the exported IDebugLaunchProvider are enumerated and the one with a matching name is instanciated and CanLaunchAsync, etc... are called.
Now the issue is the documentation suggest that we use ExportPropertyXamlRuleDefinition, but I wasn't able to make that work at all (in vs 2022).
The best way in my opinion is to use IProjectDynamicLoadComponent. Then import a IAdditionalRuleDefinitionsService in the constructor, and add the rule manually.
Then your debugger will appears in the drop down menu.
[Export(ExportContractNames.Scopes.ConfiguredProject, typeof(IProjectDynamicLoadComponent))]
[ExportDebugger("MyDebugger")]
[AppliesTo("VisualC")]
public class MyDebugLaunchProvider
: DebugLaunchProviderBase,
IProjectDynamicLoadComponent
{
private ConfiguredProject m_configuredProject = null;
[ImportMany(ExportContractNames.VsTypes.IVsHierarchy)]
private OrderPrecedenceImportCollection<IVsHierarchy> IVsHierarchies { get; set; }
[ImportingConstructor]
public MyDebugLaunchProvider(ConfiguredProject configuredProject, IAdditionalRuleDefinitionsService rds)
: base(configuredProject)
{
IVsHierarchies = new OrderPrecedenceImportCollection<IVsHierarchy>(projectCapabilityCheckProvider: configuredProject.UnconfiguredProject);
m_configuredProject = configuredProject;
Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("XamlRuleToCode:MyDebugger.xaml");
Rule rule = ((IProjectSchemaNode)XamlServices.Load(stream)).GetSchemaObjects(typeof(Rule)).Cast<Rule>().FirstOrDefault();
rds.AddRuleDefinition(rule, "Project");
}
public override Task<bool> CanLaunchAsync(DebugLaunchOptions launchOptions)
{
// perform any necessary logic to determine if the debugger can launch
return Task.FromResult(true);
}
public override async Task<IReadOnlyList<IDebugLaunchSettings>> QueryDebugTargetsAsync(DebugLaunchOptions launchOptions)
{
var settings = new DebugLaunchSettings(launchOptions);
settings.LaunchDebugEngineGuid = DebuggerEngines.NativeOnlyEngine;
settings.AppPackageLaunchInfo = new VsAppPackageLaunchInfo();
settings.Arguments = "";
settings.CurrentDirectory = "<exedir>";
settings.Executable = "<exepath>.exe";
settings.LaunchOperation = DebugLaunchOperation.CreateProcess;
settings.LaunchOptions = launchOptions;
settings.Options = "";
settings.PortName = "";
settings.PortSupplierGuid = Guid.Empty;
settings.ProcessId = 0;
settings.ProcessLanguageGuid = Guid.Empty;
settings.Project = IVsHierarchies.FirstOrDefault()?.Value;
settings.RemoteMachine = "";
settings.SendToOutputWindow = false;
settings.StandardErrorHandle = IntPtr.Zero;
settings.StandardInputHandle = IntPtr.Zero;
settings.StandardOutputHandle = IntPtr.Zero;
return new IDebugLaunchSettings[] { settings };
}
public async Task LoadAsync()
{
}
public async Task UnloadAsync()
{
}
}
Hopefully that might help you or others who run into the same issue.
from vsprojectsystem.
Related Issues (20)
- Extending the Reference Manager needs additional documentation and support.
- How to add custom columns to a custom tab in the Reference Manager.
- The ReferenceManagerXXX project capabilities do not seem to have any effect on the Reference Manager.
- .dcproj won't accept azure functions project
- VS Item Template Parameter rootnamespace returns incorrect value
- Property page default values are not correctly display HOT 2
- Creating Custom Project Type with Custom Project Format
- IDynamicDebugTargetsGenerator not registered in VS 2022 HOT 2
- Project System Extensibility extension for VS2022 HOT 7
- Providing build properties soon after VS startup
- IProjectGlobalPropertiesProvider for non-SDK-style projects
- improve extensibility docs
- Solution Explorer icons not working HOT 2
- Custom Debugger of CpsExtension sample doesn't show up HOT 2
- Why is there so little documentation for ProjectSchemaDefinitions?
- This repo is missing important files HOT 1
- Customized Build and Debugging supporting Target frameworks style projects
- Project capability proposal: [MSBuild.Sdk.SqlProj.BuildTSqlScript] HOT 7
- Complete docs on project data subscriptions, and include info about slice data
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vsprojectsystem.