Code Inspections not allowing C# 6.0 language features
I have setup a build step using the Inspections (.NET) runner type to analyze a .NET solution. that has projects that target .NET 4.6.1. Those projects have the C# Language Level value set to C# 6.0 and locally the ReSharper inspections work correctly. They also work locally using the ReSharper Code Inspections command line tool.
However, when run in TeamCity the inspection tool is reporting usage of C# 6.0 code as C# 6.0 Language Feature compiler errors.
We are using TeamCity Enterprise 10.0.2 (build 42234) and ReSharper Inspections CLT 2016.2.2. That is the same version of the CLT that runs locally correctly. The .sln is built in a build step (using VS 2015) before the inspection step is run. I have also tried to set the inspection toolset to 14.
The inspection tool seems to be ignoring the .csproj language level settings and I don't know what other settings to use to enable C# 6 support in the inspection.
Please sign in to leave a comment.
Hello,
Could you please try to run the same build using the ReSharper Code Inspections command line tool on the TeamCity agent machine in the checkout directory? Please follow the guidelines.
If build runs via command line successfully but the dedicated runner does not while the options are all the same, please create a new issue in our tracker detailing the case. Please attach all the build step settings, the build log, all agent logs covering the build, the command you used in the console to run the build and the full console output of the build.
Thank you!
Alina, Thanks for the suggestion. I tried running the inspections using the ReSharper inspections CLT on the build server using the commands from the build log and that also reported the C# 6.0 code as errors but in doing this I noticed that the build was using a profile configuration file which looked like this:
<?xml version="1.0" encoding="UTF-8"?>
<InspectCodeOptions>
<Debug>true</Debug>
<OutputFile>D:\inspectcode-report-6662349013660088090.xml</OutputFile>
<SolutionFile>MySolution.sln</SolutionFile>
<CachesHomeDirectory>D:\dotnet-tools-inspectcode\8686525c6120e2e4</CachesHomeDirectory>
<CustomSettingsProfile>MySolution.sln.DotSettings</CustomSettingsProfile>
</InspectCodeOptions>
Remove that settings profile line and the inspections started working which pointed to the DotSettings file as the issue.
I had been running InspectCode.exe without specifying the DotSettings file (e.g. InspectCode.exe MySolution.sln) because the docs say it will it by default.
--profile (-p) : Path to the file to use custom settings from (default: Use R#'s solution shared settings if exists).
But that does not appear to be the case so I checked the MySolution.sln.DotSettings file it had this line in it:
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp50</s:String>
Changing that value to CSharp60 and now the inspections run correctly!
Hello,
Thank you for the update and sharing you solution!