How to spawn an offline process from a TFS vNext build step that would last beyond the build?











up vote
0
down vote

favorite












It seems that if my build step spawns a child process, that process cannot survive the end of the build - it is killed.



But I have a scenario where a child process is triggered in order to complete offline certain operations that the build should not wait for their completion (reporting metrics to Azure AppInsights).



This procedure worked fine in XAML builds, but now that we migrated to vNext it is broken, because the child process is killed when the build ends.



What can be done about it?










share|improve this question


























    up vote
    0
    down vote

    favorite












    It seems that if my build step spawns a child process, that process cannot survive the end of the build - it is killed.



    But I have a scenario where a child process is triggered in order to complete offline certain operations that the build should not wait for their completion (reporting metrics to Azure AppInsights).



    This procedure worked fine in XAML builds, but now that we migrated to vNext it is broken, because the child process is killed when the build ends.



    What can be done about it?










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      It seems that if my build step spawns a child process, that process cannot survive the end of the build - it is killed.



      But I have a scenario where a child process is triggered in order to complete offline certain operations that the build should not wait for their completion (reporting metrics to Azure AppInsights).



      This procedure worked fine in XAML builds, but now that we migrated to vNext it is broken, because the child process is killed when the build ends.



      What can be done about it?










      share|improve this question













      It seems that if my build step spawns a child process, that process cannot survive the end of the build - it is killed.



      But I have a scenario where a child process is triggered in order to complete offline certain operations that the build should not wait for their completion (reporting metrics to Azure AppInsights).



      This procedure worked fine in XAML builds, but now that we migrated to vNext it is broken, because the child process is killed when the build ends.



      What can be done about it?







      tfs azure-devops vnext






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 11 at 1:06









      mark

      19.1k55186370




      19.1k55186370
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          The easiest way is to schedule a task using the task scheduler.



          Example using Microsoft.Win32.TaskScheduler NuGet package:



          using (var ts = new TaskService())
          {
          // Create a new task definition and assign properties
          var td = ts.NewTask();
          td.Triggers.Add(new TimeTrigger(DateTime.Now.AddDays(-1)));
          td.Actions.Add(new ExecAction(MyExe, MyArgs));
          ts.RootFolder.RegisterTaskDefinition(MyTaskName, td).Run();
          ts.RootFolder.DeleteTask(MyTaskName);
          }





          share|improve this answer























          • The schedule has to be created and auto deleted when completed. Do you happen to know the details of how can this be done from C#? I can probably google it, but these kinds of details will make your answer truly awesome.
            – mark
            Nov 11 at 18:56










          • I know :). Haven't had the time to look it up. There are plenty of examples on setting up a scheduled task from powershell. An online powershell script task would do the trick. Depending on its usage I'd either give it a fixed name and just leave it there or use the build definition ID or something to clean it up afterwards. Then pass that id in as a parameter to the schedules task.
            – jessehouwing
            Nov 12 at 11:03






          • 1




            I have taken the liberty to edit your question and add the example code based on what I did for myself. Thanks again.
            – mark
            Nov 12 at 12:50













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244947%2fhow-to-spawn-an-offline-process-from-a-tfs-vnext-build-step-that-would-last-beyo%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote



          accepted










          The easiest way is to schedule a task using the task scheduler.



          Example using Microsoft.Win32.TaskScheduler NuGet package:



          using (var ts = new TaskService())
          {
          // Create a new task definition and assign properties
          var td = ts.NewTask();
          td.Triggers.Add(new TimeTrigger(DateTime.Now.AddDays(-1)));
          td.Actions.Add(new ExecAction(MyExe, MyArgs));
          ts.RootFolder.RegisterTaskDefinition(MyTaskName, td).Run();
          ts.RootFolder.DeleteTask(MyTaskName);
          }





          share|improve this answer























          • The schedule has to be created and auto deleted when completed. Do you happen to know the details of how can this be done from C#? I can probably google it, but these kinds of details will make your answer truly awesome.
            – mark
            Nov 11 at 18:56










          • I know :). Haven't had the time to look it up. There are plenty of examples on setting up a scheduled task from powershell. An online powershell script task would do the trick. Depending on its usage I'd either give it a fixed name and just leave it there or use the build definition ID or something to clean it up afterwards. Then pass that id in as a parameter to the schedules task.
            – jessehouwing
            Nov 12 at 11:03






          • 1




            I have taken the liberty to edit your question and add the example code based on what I did for myself. Thanks again.
            – mark
            Nov 12 at 12:50

















          up vote
          1
          down vote



          accepted










          The easiest way is to schedule a task using the task scheduler.



          Example using Microsoft.Win32.TaskScheduler NuGet package:



          using (var ts = new TaskService())
          {
          // Create a new task definition and assign properties
          var td = ts.NewTask();
          td.Triggers.Add(new TimeTrigger(DateTime.Now.AddDays(-1)));
          td.Actions.Add(new ExecAction(MyExe, MyArgs));
          ts.RootFolder.RegisterTaskDefinition(MyTaskName, td).Run();
          ts.RootFolder.DeleteTask(MyTaskName);
          }





          share|improve this answer























          • The schedule has to be created and auto deleted when completed. Do you happen to know the details of how can this be done from C#? I can probably google it, but these kinds of details will make your answer truly awesome.
            – mark
            Nov 11 at 18:56










          • I know :). Haven't had the time to look it up. There are plenty of examples on setting up a scheduled task from powershell. An online powershell script task would do the trick. Depending on its usage I'd either give it a fixed name and just leave it there or use the build definition ID or something to clean it up afterwards. Then pass that id in as a parameter to the schedules task.
            – jessehouwing
            Nov 12 at 11:03






          • 1




            I have taken the liberty to edit your question and add the example code based on what I did for myself. Thanks again.
            – mark
            Nov 12 at 12:50















          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          The easiest way is to schedule a task using the task scheduler.



          Example using Microsoft.Win32.TaskScheduler NuGet package:



          using (var ts = new TaskService())
          {
          // Create a new task definition and assign properties
          var td = ts.NewTask();
          td.Triggers.Add(new TimeTrigger(DateTime.Now.AddDays(-1)));
          td.Actions.Add(new ExecAction(MyExe, MyArgs));
          ts.RootFolder.RegisterTaskDefinition(MyTaskName, td).Run();
          ts.RootFolder.DeleteTask(MyTaskName);
          }





          share|improve this answer














          The easiest way is to schedule a task using the task scheduler.



          Example using Microsoft.Win32.TaskScheduler NuGet package:



          using (var ts = new TaskService())
          {
          // Create a new task definition and assign properties
          var td = ts.NewTask();
          td.Triggers.Add(new TimeTrigger(DateTime.Now.AddDays(-1)));
          td.Actions.Add(new ExecAction(MyExe, MyArgs));
          ts.RootFolder.RegisterTaskDefinition(MyTaskName, td).Run();
          ts.RootFolder.DeleteTask(MyTaskName);
          }






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 12 at 12:52









          mark

          19.1k55186370




          19.1k55186370










          answered Nov 11 at 10:31









          jessehouwing

          66.2k9159231




          66.2k9159231












          • The schedule has to be created and auto deleted when completed. Do you happen to know the details of how can this be done from C#? I can probably google it, but these kinds of details will make your answer truly awesome.
            – mark
            Nov 11 at 18:56










          • I know :). Haven't had the time to look it up. There are plenty of examples on setting up a scheduled task from powershell. An online powershell script task would do the trick. Depending on its usage I'd either give it a fixed name and just leave it there or use the build definition ID or something to clean it up afterwards. Then pass that id in as a parameter to the schedules task.
            – jessehouwing
            Nov 12 at 11:03






          • 1




            I have taken the liberty to edit your question and add the example code based on what I did for myself. Thanks again.
            – mark
            Nov 12 at 12:50




















          • The schedule has to be created and auto deleted when completed. Do you happen to know the details of how can this be done from C#? I can probably google it, but these kinds of details will make your answer truly awesome.
            – mark
            Nov 11 at 18:56










          • I know :). Haven't had the time to look it up. There are plenty of examples on setting up a scheduled task from powershell. An online powershell script task would do the trick. Depending on its usage I'd either give it a fixed name and just leave it there or use the build definition ID or something to clean it up afterwards. Then pass that id in as a parameter to the schedules task.
            – jessehouwing
            Nov 12 at 11:03






          • 1




            I have taken the liberty to edit your question and add the example code based on what I did for myself. Thanks again.
            – mark
            Nov 12 at 12:50


















          The schedule has to be created and auto deleted when completed. Do you happen to know the details of how can this be done from C#? I can probably google it, but these kinds of details will make your answer truly awesome.
          – mark
          Nov 11 at 18:56




          The schedule has to be created and auto deleted when completed. Do you happen to know the details of how can this be done from C#? I can probably google it, but these kinds of details will make your answer truly awesome.
          – mark
          Nov 11 at 18:56












          I know :). Haven't had the time to look it up. There are plenty of examples on setting up a scheduled task from powershell. An online powershell script task would do the trick. Depending on its usage I'd either give it a fixed name and just leave it there or use the build definition ID or something to clean it up afterwards. Then pass that id in as a parameter to the schedules task.
          – jessehouwing
          Nov 12 at 11:03




          I know :). Haven't had the time to look it up. There are plenty of examples on setting up a scheduled task from powershell. An online powershell script task would do the trick. Depending on its usage I'd either give it a fixed name and just leave it there or use the build definition ID or something to clean it up afterwards. Then pass that id in as a parameter to the schedules task.
          – jessehouwing
          Nov 12 at 11:03




          1




          1




          I have taken the liberty to edit your question and add the example code based on what I did for myself. Thanks again.
          – mark
          Nov 12 at 12:50






          I have taken the liberty to edit your question and add the example code based on what I did for myself. Thanks again.
          – mark
          Nov 12 at 12:50




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244947%2fhow-to-spawn-an-offline-process-from-a-tfs-vnext-build-step-that-would-last-beyo%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Florida Star v. B. J. F.

          Error while running script in elastic search , gateway timeout

          Adding quotations to stringified JSON object values