2016-04-06 03:38:36 +02:00
|
|
|
# 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).
|
|
|
|
|
2016-06-15 12:49:46 +02:00
|
|
|
We are using our own `Start-ResGen` to generate them.
|
|
|
|
|
|
|
|
Usually it's called as part of the regular build with
|
|
|
|
|
2019-03-05 21:45:46 +01:00
|
|
|
```powershell
|
|
|
|
Start-PSBuild -ResGen
|
2016-07-14 04:49:58 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
If you see compilation errors related to resources, try to call `Start-ResGen` explicitly.
|
|
|
|
|
2019-03-05 21:45:46 +01:00
|
|
|
```powershell
|
|
|
|
Start-ResGen
|
2016-06-15 12:49:46 +02:00
|
|
|
```
|
2016-04-06 03:38:36 +02:00
|
|
|
|
2016-07-17 15:48:26 +02:00
|
|
|
## Editing `.resx` files
|
2016-04-06 03:38:36 +02:00
|
|
|
|
2019-03-05 21:45:46 +01:00
|
|
|
**Don't edit** `.resx` files from Visual Studio.
|
2016-04-06 03:38:36 +02:00
|
|
|
It will try to create `.cs` files for you and you will get whole bunch of hard-to-understand errors.
|
|
|
|
|
2019-03-05 21:45:46 +01:00
|
|
|
To edit a resource file, use any **plain text editor**.
|
2016-07-20 19:48:58 +02:00
|
|
|
A resource file is a simple XML file, and it's easy to edit.
|
2016-07-14 04:49:58 +02:00
|
|
|
|
2016-07-17 15:48:26 +02:00
|
|
|
## Convert `.txt` resource files into `.resx` files
|
2016-07-14 04:49:58 +02:00
|
|
|
|
2016-07-17 15:48:26 +02:00
|
|
|
`dotnet cli` doesn't support embedding old-fashioned `.txt` resource.
|
2016-08-18 19:11:57 +02:00
|
|
|
You can do a one-time conversion of `.txt` resources into `.resx` files with a helper function:
|
2016-07-14 04:49:58 +02:00
|
|
|
|
2019-03-05 21:45:46 +01:00
|
|
|
```powershell
|
2016-07-14 04:49:58 +02:00
|
|
|
# example, converting all .txt resources under src\Microsoft.WSMan.Management\resources
|
2019-03-05 21:45:46 +01:00
|
|
|
Convert-TxtResourceToXml -Path src\Microsoft.WSMan.Management\resources
|
2016-07-14 04:49:58 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
`.resx` files would be placed next to `.txt` files.
|