0

EDIT - Looks like the initial problem only applies to .NET Core projects. So the question shifts to "What is the correct way to get the full range of project properties from .NET Core projects?"


I'm writing a Visual Studio 2019 plugin that uses some of the project configuration settings. It seems straight forward enough to get the Project object (C# here, but also C++ & others) and then spelunking the Configuration's for Property objects.

But it appears that accessing most of the properties will throw System.NotImplementedException.

Primary Question: Is there another way to access these settings - like startup arguments and other debugging configuration?

Secondary Question: Are there any good resources on this stuff? The online MS docs are a bit terse for my taste.

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
    }
}

Thanks!

Jason Weiler
  • 81
  • 1
  • 5
  • Hmmm...there's this question that touches on exactly what I'm looking for, but I don't yet see why that succeeds while my code throws. https://stackoverflow.com/questions/55407273/getting-debugger-command-from-active-project-configuration – Jason Weiler Apr 11 '21 at 09:04
  • Follow-up: Looks like this is an incompatibility with .NET Core projects. Framework projects seem to work. – Jason Weiler Apr 11 '21 at 18:43

0 Answers0