New generated GeneratedMSBuildEditorConfig file since recent upgrade
Asked Answered
S

3

20

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?

Sprawl answered 7/10, 2020 at 10:2 Comment(0)
P
31

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>
Picrate answered 26/10, 2020 at 17:6 Comment(7)
Think you might have missed out a backslash between $(IntermediateOutputPath) and $(MSBuildProjectName)Sprawl
@Sprawl I can confirm that the backslash is needed. Without the file gets recreated.Inanition
You can deploy the workaround once for many projects by putting it in a Directory.Build.targets file (not .props, because $IntermediateOutputPath is not available yet at the stage the .props file is loaded)Pneumonectomy
It seems to be fixed in VS 2019 16.9, or .NET SDK 5.0.2 that's just released. I have remove the extra setting and not seen the file generated on the project root again.Trophic
For me, this still isn't fixed in VS 16.9.2 and dotnet SDK 5.0.201. But the workaround works perfectly for these non-SDK-style projects. Thanks!Stamp
How does this answer the question? Why is there a generated file being created when we already have a .editorconfig ?Ustulation
@davidbowser the generated file is used to pass certain msbuild values through to analyzers and generators. A user can tag certain data as being 'CompilerVisible' which causes the data to be written to this file, making it readable from the analyzer/generator via AnalyzerConfigOptions. The editorconfig standard specifies that arbitrary key values pairs are allowed by cores, so we re-use the format to pass this information in and parse via custom editorconfig plugin.Picrate
B
2

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?

Bitumen answered 7/10, 2020 at 17:17 Comment(3)
Not the OP, but for me the file is generated in the project's root. (e.g. ProjectName\ProjectName.GeneratedMSBuildEditorConfig.editorconfig). How can I fix this? The values of BaseIntermediateOutputPath and IntermediateOutputPath are obj\ and obj\x64\Debug\ respectively.Claudieclaudina
(Posted as issue here: github.com/dotnet/roslyn/issues/48430)Claudieclaudina
Jason, I see the same behaviour as @Bouke. It is created in the project root.Sprawl
Q
2

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.

Quasi answered 10/1, 2024 at 19:41 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.