Duration is being set to 0

I am having a trouble when generating as mpp file when my task has only material resources and the PercentCompleted is 100%, the duration becames 0.

Here is my code, the mpp file used as base (PrjNewFileSyncProject) and the output fileApose1.zip (47.8 KB)
.

DateTime data = new DateTime(2018, 4, 9).AddHours(9);
int duracao = 104;
DateTime dataFim = new DateTime(2018, 8, 30).AddHours(18);
project.Set(Prj.StartDate, data);
project.Set(Prj.NewTaskStartDate, TaskStartDateType.ProjectStartDate);
project.Set(Prj.DefaultStartTime, data.AddHours(9));
project.Set(Prj.DefaultFinishTime, data.AddHours(18));
project.Set(Prj.DefaultTaskType, TaskType.FixedDuration);
project.Set(Prj.DurationFormat, TimeUnitType.Day);
project.Set(Prj.WorkFormat, TimeUnitType.Hour);
project.Set(Prj.MinutesPerDay, 8 * 60);
project.Recalculate();

  Task taskPai = project.RootTask.Children.Add("Task1");
  taskPai.Set(Tsk.Cost, 10);
  taskPai.Set(Tsk.IsManual, false);
  taskPai.Set(Tsk.Type, TaskType.Undefined);
  taskPai.Set(Tsk.DurationFormat, TimeUnitType.Day);
  taskPai.Set(Tsk.IsCritical, false);
  taskPai.Set(Tsk.IsActive, true);
  taskPai.Set(Tsk.IsMilestone, false);

  Task task = taskPai.Children.Add("Task Filha");
  task.Set(Tsk.Cost, 10);
  task.Set(Tsk.IsManual, true);
  task.Set(Tsk.Type, TaskType.FixedDuration);
  task.Set(Tsk.DurationFormat, TimeUnitType.Day);
  task.Set(Tsk.IsCritical, false);
  task.Set(Tsk.IsActive, true);
  task.Set(Tsk.IsMilestone, false);

  task.Set(Tsk.Start, data);
  task.Set(Tsk.Finish, dataFim);
  task.Set(Tsk.Duration, project.GetDuration(duracao, TimeUnitType.Day));

  task.Set(Tsk.ManualStart, task.Get(Tsk.Start));
  task.Set(Tsk.ManualFinish, task.Get(Tsk.Finish));
  task.Set(Tsk.ManualDuration, task.Get(Tsk.Duration));

  task.Set(Tsk.EarlyStart, data);
  task.Set(Tsk.EarlyFinish, dataFim);
  task.Set(Tsk.LateStart, data);
  task.Set(Tsk.LateFinish, dataFim);

  task.Set(Tsk.ActualStart, data);
  task.Set(Tsk.ActualFinish, dataFim);
  task.Set(Tsk.ActualDuration, task.Get(Tsk.Duration));

  task.Set(Tsk.PercentComplete, 100);

  Resource res3 = project.Resources.Add("MAT3");
  res3.Set(Rsc.Type, ResourceType.Material);
  res3.Set(Rsc.StandardRate, 42.17M);

  ResourceAssignment resAssignment = project.ResourceAssignments.Add(task, res3, 1.59);

  resAssignment.Set(Asn.RemainingWork, project.GetDuration(0, TimeUnitType.Day));
  resAssignment.Set(Asn.PercentWorkComplete, 100);

  MPPSaveOptions mppSaveOptions = new MPPSaveOptions();
  project.RemoveInvalidResourceAssignments();
  project.Save(arqSaida, mppSaveOptions);

@amakoski,

Thank you for writing to Aspose support team.

This issue is observed here and logged under Id: TASKSNET-2453 for detailed analysis. We will write back here once analysis is done and feedback is ready to share.

@amakoski,

This issue has been fixed in Aspose.Tasks for .NET 18.6. Please check it at your end and let us know your feedback.