I have tested the scenario by creating a task and adding a resource. However no issue is observed where task date is changed. Could you please give a try to the following sample code and let us know the feedback?
Dim proj As New Project()
proj.CalculationMode = CalculationMode.Manual
proj.[Set](Prj.StartDate, New DateTime(2016, 5, 16, 8, 0, 0))
Dim eventTask As Task = proj.RootTask.Children.Add("Task 1")
eventTask.[Set](Tsk.IsManual, True)
eventTask.[Set](Tsk.IsEffortDriven, False)
eventTask.[Set](Tsk.ManualStart, New DateTime(2016, 5, 16, 8, 0, 0))
eventTask.[Set](Tsk.NotesText, "These are notes text")
eventTask.[Set](Tsk.DurationFormat, TimeUnitType.Day)
eventTask.[Set](Tsk.ManualFinish, New DateTime(2016, 5, 16, 17, 0, 0))
eventTask.[Set](Tsk.ManualDuration, proj.GetDuration(1))
Dim person1 As Resource = proj.Resources.Add("Person 1")
Dim assn1 As ResourceAssignment = proj.ResourceAssignments.Add(eventTask, person1)
proj.Save("output.xml", SaveFileFormat.XML)
Set the Task start/finish to span more than one day and then add resource to the task. The Task dates changes. I want the Task’s Date NOT to change when I add a resource to that tasks.
Dim proj As New Project(_projectTemplate)
proj.CalculationMode = CalculationMode.Manual
proj.[Set](Prj.StartDate, New DateTime(2016, 5, 18, 8, 0, 0))
Dim eventTask As Task = proj.RootTask.Children.Add("Task 1")
eventTask.[Set](Tsk.IsManual, True)
eventTask.[Set](Tsk.IsEffortDriven, False)
eventTask.[Set](Tsk.ManualStart, New DateTime(2016, 5, 20, 8, 0, 0))
eventTask.[Set](Tsk.NotesText, "These are notes text")
eventTask.[Set](Tsk.DurationFormat, TimeUnitType.Day)
eventTask.[Set](Tsk.ManualFinish, New DateTime(2016, 5, 22, 17, 0, 0))
eventTask.[Set](Tsk.ManualDuration, proj.GetDuration(1))
Dim person1 As Resource = proj.Resources.Add("Person 1")
Dim assn1 As ResourceAssignment = proj.ResourceAssignments.Add(eventTask, person1)
Dim mppSaveOptions As New MPPSaveOptions()
mppSaveOptions.WriteViewData = True
' Save as MS Project file
proj.Save(resultFile, mppSaveOptions)
I have checked your sample code without any change and generated the output MPP file.This MPP file is opened in MSP 2010 and compared with the source code. It is observed that there is no difference in the task start/finish date in the code and output file. Could you please explain where the date is changing for our reference? It will be helpful for us to observe problem and provide assistance as soon as possible.
Thank you for assisting us to re-produce issue and we have observed the difference while opening output MPP file in MSP 2010 and MSP 2013. It is logged under Id: TASKS-34605 for further investigation by the product team. You will be automatically notified once any update is received in this regard.
We are sorry but there is no ETA available at present for resolution of this issue. We have requested about this information from our Product team and will update you here once there is some information available in this regard.
We have investigated the issue thoroughly and observed that MSP 2010 and MSP 2013 use different logic for task start/finish date calculation. Looks like MSP 2013 primarily considers all resource assignment in the calculation. You may please set Asn.Start and Asn.Finish date explicitly and share the feedback.
Dim proj As New Project(“Blank2010.mpp”)
proj.CalculationMode = CalculationMode.Manual
proj.[Set](Prj.StartDate, New DateTime(2016, 5, 18, 8, 0, 0))
Dim eventTask As Task = proj.RootTask.Children.Add("Task 1")
eventTask.[Set](Tsk.IsManual, True)
eventTask.[Set](Tsk.IsEffortDriven, False)
eventTask.[Set](Tsk.ManualStart, New DateTime(2016, 5, 20, 8, 0, 0))
eventTask.[Set](Tsk.NotesText, "These are notes text")
eventTask.[Set](Tsk.DurationFormat, TimeUnitType.Day)
eventTask.[Set](Tsk.ManualFinish, New DateTime(2016, 5, 22, 17, 0, 0))
eventTask.[Set](Tsk.ManualDuration, proj.GetDuration(1))
Dim person1 As Resource = proj.Resources.Add("Person 1")
Dim assn1 As ResourceAssignment = proj.ResourceAssignments.Add(eventTask, person1)
assn1.[Set](Asn.Start, New DateTime(2016, 5, 20, 8, 0, 0))
assn1.[Set](Asn.Finish, New DateTime(2016, 5, 22, 17, 0, 0))
Dim mppSaveOptions As New MPPSaveOptions()
mppSaveOptions.WriteViewData = True
'Save as MS Project file
proj.Save("CodeOutput.mpp", mppSaveOptions)