Roslyn: When using msbuild for a solution containing multiple projects, with the /p:ErrorLog parameter, it only saves Roslyn Analyzers' results for the last project but not for the other projects.

Created on 18 Jan 2018  ·  4Comments  ·  Source: dotnet/roslyn

Version Used: MSBuild.exe v14.0 and v15.0

Steps to Reproduce:

  1. Create a solution and add more than one C# project to it.
  2. Create a .targets which includes some paths to the Roslyn analyzers, and save it in the folder $(MSBuildUserExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.CSharp.targets\ImportAfter
  3. Run a MSBuild command line, like this:
    MSBuild.exe SolutionWithMultipleProjects.sln [options] /p:ErrorLog=OutputName.sarif
  4. Check the analysis results in the output OutputName.sarif.

Expected Behavior:
/p:ErrorLog will save the Roslyn analysis results for all the projects in a solution.

Actual Behavior:
/p:ErrorLog only saves the Roslyn analysis results for the last project.

Area-Compilers Feature Request

Most helpful comment

FYI: The following workaround resolved this issue and we don't need this feature request anymore:

Are you guys on MSBuild 15+? If so, https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build might be the simplest solution for your problem. Just define a props at the root directory of the solution that sets the property ErrorLog to “$(MSBuildProjectFullPath).json”

All 4 comments

Note the effective ask here is for /errorlog compiler switch to append to the given error log file as opposed to overwrite.

Workaround for the customer is to use separate error log files per-project, but they would prefer generating a single error log file for the entire solution.

Thanks, Manish.
To clarify this is more of a blocking issue for us, than a preference. We cannot easily call MSBuild once per project; we're just 'replaying' the MSBuild cmd that was done earlier in the build.

@jcouv for triaging

FYI: The following workaround resolved this issue and we don't need this feature request anymore:

Are you guys on MSBuild 15+? If so, https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build might be the simplest solution for your problem. Just define a props at the root directory of the solution that sets the property ErrorLog to “$(MSBuildProjectFullPath).json”

Was this page helpful?
0 / 5 - 0 ratings