Working with Task Links
Overview
In project management, task links (also known as task dependencies) define the logical relationship between tasks. They allow project managers to model execution order, identify dependencies, and calculate the project schedule.
Using Aspose.Tasks for .NET, developers can programmatically create, modify, or remove task links in Microsoft Project (MPP/XML) files without the need for Microsoft Project installed. This enables advanced automation scenarios such as schedule analysis, critical path calculation, or dynamic project generation.
Why Task Links Matter
- Control task flow — define which tasks must finish before others can start.
- Schedule calculation — Microsoft Project and Aspose.Tasks use links to recalculate dates automatically.
- Cross-project dependencies — link tasks across different projects for portfolio-level planning.
- What-if analysis — simulate changes by programmatically updating task links.
Core API Classes
The main classes used when working with task links are:
- TaskLink – represents a dependency between two tasks.
- TaskLinkType – defines the type of link (Finish-to-Start, Start-to-Start, etc.).
- Task – source and target objects for the link.
- Project – root object for loading, editing, and saving tasks and links.
Creating a Simple Task Link
1 var project = new Project();
2
3 // Create two tasks
4 Task task1 = project.RootTask.Children.Add("Design Phase");
5 Task task2 = project.RootTask.Children.Add("Implementation Phase");
6
7 // Create a Finish-to-Start link (default type)
8 TaskLink link = project.TaskLinks.Add(task1, task2);
9
10 // Optionally change the link type
11 link.LinkType = TaskLinkType.StartToStart;
12
13 // Save the project
14 project.Save("TaskLinksExample.mpp", SaveFileFormat.Mpp);
Practical Scenarios
- Defining link types — choose between FS, SS, FF, and SF depending on dependency needs.
- Analyzing predecessors and successors — iterate through tasks to report their relationships.
- Cross-project predecessors — link tasks across multiple MPP files.
- Identifying linked tasks — programmatically detect tasks with dependencies for validation or reporting.
Related Articles
- Creating Task Links
- Defining Link Type
- Predecessor and Successor Tasks
- How to Work with Cross Project Predecessors
- Identify Cross Project Tasks
Conclusion
Task links are the foundation of a project schedule. With Aspose.Tasks for .NET, you can fully manage dependencies programmatically — from creating simple Finish-to-Start links to modeling complex cross-project relationships. This enables developers to build powerful scheduling, analysis, and reporting tools tailored to specific business workflows.