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=&quot;$(TargetPath)&quot; /Filters=-:nunit.framework;-:IntegrationProjectTest;-:type=MyNamespace.View.*;-:type=*Test /TargetWorkingDir=$(TargetDir) /Output=$(TargetDir)TestResultMyCoverageReport.html /ReportType=HTML" />
</Target>









share|improve this question
























  • 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















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=&quot;$(TargetPath)&quot; /Filters=-:nunit.framework;-:IntegrationProjectTest;-:type=MyNamespace.View.*;-:type=*Test /TargetWorkingDir=$(TargetDir) /Output=$(TargetDir)TestResultMyCoverageReport.html /ReportType=HTML" />
</Target>









share|improve this question
























  • 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













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=&quot;$(TargetPath)&quot; /Filters=-:nunit.framework;-:IntegrationProjectTest;-:type=MyNamespace.View.*;-:type=*Test /TargetWorkingDir=$(TargetDir) /Output=$(TargetDir)TestResultMyCoverageReport.html /ReportType=HTML" />
</Target>









share|improve this question















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=&quot;$(TargetPath)&quot; /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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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












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=&quot;$(TargetPath)&quot; ^
/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>





share|improve this answer

















  • 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













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%2f53409914%2fmsbuild-ignoring-build-errors%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
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=&quot;$(TargetPath)&quot; ^
/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>





share|improve this answer

















  • 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

















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=&quot;$(TargetPath)&quot; ^
/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>





share|improve this answer

















  • 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















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=&quot;$(TargetPath)&quot; ^
/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>





share|improve this answer












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=&quot;$(TargetPath)&quot; ^
/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>






share|improve this answer












share|improve this answer



share|improve this answer










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
















  • 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




















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%2f53409914%2fmsbuild-ignoring-build-errors%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

Berounka

Sphinx de Gizeh

Different font size/position of beamer's navigation symbols template's content depending on regular/plain...