New generated GeneratedMSBuildEditorConfig file since recent upgrade

16.3k views Asked by At

I have been upgrading a project and since the latest version of Visual Studio 2019 was installed have found the following file being output to disk

MyProjectName.GeneratedMSBuildEditorConfig.editorconfig

I think that this is related to the roslyn compiler and was introduced in this commit: https://github.com/dotnet/roslyn/commit/de348c5a77977459a4138de0a62487e00980e28a#diff-e87b4990385fcfea8cf3f744bb8ad23e

The obvious questions have arisen as to what this file is, what it does and whether it should be in source control or excluded. I know what .editorconfig files are for but this one was unexpected. My searching has turned up nothing. Can anyone shed any light on this?

3

There are 3 answers

5
Chris Sienkiewicz On BEST ANSWER

Update: This is fixed in Visual Studio 16.9 and higher.


There is a bug when using legacy/non SDK-style projects, which causes these files to be output to the wrong location. We have a fix out for this here: https://github.com/dotnet/roslyn/pull/48781

In the interim as a workaround you can set the generated file output path explicitly by adding the following to your project file

<PropertyGroup>
    <GeneratedMSBuildEditorConfigFile>$(IntermediateOutputPath)\$(MSBuildProjectName).GeneratedMSBuildEditorConfig.editorconfig</GeneratedMSBuildEditorConfigFile>
</PropertyGroup>
3
Jason Malinowski On

The right pull request is this one -- it's built as a way for some MSBuild logic to pass values to certain Roslyn analyzers. This is internal implementation detail and shouldn't be checked in to source control.

I'm surprised you noticed this file though -- it should be generated into your obj\ directory, which you should already have excluded from source control and never really noticed in the first place. Did it get generated somewhere else?

0
Greg On

Make sure your project name isn't too long.

I had a similar problem, and I tried several suggested solutions, but none of them worked. In the end the solution was just to shorten the project name.