NewTaskFromFile will give you a TaskDefinition but does not create (register) the task. The problem you may be having is a permissions problem when registering. Are you running the executable from an account that has permissions to create tasks? Are you not running as Administrator and having UAC block your access? Your code is correct if you have permissions. Alternately, you could do all that in one line:
TaskService.Instance.RootFolder.ImportTask("XMLTask", @"D:\DailyTrigger.xml");
If you have permission problems, you may need to supply user information:using (var ts = new TaskService())
{
// If user information is in the XML file under the Principal tag, you can use this short form:
ts.RootFolder.RegisterTaskDefinition("XMLTask", ts.NewTaskFromFile(@"D:\DailyTrigger.xml"));
// If you need to supply user information at this time use this form. See documentation for detail on TaskLogonType.
ts.RootFolder.RegisterTaskDefinition("XMLTask", ts.NewTaskFromFile(@"D:\DailyTrigger.xml"),
TaskCreation.CreateOrUpdate, "username", "password", TaskLogonType.XYZ);
}