msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

[Built-in analyzer] EmbeddedResource item is missing the Culture metadata

Open ladipro opened this issue 3 months ago • 5 comments

Background

This issue tracks one of the BuildCheck analyzers we would like to ship in-box with MSBuild.

Goal

Implement an analyzer with the following rule: EmbeddedResource items should not be defined without the Culture metadatum.

Notes

When Culture is missing, the culture is inferred from the file name. This is using the culture-name mapping of the currently running .NET runtime, which hurts build reproducibility.

ladipro avatar Mar 18 '24 11:03 ladipro

We'll also need good docs that say to do this because it's not the way it's been done for a long time (even though the way it has been done with the "guess at culture based on filename and cultures known to the OS" technique is bad and wrong).

rainersigwald avatar Mar 18 '24 14:03 rainersigwald

+1 on docs - each of our diagnostics should be able to specify some kind of help link to follow for each recognizable issue, and we should create the pages for each diagnostic (at least in a bare form) as we create them.

baronfel avatar Mar 18 '24 14:03 baronfel

It looks like the Culture metadatum is not documented at all 😮 https://learn.microsoft.com/en-us/visualstudio/msbuild/common-msbuild-project-items#embeddedresource

ladipro avatar Mar 18 '24 14:03 ladipro

Yeah the docs need here is twofold:

  1. Tell users they CAN and SHOULD do this.
  2. The specific page for this analyzer that points to that doc.

Hopefully for most of the analyzers we only need 2 but we should have a policy of checking for/updating 1 for all of them.

rainersigwald avatar Mar 18 '24 14:03 rainersigwald

I would prefer to not require Culture be set on individual items when <NeutralLanguage> is set and the item doesn't have a culture-specific extension.

sharwell avatar Mar 20 '24 22:03 sharwell