public static async Task GetPropertyAsync()

in EnvDTE.Host/Callback/Util/ProjectExtensions.cs [42:75]


    public static async Task<string> GetPropertyAsync(
        [NotNull] this IProject project,
        Lifetime lifetime,
        [NotNull] string name)
    {
        var value = await lifetime.StartReadActionAsync(() =>
            project.GetRequestedProjectProperty(project.GetCurrentTargetFrameworkId(), name));

        if (value is not null) return value;

        Log.Verbose($"Property '{name}' not found in configuration's properties collection. Falling back to MSBuild.");

        var projectHostContainer = project.GetSolution().ProjectsHostContainer();
        var solutionHost = projectHostContainer.GetComponent<ISolutionHost>();
        var projectMark = project.GetProjectMark();
        if (projectMark is null)
        {
            Log.Warn($"Project mark not found for project: {project.Name}.");
            return null;
        }

        if (solutionHost.GetProjectHost(projectMark) is MsBuildProjectHost projectHost)
        {
            value = await lifetime.StartMainRead(() => projectHost.Session.GetProjectProperty(projectMark, name,
                project.GetCurrentTargetFrameworkId(),
                MsBuildEvaluationMode.Expand));
        }
        else
        {
            Log.Warn($"Project '{project.Name}' is not hosted on {nameof(MsBuildProjectHost)}.");
        }

        return value;
    }