Azure-DevOps display build warning












0















Problem background



I am working on a C# project that is using Azure DevOps for CI. I have a power shell file that is being run when the project is pushed to Azure. The relevant part of the build file is:



# $buildTools is the path to MSBuild.exe
# $solution is the path to the project's .sln file
& $buildTools $solution /t:Clean,Build /p:Configuration=Release,Platform=x86
if ($LASTEXITCODE -eq 0) {
Write-Host 'Build completed successfully!'
} else {
Write-Host '##vso[task.logissue type=error;]There were errors during the build of the application'
}


Problem



Currently, $LASTEXITCODE can either be 0 (no errors) or 1 (error). If the exit code is 0 everything is okay and Azure shows the green, passing badge; if it is 1 Azure shows the red, error badge. However, when there are warnings in the build they are shown in the logs and Azure shows the green badge.



Goal



My goal is to make Azure display a yellow/orange warning badge when there are warnings. Is this possible and how? Thank you very much for your time!



Attempted solution



In the C# project properties the Warning level is set to 4; so I tried this modification to the power shell script, however, it did not work out.



& $buildTools $solution 4> 'warning.txt'


Update with solution



Thanks to D.J.'s answer! The final build line looks like:



# $warningsFile is a path to a file that will contain all the warnings
& $buildTools $solution /t:Clean,Build /p:Configuration=Release,Platform=x86 /fl1 "/flp1:$warningsFile;warningsonly"









share|improve this question





























    0















    Problem background



    I am working on a C# project that is using Azure DevOps for CI. I have a power shell file that is being run when the project is pushed to Azure. The relevant part of the build file is:



    # $buildTools is the path to MSBuild.exe
    # $solution is the path to the project's .sln file
    & $buildTools $solution /t:Clean,Build /p:Configuration=Release,Platform=x86
    if ($LASTEXITCODE -eq 0) {
    Write-Host 'Build completed successfully!'
    } else {
    Write-Host '##vso[task.logissue type=error;]There were errors during the build of the application'
    }


    Problem



    Currently, $LASTEXITCODE can either be 0 (no errors) or 1 (error). If the exit code is 0 everything is okay and Azure shows the green, passing badge; if it is 1 Azure shows the red, error badge. However, when there are warnings in the build they are shown in the logs and Azure shows the green badge.



    Goal



    My goal is to make Azure display a yellow/orange warning badge when there are warnings. Is this possible and how? Thank you very much for your time!



    Attempted solution



    In the C# project properties the Warning level is set to 4; so I tried this modification to the power shell script, however, it did not work out.



    & $buildTools $solution 4> 'warning.txt'


    Update with solution



    Thanks to D.J.'s answer! The final build line looks like:



    # $warningsFile is a path to a file that will contain all the warnings
    & $buildTools $solution /t:Clean,Build /p:Configuration=Release,Platform=x86 /fl1 "/flp1:$warningsFile;warningsonly"









    share|improve this question



























      0












      0








      0








      Problem background



      I am working on a C# project that is using Azure DevOps for CI. I have a power shell file that is being run when the project is pushed to Azure. The relevant part of the build file is:



      # $buildTools is the path to MSBuild.exe
      # $solution is the path to the project's .sln file
      & $buildTools $solution /t:Clean,Build /p:Configuration=Release,Platform=x86
      if ($LASTEXITCODE -eq 0) {
      Write-Host 'Build completed successfully!'
      } else {
      Write-Host '##vso[task.logissue type=error;]There were errors during the build of the application'
      }


      Problem



      Currently, $LASTEXITCODE can either be 0 (no errors) or 1 (error). If the exit code is 0 everything is okay and Azure shows the green, passing badge; if it is 1 Azure shows the red, error badge. However, when there are warnings in the build they are shown in the logs and Azure shows the green badge.



      Goal



      My goal is to make Azure display a yellow/orange warning badge when there are warnings. Is this possible and how? Thank you very much for your time!



      Attempted solution



      In the C# project properties the Warning level is set to 4; so I tried this modification to the power shell script, however, it did not work out.



      & $buildTools $solution 4> 'warning.txt'


      Update with solution



      Thanks to D.J.'s answer! The final build line looks like:



      # $warningsFile is a path to a file that will contain all the warnings
      & $buildTools $solution /t:Clean,Build /p:Configuration=Release,Platform=x86 /fl1 "/flp1:$warningsFile;warningsonly"









      share|improve this question
















      Problem background



      I am working on a C# project that is using Azure DevOps for CI. I have a power shell file that is being run when the project is pushed to Azure. The relevant part of the build file is:



      # $buildTools is the path to MSBuild.exe
      # $solution is the path to the project's .sln file
      & $buildTools $solution /t:Clean,Build /p:Configuration=Release,Platform=x86
      if ($LASTEXITCODE -eq 0) {
      Write-Host 'Build completed successfully!'
      } else {
      Write-Host '##vso[task.logissue type=error;]There were errors during the build of the application'
      }


      Problem



      Currently, $LASTEXITCODE can either be 0 (no errors) or 1 (error). If the exit code is 0 everything is okay and Azure shows the green, passing badge; if it is 1 Azure shows the red, error badge. However, when there are warnings in the build they are shown in the logs and Azure shows the green badge.



      Goal



      My goal is to make Azure display a yellow/orange warning badge when there are warnings. Is this possible and how? Thank you very much for your time!



      Attempted solution



      In the C# project properties the Warning level is set to 4; so I tried this modification to the power shell script, however, it did not work out.



      & $buildTools $solution 4> 'warning.txt'


      Update with solution



      Thanks to D.J.'s answer! The final build line looks like:



      # $warningsFile is a path to a file that will contain all the warnings
      & $buildTools $solution /t:Clean,Build /p:Configuration=Release,Platform=x86 /fl1 "/flp1:$warningsFile;warningsonly"






      c# azure msbuild continuous-integration azure-devops






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 '18 at 13:14







      ful-stackz

















      asked Nov 19 '18 at 10:36









      ful-stackzful-stackz

      6018




      6018
























          1 Answer
          1






          active

          oldest

          votes


















          2














          You could use this -> https://docs.microsoft.com/en-us/visualstudio/msbuild/obtaining-build-logs-with-msbuild?view=vs-2017#save-the-log-output-to-multiple-files and write all warnings into a logfile, then check if the log file contains anything and then write the warnings to the output using theese commands (https://github.com/Microsoft/azure-pipelines-tasks/blob/master/docs/authoring/commands.md)






          share|improve this answer
























          • Thank you for giving me hope! I've changed the build line to & $buildTools $solution /t:Clean,Build /p:Configuration=Release,Platform=x86 /fl1 /flp1:warningsonly;logfile=$warningsFile where $warningsFile is the path to a file in the same directory. This line however, throws the following error: The term 'logfile=$warningsFile' is not recognized as the name of a cmdlet, function, script file... What would you recommend me to try next?

            – ful-stackz
            Nov 19 '18 at 12:29













          • wrap your list of arguments with "

            – D.J.
            Nov 19 '18 at 12:36








          • 1





            It does not work at all when I wrap the arguments with ", even if I remove the /fl /flp part it throws an error because of the ".

            – ful-stackz
            Nov 19 '18 at 12:49






          • 1





            I found a solution! If I only wrap the /fl /flp part with " it works as expected. Thank you again!

            – ful-stackz
            Nov 19 '18 at 13:07











          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',
          autoActivateHeartbeat: false,
          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%2f53372774%2fazure-devops-display-build-warning%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









          2














          You could use this -> https://docs.microsoft.com/en-us/visualstudio/msbuild/obtaining-build-logs-with-msbuild?view=vs-2017#save-the-log-output-to-multiple-files and write all warnings into a logfile, then check if the log file contains anything and then write the warnings to the output using theese commands (https://github.com/Microsoft/azure-pipelines-tasks/blob/master/docs/authoring/commands.md)






          share|improve this answer
























          • Thank you for giving me hope! I've changed the build line to & $buildTools $solution /t:Clean,Build /p:Configuration=Release,Platform=x86 /fl1 /flp1:warningsonly;logfile=$warningsFile where $warningsFile is the path to a file in the same directory. This line however, throws the following error: The term 'logfile=$warningsFile' is not recognized as the name of a cmdlet, function, script file... What would you recommend me to try next?

            – ful-stackz
            Nov 19 '18 at 12:29













          • wrap your list of arguments with "

            – D.J.
            Nov 19 '18 at 12:36








          • 1





            It does not work at all when I wrap the arguments with ", even if I remove the /fl /flp part it throws an error because of the ".

            – ful-stackz
            Nov 19 '18 at 12:49






          • 1





            I found a solution! If I only wrap the /fl /flp part with " it works as expected. Thank you again!

            – ful-stackz
            Nov 19 '18 at 13:07
















          2














          You could use this -> https://docs.microsoft.com/en-us/visualstudio/msbuild/obtaining-build-logs-with-msbuild?view=vs-2017#save-the-log-output-to-multiple-files and write all warnings into a logfile, then check if the log file contains anything and then write the warnings to the output using theese commands (https://github.com/Microsoft/azure-pipelines-tasks/blob/master/docs/authoring/commands.md)






          share|improve this answer
























          • Thank you for giving me hope! I've changed the build line to & $buildTools $solution /t:Clean,Build /p:Configuration=Release,Platform=x86 /fl1 /flp1:warningsonly;logfile=$warningsFile where $warningsFile is the path to a file in the same directory. This line however, throws the following error: The term 'logfile=$warningsFile' is not recognized as the name of a cmdlet, function, script file... What would you recommend me to try next?

            – ful-stackz
            Nov 19 '18 at 12:29













          • wrap your list of arguments with "

            – D.J.
            Nov 19 '18 at 12:36








          • 1





            It does not work at all when I wrap the arguments with ", even if I remove the /fl /flp part it throws an error because of the ".

            – ful-stackz
            Nov 19 '18 at 12:49






          • 1





            I found a solution! If I only wrap the /fl /flp part with " it works as expected. Thank you again!

            – ful-stackz
            Nov 19 '18 at 13:07














          2












          2








          2







          You could use this -> https://docs.microsoft.com/en-us/visualstudio/msbuild/obtaining-build-logs-with-msbuild?view=vs-2017#save-the-log-output-to-multiple-files and write all warnings into a logfile, then check if the log file contains anything and then write the warnings to the output using theese commands (https://github.com/Microsoft/azure-pipelines-tasks/blob/master/docs/authoring/commands.md)






          share|improve this answer













          You could use this -> https://docs.microsoft.com/en-us/visualstudio/msbuild/obtaining-build-logs-with-msbuild?view=vs-2017#save-the-log-output-to-multiple-files and write all warnings into a logfile, then check if the log file contains anything and then write the warnings to the output using theese commands (https://github.com/Microsoft/azure-pipelines-tasks/blob/master/docs/authoring/commands.md)







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 19 '18 at 12:00









          D.J.D.J.

          67829




          67829













          • Thank you for giving me hope! I've changed the build line to & $buildTools $solution /t:Clean,Build /p:Configuration=Release,Platform=x86 /fl1 /flp1:warningsonly;logfile=$warningsFile where $warningsFile is the path to a file in the same directory. This line however, throws the following error: The term 'logfile=$warningsFile' is not recognized as the name of a cmdlet, function, script file... What would you recommend me to try next?

            – ful-stackz
            Nov 19 '18 at 12:29













          • wrap your list of arguments with "

            – D.J.
            Nov 19 '18 at 12:36








          • 1





            It does not work at all when I wrap the arguments with ", even if I remove the /fl /flp part it throws an error because of the ".

            – ful-stackz
            Nov 19 '18 at 12:49






          • 1





            I found a solution! If I only wrap the /fl /flp part with " it works as expected. Thank you again!

            – ful-stackz
            Nov 19 '18 at 13:07



















          • Thank you for giving me hope! I've changed the build line to & $buildTools $solution /t:Clean,Build /p:Configuration=Release,Platform=x86 /fl1 /flp1:warningsonly;logfile=$warningsFile where $warningsFile is the path to a file in the same directory. This line however, throws the following error: The term 'logfile=$warningsFile' is not recognized as the name of a cmdlet, function, script file... What would you recommend me to try next?

            – ful-stackz
            Nov 19 '18 at 12:29













          • wrap your list of arguments with "

            – D.J.
            Nov 19 '18 at 12:36








          • 1





            It does not work at all when I wrap the arguments with ", even if I remove the /fl /flp part it throws an error because of the ".

            – ful-stackz
            Nov 19 '18 at 12:49






          • 1





            I found a solution! If I only wrap the /fl /flp part with " it works as expected. Thank you again!

            – ful-stackz
            Nov 19 '18 at 13:07

















          Thank you for giving me hope! I've changed the build line to & $buildTools $solution /t:Clean,Build /p:Configuration=Release,Platform=x86 /fl1 /flp1:warningsonly;logfile=$warningsFile where $warningsFile is the path to a file in the same directory. This line however, throws the following error: The term 'logfile=$warningsFile' is not recognized as the name of a cmdlet, function, script file... What would you recommend me to try next?

          – ful-stackz
          Nov 19 '18 at 12:29







          Thank you for giving me hope! I've changed the build line to & $buildTools $solution /t:Clean,Build /p:Configuration=Release,Platform=x86 /fl1 /flp1:warningsonly;logfile=$warningsFile where $warningsFile is the path to a file in the same directory. This line however, throws the following error: The term 'logfile=$warningsFile' is not recognized as the name of a cmdlet, function, script file... What would you recommend me to try next?

          – ful-stackz
          Nov 19 '18 at 12:29















          wrap your list of arguments with "

          – D.J.
          Nov 19 '18 at 12:36







          wrap your list of arguments with "

          – D.J.
          Nov 19 '18 at 12:36






          1




          1





          It does not work at all when I wrap the arguments with ", even if I remove the /fl /flp part it throws an error because of the ".

          – ful-stackz
          Nov 19 '18 at 12:49





          It does not work at all when I wrap the arguments with ", even if I remove the /fl /flp part it throws an error because of the ".

          – ful-stackz
          Nov 19 '18 at 12:49




          1




          1





          I found a solution! If I only wrap the /fl /flp part with " it works as expected. Thank you again!

          – ful-stackz
          Nov 19 '18 at 13:07





          I found a solution! If I only wrap the /fl /flp part with " it works as expected. Thank you again!

          – ful-stackz
          Nov 19 '18 at 13:07


















          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372774%2fazure-devops-display-build-warning%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

          Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

          ComboBox Display Member on multiple fields

          Is it possible to collect Nectar points via Trainline?