从 .NET Core 项目的 VSIX 插件获取 StartArguments

问题描述

EDIT - 看起来最初的问题只适用于 .NET Core 项目。所以问题转移到“从 .NET Core 项目中获取全部项目属性的正确方法是什么?”


我正在编写一个使用一些项目配置设置的 Visual Studio 2019 插件。获取 Project 对象(此处为 C#,但也包括 C++ 和其他),然后为 Configuration 对象解析 Property 似乎很简单。

但似乎访问大多数属性会抛出 System.NotImplementedException

主要问题:有没有其他方法可以访问这些设置——比如启动参数和其他调试配置?

第二个问题:有关于这些东西的好的资源吗?在线 MS 文档对我来说有点简洁。

void ProcessCSharpProject(VSProject csProj)
{
    foreach (var config in csProj.Project.ConfigurationManager.Cast<Configuration>())
    {
        Property debugInfoProp = config.Properties.Item("DebugInfo");
        var debugInfo = debugInfoProp.Value as String;                 // works

        Property startArgsProp = config.Properties.Item("StartArguments");
        var startArgs = startArgsProp.Value as String;                 // NotImplemented

        // Another way to access the same thing:
        var configProps = config.Object as CSharpProjectConfigurationProperties6;
        var startArgs2 = configProps.StartArguments;                   // Also NotImplemented
    }
}

谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)