Ejemplo n.º 1
0
        /// <summary>
        ///     Get all tasks defined in the project.
        /// </summary>
        /// <param name="projectDocument">
        ///     The project document.
        /// </param>
        /// <returns>
        ///     A dictionary of task metadata, keyed by task name.
        /// </returns>
        protected async Task <Dictionary <string, MSBuildTaskMetadata> > GetProjectTasks(ProjectDocument projectDocument)
        {
            if (projectDocument == null)
            {
                throw new ArgumentNullException(nameof(projectDocument));
            }

            // We trust that all tasks discovered via GetMSBuildProjectTaskAssemblies are accessible in the current project.

            Dictionary <string, MSBuildTaskMetadata> tasks = new Dictionary <string, MSBuildTaskMetadata>();

            foreach (MSBuildTaskAssemblyMetadata assemblyMetadata in await projectDocument.GetMSBuildProjectTaskAssemblies())
            {
                foreach (MSBuildTaskMetadata task in assemblyMetadata.Tasks)
                {
                    tasks[task.Name] = task;
                }
            }

            return(tasks);
        }