I am trying to write a MSBuild Targets file to integrate TSLint into the build system of our project. I can get the the lint task to break the build correctly but cannot seem to find a way to get the Errors in the Errors and Warnings window to navigate to the correct file which was the source of the error. The file field for the error in the Errors and Warnings window is shown as Exec and not the actual file which was the source of the error. My Targets file looks something like this.
<NodeExePath>$(WorkspaceDirectory)\packages\node.8.9.2\files\node.exe</NodeExePath>
<TsLintPath>$(WorkspaceDirectory)\packages\tslint.5.9.1\tools\node_modules\tslint\bin\tslint</TsLintPath>
</PropertyGroup>
<Target Name="TSLint">
<Exec
Command=""$(NodeExePath)" "$(TsLintPath)" -p $(MSBuildProjectDirectory)"
WorkingDirectory="$(MSBuildProjectDirectory)"
ConsoleToMsBuild="true"
EchoOff="true"
IgnoreExitCode="true">
<Output TaskParameter="ConsoleOutput" ItemName="TSLintOutput" />
<Output TaskParameter="ExitCode" PropertyName="TSLintErrorCode" />
</Exec>
<!-- Return an error if TSLint returned an exit code and we should break on errors -->
<Error Condition="'$(TSLintErrorCode)' != '0'" />
</Target>`
I tried using the Targets file from the TSLint.MSBuild NuGet package but ran into issues with it if I try to use the tsconfig json to specify the files to lint. That Targets file somehow seems to be able to produce errors where I can navigate to the errors but couldn't figure out how.
Try adding the option
--format "msbuild"in your command. TSLint will format the results for you.