AssignCulture Task

 

For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.

For the latest documentation on Visual Studio 2017, see AssignCulture Task on docs.microsoft.com. This task accepts a list of items that may contain a valid .NET culture identifier string as part of the file name, and produces items that have a metadata named Culture containing the corresponding culture identifier. For example, the file name Form1.fr-fr.resx has an embedded culture identifier "fr-fr", so this task will produce an item that has the same filename with the metadata Culture equal to fr-fr. The task also produces a list of filenames with the culture removed from the filename.

The following table describes the parameters of the AssignCulture task.

ParameterDescription
AssignedFilesOptional ITaskItem[] output parameter.

Contains the list of items received in the Files parameter, with a Culture metadata entry added to each item.

If the incoming item from the Files parameter already contains a Culture metadata entry, the original metadata entry is used.

The task only assigns a Culture metadata entry if the file name contains a valid culture identifier. The culture identifier must be between the last two dots in the filename.
AssignedFilesWithCultureOptional ITaskItem[] output parameter.

Contains the subset of the items from the AssignedFiles parameter that have a Culture metadata entry.
AssignedFilesWithNoCultureOptional ITaskItem[] output parameter.

Contains the subset of the items from the AssignedFiles parameter that do not have a Culture metadata entry.
CultureNeutralAssignedFilesOptional ITaskItem[] output parameter.

Contains the same list of items that is produced in the AssignedFiles parameter, except with the culture removed from the file name.

The task only removes the culture from the file name if it is a valid culture identifier.
FilesRequired ITaskItem[] parameter.

Specifies the list of files with embedded culture names to assign a culture to.

In addition to the parameters listed above, this task inherits parameters from the TaskExtension class, which itself inherits from the Task class. For a list of these additional parameters and their descriptions, see TaskExtension Base Class.

The following example executes the AssignCulture task with the ResourceFiles item collection.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">  
    <ItemGroup>  
        <ResourceFiles Include="MyResource1.fr.resx"/>  
        <ResourceFiles Include="MyResource2.XX.resx"/>  
    </ItemGroup>  
  
    <Target Name="Culture">  
        <AssignCulture  
            Files="@(ResourceFiles)"  
            <Output TaskParameter="AssignedFiles"  
                ItemName="OutAssignedFiles"/>  
            <Output TaskParameter="AssignedFilesWithCulture"  
                ItemName="OutAssignedFilesWithCulture"/>  
            <Output TaskParameter="AssignedFilesWithNoCulture"  
                ItemName="OutAssignedFilesWithNoCulture"/>  
            <Output TaskParameter="CultureNeutralAssignedFiles"  
                ItemName="OutCultureNeutralAssignedFiles"/>  
        </AssignCulture>  
    </Target>  
</Project>  

The following table describes the value of the output items after task execution. Item metadata is shown in parenthesis after the item.

Item collectionContents
OutAssignedFilesMyResource1.fr.resx (Culture="fr")

 MyResource2.XX.resx (no additional metadata)
OutAssignedFilesWithCultureMyResource1.fr.resx (Culture="fr")
OutAssignedFilesWithNoCultureMyResource2.XX.resx (no additional metadata)
OutCultureNeutralAssignedFilesMyResource1.resx (Culture="fr")

 MyResource2.XX.resx (no additional metadata)

Tasks
Task Reference

Show: