PowerShell/docs/workflow/resources.md

42 lines
1.2 KiB
Markdown
Raw Normal View History

# Resources
Resources are `.resx` files with string values that we use for error messages and such.
They live in `src\<project>\resources` folders.
At the moment `dotnet cli` doesn't support generating C# bindings (strongly typed resource files).
We are using our own `Start-ResGen` to generate them.
Usually it's called as part of the regular build with
```
2016-07-14 04:49:58 +02:00
PS C:\> Start-PSBuild -ResGen
```
If you see compilation errors related to resources, try to call `Start-ResGen` explicitly.
```
PS C:\> Start-ResGen
```
## Editing resx files
**Don't edit** resx files from Visual Studio.
It will try to create `.cs` files for you and you will get whole bunch of hard-to-understand errors.
To edit resource file, use any **plain text editor**.
Resource file is a simple xml, and it's easy to edit.
2016-07-14 04:49:58 +02:00
## Convert txt resource files into resx
`dotnet cli` doesn't support embeeding old-fashioned txt resource.
You can do a one-time convertion of `.txt` resources into `.resx` files with a helper function
```
# example, converting all .txt resources under src\Microsoft.WSMan.Management\resources
PS C:\> Convert-TxtResourceToXml -Path src\Microsoft.WSMan.Management\resources
```
`.resx` files would be placed next to `.txt` files.