非 windows 系统上的自定义 ITaskHost
Custom ITaskHost on non windows system
我正在尝试在 HostServices
中注册自定义 ITaskHost
,以便在构建过程中使用 Task.HostObject
属性.
进行访问
HostServices hostServices = new HostServices();
string prjPath = "/mnt/devel/CrowIDE/build/Debug/netcoreapp3.1/src/CustomCrowIDE.targets"
hostServices.RegisterHostObject(prjPath, "CustomBeforeBuild", "HookTask", this);
ProjectInstance pi = BuildManager.DefaultBuildManager.GetProjectInstanceForBuild (project);
BuildRequestData request = new BuildRequestData (pi, new string[] { target }, hostServices);
BuildResult result = BuildManager.DefaultBuildManager.Build (solution.buildParams, request);
但是我的自定义任务的 HostObjet
属性 保持为空。
我读到 ITaskHost 是 windows 上的 com 对象,必须在 ROT table 中注册,但在 linux 上,是否可以绕过此约束?
我找到了另一种使用 ILogger
将结果转发到托管应用程序的解决方案,并且可以使用 CustomBuildEventArgs
引发自定义事件。
诀窍是在记录器中使用反射来绕过隔离。
我正在尝试在 HostServices
中注册自定义 ITaskHost
,以便在构建过程中使用 Task.HostObject
属性.
HostServices hostServices = new HostServices();
string prjPath = "/mnt/devel/CrowIDE/build/Debug/netcoreapp3.1/src/CustomCrowIDE.targets"
hostServices.RegisterHostObject(prjPath, "CustomBeforeBuild", "HookTask", this);
ProjectInstance pi = BuildManager.DefaultBuildManager.GetProjectInstanceForBuild (project);
BuildRequestData request = new BuildRequestData (pi, new string[] { target }, hostServices);
BuildResult result = BuildManager.DefaultBuildManager.Build (solution.buildParams, request);
但是我的自定义任务的 HostObjet
属性 保持为空。
我读到 ITaskHost 是 windows 上的 com 对象,必须在 ROT table 中注册,但在 linux 上,是否可以绕过此约束?
我找到了另一种使用 ILogger
将结果转发到托管应用程序的解决方案,并且可以使用 CustomBuildEventArgs
引发自定义事件。
诀窍是在记录器中使用反射来绕过隔离。