Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

GenerateResource Task 

Converts between .txt and .resx (XML-based resource format) files and common language runtime binary .resources files that can be embedded in a runtime binary executable or compiled into satellite assemblies. This task is typically used to convert .txt or .resx files to .resource files. The GenerateResource task is functionally similar to resgen.exe.

The following table describes the parameters of the GenerateResource task.

Parameter Description

FilesWritten

Optional ITaskItem[] output parameter.

Contains the names of all files written to disk. This includes the cache file, if any. This parameter is useful for implementations of Clean.

OutputResources

Optional ITaskItem[] output parameter.

Specifies the name of the generated files, such as .resources files. If you do not specify a name, the name of the matching input file is used and the .resources file that is created is placed in the directory that contains the input file.

PublicClass

Optional Boolean parameter.

If true, creates a strongly typed resource class as a public class.

References

Optional String[] parameter.

References to load types in .resx files from. Resx file data elements may have a .NET type. When the .resx file is read, this must be resolved. Typically it is resolved successfully using standard type loading rules. If you provide assemblies in References, they take precedence.

This parameter is not required for strongly typed resources.

Sources

Required ITaskItem[] parameter.

Specifies the items to convert. Items passed to this parameter must have one of the following file extensions:

  • .txt: Specifies the extension for a text file to convert. Text files can only contain string resources.

  • .resx: Specifies the extension for an XML-based resource file to convert.

  • .restext: Specifies the same format as .txt. This diferent extension is useful if you want to clearly distinguish source files that contain resources from other source files in your build process.

  • .resources: Specifies the extension for a resource file to convert.

StateFile

Optional ITaskItem parameter.

Specifies the path to an optional cache file used to speed up dependency checking of links in .resx input files.

StronglyTypedClassName

Optional String parameter.

Specifies the class name for the strongly typed resource class. If this parameter is not specified, the base name of the resource file is used.

StronglyTypedFilename

Optional ITaskItem parameter.

Specifies the filename for the source file. If this parameter is not specified, the name of the class is used as the base filename, with the extension dependent on the language. For example: MyClass.cs.

StronglyTypedLanguage

Optional String parameter.

Specifies the language to use when generating the class source for the strongly typed resource. This parameter must match exactly one of the languages used by the CodeDomProvider. For example: VB or C#.

Passing a value to this parameter instructs the task to generate strongly typed resources.

StronglyTypedNamespace

Optional String parameter.

Specifies the namespace to use for the generated class source for the strongly typed resource. If this parameter is not specified, any strongly typed resources are in the global namespace.

UseSourcePath

Optional Boolean parameter.

If true, specifies that the input file's directory is to be used for resolving relative file paths.

Because .resx files may contain links to other resource files, it is not sufficient to simply compare .resx and .resource file timestamps to see if the outputs are up-to-date. Instead, the GenerateResource task follows the links in the .resx files and checks the timestamps of the linked files as well. This means that you should not generally use Inputs and Outputs attributes on the target containing the GenerateResource task, as this may cause it to be skipped when it should actually run.

The following example uses the GenerateResource task to generate .resources files from the files specified by the Resx item collection.

<GenerateResource
    Sources="@(Resx)"
    OutputResources="@(Resx->'$(IntermediateOutputPath)%(Identity).resources')"/>
    <Output
        TaskParameter="OutputResources"
        ItemName="Resources"/>
</GenerateResource>
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft