|
| 1 | +### Resource manifest file names |
| 2 | + |
| 3 | +Starting in .NET Core 3.0, the generated resource manifest file name has changed. |
| 4 | + |
| 5 | +#### Version introduced |
| 6 | + |
| 7 | +3.0 |
| 8 | + |
| 9 | +#### Change description |
| 10 | + |
| 11 | +Prior to .NET Core 3.0, when [DependentUpon](/visualstudio/msbuild/common-msbuild-project-items#compile) metadata was set for a resource (*.resx*) file in the MSBuild project file, the generated manifest name was *Namespace.Classname.resources*. When [DependentUpon](/visualstudio/msbuild/common-msbuild-project-items#compile) was not set, the generated manifest name was *Namespace.Classname.FolderPathRelativeToRoot.Culture.resources*. |
| 12 | + |
| 13 | +Starting in .NET Core 3.0, when a *.resx* file is colocated with a source file of the same name, for example, in Windows Forms apps, the resource manifest name is generated from the full name of the first type in the source file. For example, if *Type.cs* is colocated with *Type.resx*, the generated manifest name is *Namespace.Classname.resources*. However, if you modify any of the attributes on the `EmbeddedResource` property for the *.resx* file, the generated manifest file name may be different: |
| 14 | + |
| 15 | +- If the `LogicalName` attribute on the `EmbeddedResource` property is set, that value is used as the resource manifest file name. |
| 16 | + |
| 17 | + Examples: |
| 18 | + |
| 19 | + ```xml |
| 20 | + <EmbeddedResource Include="X.resx" LogicalName="SomeName.resources" /> |
| 21 | + -or- |
| 22 | + <EmbeddedResource Include="X.fr-FR.resx" LogicalName="SomeName.resources" /> |
| 23 | + ``` |
| 24 | + |
| 25 | + **Generated resource manifest file name**: *SomeName.resources* (regardless of the *.resx* file name or culture or any other metadata). |
| 26 | + |
| 27 | +- If `LogicalName` is not set, but the `ManifestResourceName` attribute on the `EmbeddedResource` property is set, its value, combined with the file extension *.resources*, is used as the resource manifest file name. |
| 28 | + |
| 29 | + Examples: |
| 30 | + |
| 31 | + ```xml |
| 32 | + <EmbeddedResource Include="X.resx" ManifestResourceName="SomeName" /> |
| 33 | + -or- |
| 34 | + <EmbeddedResource Include="X.fr-FR.resx" ManifestResourceName="SomeName.fr-FR" /> |
| 35 | + ``` |
| 36 | + |
| 37 | + **Generated resource manifest file name**: *SomeName.resources* or *SomeName.fr-FR.resources*. |
| 38 | + |
| 39 | +- If the previous rules don't apply, and the `DependentUpon` attribute on the `EmbeddedResource` element is set to a source file, the type name of the first class in the source file is used in the resource manifest file name. More specifically, the generated file name is *Namespace.Classname\[.Culture].resources*. |
| 40 | + |
| 41 | + Examples: |
| 42 | + |
| 43 | + ```xml |
| 44 | + <EmbeddedResource Include="X.resx" DependentUpon="MyTypes.cs"> |
| 45 | + -or- |
| 46 | + <EmbeddedResource Include="X.fr-FR.resx" DependentUpon="MyTypes.cs"> |
| 47 | + ``` |
| 48 | + |
| 49 | + **Generated resource manifest file name**: *Namespace.Classname.resources* or *Namespace.Classname.fr-FR.resources* (where `Namespace.Classname` is the name of the first class in *MyTypes.cs*). |
| 50 | + |
| 51 | +- If the previous rules don't apply, `EmbeddedResourceUseDependentUponConvention` is `true` (the default for .NET Core), and there's a source file colocated with a *.resx* file that has the same base file name, the *.resx* file is made dependent upon the matching source file, and the generated name is the same as in the previous rule. This is the "default settings" rule for .NET Core projects. |
| 52 | + |
| 53 | + Examples: |
| 54 | + |
| 55 | + Files *MyTypes.cs* and *MyTypes.resx* or *MyTypes.fr-FR.resx* exist in the same folder. |
| 56 | + |
| 57 | + **Generated resource manifest file name**: *Namespace.Classname.resources* or *Namespace.Classname.fr-FR.resources* (where `Namespace.Classname` is the name of the first class in *MyTypes.cs*). |
| 58 | + |
| 59 | +- If none of the previous rules apply, the generated resource manifest file name is *RootNamespace.RelativePathWithDotsForSlashes.\[Culture.]resources*. The relative path is the value of the `Link` attribute of the `EmbeddedResource` element if it's set. Otherwise, the relative path is the value of the `Identity` attribute of the `EmbeddedResource` element. In Visual Studio, this is the path from the project root to the file in Solution Explorer. |
| 60 | + |
| 61 | +#### Recommended action |
| 62 | + |
| 63 | +If you're unsatisfied with the generated manifest names, you can: |
| 64 | + |
| 65 | +- Modify your resource file metadata according to one of the previously described naming rules. |
| 66 | + |
| 67 | +- Set `EmbeddedResourceUseDependentUponConvention` to `false` in your project file to opt out of the new convention entirely: |
| 68 | + |
| 69 | + ```xml |
| 70 | + <EmbeddedResourceUseDependentUponConvention>false</EmbeddedResourceUseDependentUponConvention> |
| 71 | + ``` |
| 72 | + |
| 73 | + > [!NOTE] |
| 74 | + > If the `LogicalName` or `ManifestResourceName` attributes are present, their values will still be used for the generated file name. |
| 75 | +
|
| 76 | +#### Category |
| 77 | + |
| 78 | +MSBuild |
| 79 | + |
| 80 | +#### Affected APIs |
| 81 | + |
| 82 | +N/A |
0 commit comments