Azure-DevOps display build warning











up vote
0
down vote

favorite












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




























    up vote
    0
    down vote

    favorite












    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


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      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 2 days ago

























      asked 2 days ago









      ful-stackz

      607




      607
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          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
            2 days ago












          • wrap your list of arguments with "
            – D.J.
            2 days ago








          • 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
            2 days ago






          • 1




            I found a solution! If I only wrap the /fl /flp part with " it works as expected. Thank you again!
            – ful-stackz
            2 days ago











          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%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








          up vote
          2
          down vote



          accepted










          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
            2 days ago












          • wrap your list of arguments with "
            – D.J.
            2 days ago








          • 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
            2 days ago






          • 1




            I found a solution! If I only wrap the /fl /flp part with " it works as expected. Thank you again!
            – ful-stackz
            2 days ago















          up vote
          2
          down vote



          accepted










          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
            2 days ago












          • wrap your list of arguments with "
            – D.J.
            2 days ago








          • 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
            2 days ago






          • 1




            I found a solution! If I only wrap the /fl /flp part with " it works as expected. Thank you again!
            – ful-stackz
            2 days ago













          up vote
          2
          down vote



          accepted







          up vote
          2
          down vote



          accepted






          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 2 days ago









          D.J.

          54929




          54929












          • 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
            2 days ago












          • wrap your list of arguments with "
            – D.J.
            2 days ago








          • 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
            2 days ago






          • 1




            I found a solution! If I only wrap the /fl /flp part with " it works as expected. Thank you again!
            – ful-stackz
            2 days ago


















          • 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
            2 days ago












          • wrap your list of arguments with "
            – D.J.
            2 days ago








          • 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
            2 days ago






          • 1




            I found a solution! If I only wrap the /fl /flp part with " it works as expected. Thank you again!
            – ful-stackz
            2 days ago
















          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
          2 days ago






          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
          2 days ago














          wrap your list of arguments with "
          – D.J.
          2 days ago






          wrap your list of arguments with "
          – D.J.
          2 days ago






          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
          2 days ago




          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
          2 days ago




          1




          1




          I found a solution! If I only wrap the /fl /flp part with " it works as expected. Thank you again!
          – ful-stackz
          2 days ago




          I found a solution! If I only wrap the /fl /flp part with " it works as expected. Thank you again!
          – ful-stackz
          2 days ago


















           

          draft saved


          draft discarded



















































           


          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

          Wiesbaden

          Marschland

          Dieringhausen