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"
c# azure msbuild continuous-integration azure-devops
add a comment |
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"
c# azure msbuild continuous-integration azure-devops
add a comment |
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"
c# azure msbuild continuous-integration azure-devops
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
c# azure msbuild continuous-integration azure-devops
edited 2 days ago
asked 2 days ago
ful-stackz
607
607
add a comment |
add a comment |
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)
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
add a comment |
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)
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
add a comment |
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)
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
add a comment |
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)
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)
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
add a comment |
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
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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