Msbuild ignoring build errors
up vote
0
down vote
favorite
Context
I have a task integration testing and code coverage which I execute in my jenkins pipeline.
The tools used is dotcover and Nunit.
Nunit is executed throught dotcover during the integration test build when the configuration is Integration.
Problem
When I execute the configuration Integration in visual studio with some tests in error, then the build failed, everything are ok, but when the same configuration are executed with msbuild, it doesn't return any error code then jenkins pipelin doesn't fail.
The situation put us in delicate way because we can't trust our build pipeline anymore.
I looking for a solution on web for some days and I still on the same point, it's why I asking for your help here.
Thank you for helping.
Files
jenkinsfile
node('BUILD_PROJECT') {
stage ('Checkout')
{
checkout scm
}
stage ('Build')
{
bat '"C:/Program Files (x86)/NuGet/nuget.exe" restore -NonInteractive MySolution.sln'
bat ""C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin/MSBuild.exe" /p:Configuration=Release;AssemblyVersion=0.1.0.${env.BUILD_NUMBER} /maxcpucount:8 MySolution.sln"
}
stage ('Integration')
{
bat ""C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin/MSBuild.exe" /p:Configuration=Integration /maxcpucount:8 MySolution.sln"
}
stage ('Publish Coverage')
{
publishHTML target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'Solution/IntegrationProject/bin/Integration/TestResult',
reportFiles: 'ProjectCoverageReport.html',
reportName: 'Project Coverage Report'
]
}
stage ('Setup')
{
bat ""C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin/MSBuild.exe" /p:Configuration=Setup;Platform=x86;AssemblyVersion=0.1.0.${env.BUILD_NUMBER} /maxcpucount:8 MySolution.sln"
}
stage ('Archive')
{
archiveArtifacts artifacts: 'Solution/SetupProject/bin/x86/Setup/MySetup.exe'
}
}
In IntegrationProject.csproj
<Target Name="CoverageReport" AfterTargets="CopySqlFiles" Condition="$(Configuration) == Integration">
<Exec Command="..packagesJetBrains.dotCover.CommandLineTools.2018.1.3toolsdotCover.exe analyse /TargetExecutable=..packagesNUnit.ConsoleRunner.3.8.0toolsnunit3-console.exe /ReturnTargetExitCode /TargetArguments="$(TargetPath)" /Filters=-:nunit.framework;-:IntegrationProjectTest;-:type=MyNamespace.View.*;-:type=*Test /TargetWorkingDir=$(TargetDir) /Output=$(TargetDir)TestResultMyCoverageReport.html /ReportType=HTML" />
</Target>
msbuild nunit jenkins-pipeline msbuild-task dotcover
add a comment |
up vote
0
down vote
favorite
Context
I have a task integration testing and code coverage which I execute in my jenkins pipeline.
The tools used is dotcover and Nunit.
Nunit is executed throught dotcover during the integration test build when the configuration is Integration.
Problem
When I execute the configuration Integration in visual studio with some tests in error, then the build failed, everything are ok, but when the same configuration are executed with msbuild, it doesn't return any error code then jenkins pipelin doesn't fail.
The situation put us in delicate way because we can't trust our build pipeline anymore.
I looking for a solution on web for some days and I still on the same point, it's why I asking for your help here.
Thank you for helping.
Files
jenkinsfile
node('BUILD_PROJECT') {
stage ('Checkout')
{
checkout scm
}
stage ('Build')
{
bat '"C:/Program Files (x86)/NuGet/nuget.exe" restore -NonInteractive MySolution.sln'
bat ""C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin/MSBuild.exe" /p:Configuration=Release;AssemblyVersion=0.1.0.${env.BUILD_NUMBER} /maxcpucount:8 MySolution.sln"
}
stage ('Integration')
{
bat ""C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin/MSBuild.exe" /p:Configuration=Integration /maxcpucount:8 MySolution.sln"
}
stage ('Publish Coverage')
{
publishHTML target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'Solution/IntegrationProject/bin/Integration/TestResult',
reportFiles: 'ProjectCoverageReport.html',
reportName: 'Project Coverage Report'
]
}
stage ('Setup')
{
bat ""C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin/MSBuild.exe" /p:Configuration=Setup;Platform=x86;AssemblyVersion=0.1.0.${env.BUILD_NUMBER} /maxcpucount:8 MySolution.sln"
}
stage ('Archive')
{
archiveArtifacts artifacts: 'Solution/SetupProject/bin/x86/Setup/MySetup.exe'
}
}
In IntegrationProject.csproj
<Target Name="CoverageReport" AfterTargets="CopySqlFiles" Condition="$(Configuration) == Integration">
<Exec Command="..packagesJetBrains.dotCover.CommandLineTools.2018.1.3toolsdotCover.exe analyse /TargetExecutable=..packagesNUnit.ConsoleRunner.3.8.0toolsnunit3-console.exe /ReturnTargetExitCode /TargetArguments="$(TargetPath)" /Filters=-:nunit.framework;-:IntegrationProjectTest;-:type=MyNamespace.View.*;-:type=*Test /TargetWorkingDir=$(TargetDir) /Output=$(TargetDir)TestResultMyCoverageReport.html /ReportType=HTML" />
</Target>
msbuild nunit jenkins-pipeline msbuild-task dotcover
When you create a binary log (-bl
argument to Msbuild), does it show your project and target being executed? I suggest you use MSBuild Structured Log Viewer to dig into this.
– Martin Ullrich
Nov 21 at 11:16
Thank you for the tool i'll take a look.
– Jouan Antoine
Nov 21 at 11:26
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Context
I have a task integration testing and code coverage which I execute in my jenkins pipeline.
The tools used is dotcover and Nunit.
Nunit is executed throught dotcover during the integration test build when the configuration is Integration.
Problem
When I execute the configuration Integration in visual studio with some tests in error, then the build failed, everything are ok, but when the same configuration are executed with msbuild, it doesn't return any error code then jenkins pipelin doesn't fail.
The situation put us in delicate way because we can't trust our build pipeline anymore.
I looking for a solution on web for some days and I still on the same point, it's why I asking for your help here.
Thank you for helping.
Files
jenkinsfile
node('BUILD_PROJECT') {
stage ('Checkout')
{
checkout scm
}
stage ('Build')
{
bat '"C:/Program Files (x86)/NuGet/nuget.exe" restore -NonInteractive MySolution.sln'
bat ""C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin/MSBuild.exe" /p:Configuration=Release;AssemblyVersion=0.1.0.${env.BUILD_NUMBER} /maxcpucount:8 MySolution.sln"
}
stage ('Integration')
{
bat ""C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin/MSBuild.exe" /p:Configuration=Integration /maxcpucount:8 MySolution.sln"
}
stage ('Publish Coverage')
{
publishHTML target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'Solution/IntegrationProject/bin/Integration/TestResult',
reportFiles: 'ProjectCoverageReport.html',
reportName: 'Project Coverage Report'
]
}
stage ('Setup')
{
bat ""C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin/MSBuild.exe" /p:Configuration=Setup;Platform=x86;AssemblyVersion=0.1.0.${env.BUILD_NUMBER} /maxcpucount:8 MySolution.sln"
}
stage ('Archive')
{
archiveArtifacts artifacts: 'Solution/SetupProject/bin/x86/Setup/MySetup.exe'
}
}
In IntegrationProject.csproj
<Target Name="CoverageReport" AfterTargets="CopySqlFiles" Condition="$(Configuration) == Integration">
<Exec Command="..packagesJetBrains.dotCover.CommandLineTools.2018.1.3toolsdotCover.exe analyse /TargetExecutable=..packagesNUnit.ConsoleRunner.3.8.0toolsnunit3-console.exe /ReturnTargetExitCode /TargetArguments="$(TargetPath)" /Filters=-:nunit.framework;-:IntegrationProjectTest;-:type=MyNamespace.View.*;-:type=*Test /TargetWorkingDir=$(TargetDir) /Output=$(TargetDir)TestResultMyCoverageReport.html /ReportType=HTML" />
</Target>
msbuild nunit jenkins-pipeline msbuild-task dotcover
Context
I have a task integration testing and code coverage which I execute in my jenkins pipeline.
The tools used is dotcover and Nunit.
Nunit is executed throught dotcover during the integration test build when the configuration is Integration.
Problem
When I execute the configuration Integration in visual studio with some tests in error, then the build failed, everything are ok, but when the same configuration are executed with msbuild, it doesn't return any error code then jenkins pipelin doesn't fail.
The situation put us in delicate way because we can't trust our build pipeline anymore.
I looking for a solution on web for some days and I still on the same point, it's why I asking for your help here.
Thank you for helping.
Files
jenkinsfile
node('BUILD_PROJECT') {
stage ('Checkout')
{
checkout scm
}
stage ('Build')
{
bat '"C:/Program Files (x86)/NuGet/nuget.exe" restore -NonInteractive MySolution.sln'
bat ""C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin/MSBuild.exe" /p:Configuration=Release;AssemblyVersion=0.1.0.${env.BUILD_NUMBER} /maxcpucount:8 MySolution.sln"
}
stage ('Integration')
{
bat ""C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin/MSBuild.exe" /p:Configuration=Integration /maxcpucount:8 MySolution.sln"
}
stage ('Publish Coverage')
{
publishHTML target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'Solution/IntegrationProject/bin/Integration/TestResult',
reportFiles: 'ProjectCoverageReport.html',
reportName: 'Project Coverage Report'
]
}
stage ('Setup')
{
bat ""C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin/MSBuild.exe" /p:Configuration=Setup;Platform=x86;AssemblyVersion=0.1.0.${env.BUILD_NUMBER} /maxcpucount:8 MySolution.sln"
}
stage ('Archive')
{
archiveArtifacts artifacts: 'Solution/SetupProject/bin/x86/Setup/MySetup.exe'
}
}
In IntegrationProject.csproj
<Target Name="CoverageReport" AfterTargets="CopySqlFiles" Condition="$(Configuration) == Integration">
<Exec Command="..packagesJetBrains.dotCover.CommandLineTools.2018.1.3toolsdotCover.exe analyse /TargetExecutable=..packagesNUnit.ConsoleRunner.3.8.0toolsnunit3-console.exe /ReturnTargetExitCode /TargetArguments="$(TargetPath)" /Filters=-:nunit.framework;-:IntegrationProjectTest;-:type=MyNamespace.View.*;-:type=*Test /TargetWorkingDir=$(TargetDir) /Output=$(TargetDir)TestResultMyCoverageReport.html /ReportType=HTML" />
</Target>
msbuild nunit jenkins-pipeline msbuild-task dotcover
msbuild nunit jenkins-pipeline msbuild-task dotcover
edited Nov 21 at 15:42
Wai Ha Lee
5,640123662
5,640123662
asked Nov 21 at 10:22
Jouan Antoine
234
234
When you create a binary log (-bl
argument to Msbuild), does it show your project and target being executed? I suggest you use MSBuild Structured Log Viewer to dig into this.
– Martin Ullrich
Nov 21 at 11:16
Thank you for the tool i'll take a look.
– Jouan Antoine
Nov 21 at 11:26
add a comment |
When you create a binary log (-bl
argument to Msbuild), does it show your project and target being executed? I suggest you use MSBuild Structured Log Viewer to dig into this.
– Martin Ullrich
Nov 21 at 11:16
Thank you for the tool i'll take a look.
– Jouan Antoine
Nov 21 at 11:26
When you create a binary log (
-bl
argument to Msbuild), does it show your project and target being executed? I suggest you use MSBuild Structured Log Viewer to dig into this.– Martin Ullrich
Nov 21 at 11:16
When you create a binary log (
-bl
argument to Msbuild), does it show your project and target being executed? I suggest you use MSBuild Structured Log Viewer to dig into this.– Martin Ullrich
Nov 21 at 11:16
Thank you for the tool i'll take a look.
– Jouan Antoine
Nov 21 at 11:26
Thank you for the tool i'll take a look.
– Jouan Antoine
Nov 21 at 11:26
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
You should be able to make use of the dotcover parameter ReturnTargetExitCode to get the return code from nunit.
<Target Name="CoverageReport" AfterTargets="CopySqlFiles" Condition="$(Configuration) == Integration">
<Exec Command="..packagesJetBrains.dotCover.CommandLineTools.2018.1.3toolsdotCover.exe analyse ^
/TargetExecutable=..packagesNUnit.ConsoleRunner.3.8.0toolsnunit3-console.exe ^
/ReturnTargetExitCode ^
/TargetArguments="$(TargetPath)" ^
/Filters=-:nunit.framework;-:IntegrationProjectTest;-:type=MyNamespace.View.*;-:type=*Test ^
/TargetWorkingDir=$(TargetDir) ^
/Output=$(TargetDir)TestResultMyCoverageReport.html ^
/ReportType=HTML
/ReturnTargetExitCode">
<Output TaskParameter="ExitCode" PropertyName="DotCoverExitCode" />
</Exec>
<Message Text="Unit Tests Failed!" Condition="$(DotCoverExitCode) != '0'"/>
</Target>
1
Hello, your answer fix my problem, I used ReturnTargetExitCode, this parameter is in my task but I didn't used <Output /> then with this it's ok now. Thank you & regards
– Jouan Antoine
Nov 22 at 9:17
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
You should be able to make use of the dotcover parameter ReturnTargetExitCode to get the return code from nunit.
<Target Name="CoverageReport" AfterTargets="CopySqlFiles" Condition="$(Configuration) == Integration">
<Exec Command="..packagesJetBrains.dotCover.CommandLineTools.2018.1.3toolsdotCover.exe analyse ^
/TargetExecutable=..packagesNUnit.ConsoleRunner.3.8.0toolsnunit3-console.exe ^
/ReturnTargetExitCode ^
/TargetArguments="$(TargetPath)" ^
/Filters=-:nunit.framework;-:IntegrationProjectTest;-:type=MyNamespace.View.*;-:type=*Test ^
/TargetWorkingDir=$(TargetDir) ^
/Output=$(TargetDir)TestResultMyCoverageReport.html ^
/ReportType=HTML
/ReturnTargetExitCode">
<Output TaskParameter="ExitCode" PropertyName="DotCoverExitCode" />
</Exec>
<Message Text="Unit Tests Failed!" Condition="$(DotCoverExitCode) != '0'"/>
</Target>
1
Hello, your answer fix my problem, I used ReturnTargetExitCode, this parameter is in my task but I didn't used <Output /> then with this it's ok now. Thank you & regards
– Jouan Antoine
Nov 22 at 9:17
add a comment |
up vote
0
down vote
accepted
You should be able to make use of the dotcover parameter ReturnTargetExitCode to get the return code from nunit.
<Target Name="CoverageReport" AfterTargets="CopySqlFiles" Condition="$(Configuration) == Integration">
<Exec Command="..packagesJetBrains.dotCover.CommandLineTools.2018.1.3toolsdotCover.exe analyse ^
/TargetExecutable=..packagesNUnit.ConsoleRunner.3.8.0toolsnunit3-console.exe ^
/ReturnTargetExitCode ^
/TargetArguments="$(TargetPath)" ^
/Filters=-:nunit.framework;-:IntegrationProjectTest;-:type=MyNamespace.View.*;-:type=*Test ^
/TargetWorkingDir=$(TargetDir) ^
/Output=$(TargetDir)TestResultMyCoverageReport.html ^
/ReportType=HTML
/ReturnTargetExitCode">
<Output TaskParameter="ExitCode" PropertyName="DotCoverExitCode" />
</Exec>
<Message Text="Unit Tests Failed!" Condition="$(DotCoverExitCode) != '0'"/>
</Target>
1
Hello, your answer fix my problem, I used ReturnTargetExitCode, this parameter is in my task but I didn't used <Output /> then with this it's ok now. Thank you & regards
– Jouan Antoine
Nov 22 at 9:17
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
You should be able to make use of the dotcover parameter ReturnTargetExitCode to get the return code from nunit.
<Target Name="CoverageReport" AfterTargets="CopySqlFiles" Condition="$(Configuration) == Integration">
<Exec Command="..packagesJetBrains.dotCover.CommandLineTools.2018.1.3toolsdotCover.exe analyse ^
/TargetExecutable=..packagesNUnit.ConsoleRunner.3.8.0toolsnunit3-console.exe ^
/ReturnTargetExitCode ^
/TargetArguments="$(TargetPath)" ^
/Filters=-:nunit.framework;-:IntegrationProjectTest;-:type=MyNamespace.View.*;-:type=*Test ^
/TargetWorkingDir=$(TargetDir) ^
/Output=$(TargetDir)TestResultMyCoverageReport.html ^
/ReportType=HTML
/ReturnTargetExitCode">
<Output TaskParameter="ExitCode" PropertyName="DotCoverExitCode" />
</Exec>
<Message Text="Unit Tests Failed!" Condition="$(DotCoverExitCode) != '0'"/>
</Target>
You should be able to make use of the dotcover parameter ReturnTargetExitCode to get the return code from nunit.
<Target Name="CoverageReport" AfterTargets="CopySqlFiles" Condition="$(Configuration) == Integration">
<Exec Command="..packagesJetBrains.dotCover.CommandLineTools.2018.1.3toolsdotCover.exe analyse ^
/TargetExecutable=..packagesNUnit.ConsoleRunner.3.8.0toolsnunit3-console.exe ^
/ReturnTargetExitCode ^
/TargetArguments="$(TargetPath)" ^
/Filters=-:nunit.framework;-:IntegrationProjectTest;-:type=MyNamespace.View.*;-:type=*Test ^
/TargetWorkingDir=$(TargetDir) ^
/Output=$(TargetDir)TestResultMyCoverageReport.html ^
/ReportType=HTML
/ReturnTargetExitCode">
<Output TaskParameter="ExitCode" PropertyName="DotCoverExitCode" />
</Exec>
<Message Text="Unit Tests Failed!" Condition="$(DotCoverExitCode) != '0'"/>
</Target>
answered Nov 21 at 15:35
David Martin
8,41613260
8,41613260
1
Hello, your answer fix my problem, I used ReturnTargetExitCode, this parameter is in my task but I didn't used <Output /> then with this it's ok now. Thank you & regards
– Jouan Antoine
Nov 22 at 9:17
add a comment |
1
Hello, your answer fix my problem, I used ReturnTargetExitCode, this parameter is in my task but I didn't used <Output /> then with this it's ok now. Thank you & regards
– Jouan Antoine
Nov 22 at 9:17
1
1
Hello, your answer fix my problem, I used ReturnTargetExitCode, this parameter is in my task but I didn't used <Output /> then with this it's ok now. Thank you & regards
– Jouan Antoine
Nov 22 at 9:17
Hello, your answer fix my problem, I used ReturnTargetExitCode, this parameter is in my task but I didn't used <Output /> then with this it's ok now. Thank you & regards
– Jouan Antoine
Nov 22 at 9:17
add a comment |
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.
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%2f53409914%2fmsbuild-ignoring-build-errors%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
When you create a binary log (
-bl
argument to Msbuild), does it show your project and target being executed? I suggest you use MSBuild Structured Log Viewer to dig into this.– Martin Ullrich
Nov 21 at 11:16
Thank you for the tool i'll take a look.
– Jouan Antoine
Nov 21 at 11:26