首页 > 解决方案 > 从 .NET Core 项目的 VSIX 插件获取 StartArguments

问题描述

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


我正在编写一个使用一些项目配置设置的 Visual Studio 2019 插件。Project获取对象(这里是 C#,还有 C++ 和其他)似乎很简单,然后Configuration为对象挖掘 's 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
    }
}

谢谢!

标签: c#visual-studiovsixenvdte

解决方案


推荐阅读