public static async Task SetPropertyAsync()

in EnvDTE.Host/Callback/Util/ProjectExtensions.cs [85:111]


    public static async Task SetPropertyAsync(
        [NotNull] this IProject project,
        Lifetime lifetime,
        [NotNull] string name,
        [CanBeNull] string value)
    {
        var projectMark = project.GetProjectMark();
        if (projectMark is null)
        {
            Log.Warn($"Project mark not found for project: {project.Name}.");
            return;
        }

        var projectHostContainer = project.GetSolution().ProjectsHostContainer();
        var projectHost = projectHostContainer.GetComponent<MsBuildProjectHost>();
        var solutionHost = projectHostContainer.GetComponent<ISolutionHost>();

        var rdSaveProperties = new List<RdSaveProperty>
        {
            // Even though we use `null` for configuration, the property will be set at the right place
            MsBuildModelHelper.CreateSimpleSaveProperty(name, value, null)
        };
        await lifetime.StartMainWrite(() => projectHost.SaveProperties(projectMark, rdSaveProperties));

        project.GetSolution().GetSolutionLifetimes().UntilSolutionCloseLifetime.StartMainWrite(() =>
            solutionHost.ReloadProjectAsync(projectMark)).NoAwait();
    }