Reputation: 4393
My test folder is set up as follows:
I have ran source monitor on its own from the command line and it runs to completion successfully and outputs some .xml files that I need for my CI process.
Below is my .proj file that I am trying to run:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Analyze" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildCommunityTasksPath>.</MSBuildCommunityTasksPath>
</PropertyGroup>
<Import Project="MSBuild.Community.Tasks.Targets"/>
<Target Name="Analyze">
<Exec Command="sm.exe /C sm-commands.xml"/>
<XmlRead XPath="//*/metric[@id='M0']" XmlFileName="sm-summary.xml">
<Output TaskParameter="Value" PropertyName="NumberOfLines" />
</XmlRead>
<TeamCityReportStatsValue Key="NumberOfLines" Value="$(NumberOfLines)" />
<XmlRead XPath="//*/metric[@id='M5']" XmlFileName="sm-summary.xml">
<Output TaskParameter="Value" PropertyName="MethodsPerClass" />
</XmlRead>
<TeamCityReportStatsValue Key="MethodsPerClass" Value="$(MethodsPerClass)" />
<XmlRead XPath="//*/metric[@id='M7']" XmlFileName="sm-summary.xml">
<Output TaskParameter="Value" PropertyName="StatementsPerMethod" />
</XmlRead>
<TeamCityReportStatsValue Key="StatementsPerMethod" Value="$(StatementsPerMethod)" />
<XmlRead XPath="//*/metric[@id='M10']" XmlFileName="sm-summary.xml">
<Output TaskParameter="Value" PropertyName="MaxComplexity" />
</XmlRead>
<TeamCityReportStatsValue Key="MaxComplexity" Value="$(MaxComplexity)" />
<XmlRead XPath="//*/metric[@id='M14']" XmlFileName="sm-summary.xml">
<Output TaskParameter="Value" PropertyName="AvgComplexity" />
</XmlRead>
<TeamCityReportStatsValue Key="AvgComplexity" Value="$(AvgComplexity)" />
</Target>
</Project>
I get the following error:
RESEARCH LINK:Article I am following
Upvotes: 0
Views: 565
Reputation: 10432
Exit code 1 is not really helpful. Try prepending your command with start cmd /k
(it'll escape MSBuild's sandbox redirect with a new cmd
window) and see if it prints anything else. One possibility for ERRORLEVEL 1
is MSBuild closing input stream so if sc.exe
is interactive and needs to read anything from the user it would terminate with exit code 1.
Also, after you manually "ran to completion successfully", did you check the exit code with echo %ERRORLEVEL%
? It might exit quietly and output some files but still technically fail with a non-0 exit code.
Upvotes: 1