Skip to content

Commit ae7f020

Browse files
committed
Update README.md for clarity and organization; enhance CLI examples and instructions
1 parent b9695a5 commit ae7f020

1 file changed

Lines changed: 126 additions & 33 deletions

File tree

README.md

Lines changed: 126 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,169 @@
1-
# Dataverse Wrapper Generator
1+
# Dataverse Plugin Wrapper Generator
22

3-
A C# console application that generates strongly typed entity classes and option set enums from a Dataverse solution zip (`customizations.xml`).
3+
Generate strongly typed C# wrappers and option set enums from a Dataverse solution zip (`customizations.xml`).
44

5-
## Features
5+
This tool reads Dataverse metadata and writes:
6+
- `OptionSets/OptionValueSets.cs` with global option set enums and state enums
7+
- `Entities/*.cs` wrapper classes with CRUD helpers (`Create`, `Retrieve`, `Update`, `Delete`)
68

7-
- Parses `customizations.xml` from a Dataverse solution zip.
8-
- Generates option set enums in `OptionSets/OptionValueSets.cs`.
9-
- Generates entity wrapper classes with `Create`, `Retrieve`, `Update`, and `Delete` methods.
10-
- Supports overwrite prompts (or `--yes` to skip prompts).
11-
- Supports entity filtering with `--filter`.
9+
## What This Project Is
1210

13-
## Getting Started
11+
- A .NET console app (`DataversePluginWrapper`) that parses Dataverse solution metadata.
12+
- A code generator only. It does not deploy to Dataverse.
13+
- Supports both:
14+
- CLI mode (arguments)
15+
- Interactive mode (no arguments)
1416

15-
### 1. Clone and build
17+
## Prerequisites
18+
19+
- .NET 6 SDK or later installed
20+
- A Dataverse solution zip containing `customizations.xml`
21+
22+
Check SDK:
23+
24+
```sh
25+
dotnet --version
26+
```
27+
28+
## Build
1629

1730
```sh
18-
git clone https://github.com/EricLott/DataversePluginWrapper.git
19-
cd DataversePluginWrapper
31+
dotnet restore
2032
dotnet build
2133
```
2234

23-
### 2. Run
35+
## Run
36+
37+
### Interactive mode (recommended for first-time use)
38+
39+
Run with no arguments:
2440

2541
```sh
26-
dotnet run -- -z path/to/your/solution.zip -o ./Generated
42+
dotnet run --
2743
```
2844

29-
## Usage
45+
You will be prompted for:
46+
- solution zip path
47+
- output directory
48+
- optional entity-name filter
49+
- verbose logging toggle
50+
- overwrite behavior
51+
- final confirmation
3052

31-
```text
32-
DataverseWrapper -z <path_to_solution_zip> [options]
33-
DataverseWrapper (interactive mode)
53+
### CLI mode
3454

35-
Options:
36-
-z, --zip <path> Path to Dataverse solution zip (required)
37-
-o, --out <dir> Output directory (default: ./GeneratedClasses_{timestamp})
38-
-f, --filter <text> Only generate for entities whose display name contains text
39-
-v, --verbose Verbose logging
40-
-y, --yes Overwrite existing files without prompt
41-
-h, --help Show help
55+
```sh
56+
dotnet run -- -z <path_to_solution_zip> [options]
4257
```
4358

44-
If you run the executable with no arguments, it starts a guided interactive flow and prompts for zip path, output folder, optional filter, and overwrite behavior.
59+
Options:
60+
61+
- `-z, --zip <path>`: path to Dataverse solution zip (required)
62+
- `-o, --out <dir>`: output directory (default: `./GeneratedClasses_{timestamp}`)
63+
- `-f, --filter <text>`: generate only entities whose display name contains text
64+
- `-v, --verbose`: verbose logging
65+
- `-y, --yes`: overwrite existing files without prompt
66+
- `-h, --help`: show help
4567

46-
### Examples
68+
### CLI examples
4769

48-
Generate all:
70+
Generate everything:
4971

5072
```sh
5173
dotnet run -- -z ./MySolution.zip
5274
```
5375

54-
Generate entities containing "Contact":
76+
Generate only entities containing `Contact`:
5577

5678
```sh
5779
dotnet run -- -z ./MySolution.zip -f Contact
5880
```
5981

60-
Overwrite without prompts:
82+
Write to a fixed folder and overwrite existing files:
6183

6284
```sh
63-
dotnet run -- -z ./MySolution.zip -o ./OutDir -y
85+
dotnet run -- -z ./MySolution.zip -o ./Generated -y
6486
```
6587

66-
## Output Structure
88+
## Publish an EXE
89+
90+
Windows x64 example:
91+
92+
```sh
93+
dotnet publish -c Release -r win-x64 --self-contained false
94+
```
95+
96+
Output executable will be under:
97+
98+
`bin/Release/net6.0/win-x64/publish/`
99+
100+
Run the EXE directly:
101+
- no args -> interactive mode
102+
- with args -> CLI mode
103+
104+
## Output Layout
67105

68106
```text
69-
GeneratedClasses_20250919/
107+
GeneratedClasses_20260221_153000/
70108
|-- OptionSets/
71109
| `-- OptionValueSets.cs
72110
`-- Entities/
73111
|-- Account.cs
74112
|-- Contact.cs
75113
`-- ...
76114
```
115+
116+
## Generated Code Notes
117+
118+
- Generated entity wrappers use Dataverse SDK types (`IOrganizationService`, `Entity`, `EntityReference`, `OptionSetValue`, etc.).
119+
- Option set/state values are mapped to enums where possible.
120+
- Status reason is generated as numeric backing (`int?`) with enum helper behavior.
121+
- Lookups/owners/customers are generated as `EntityReference`.
122+
123+
## Consuming Generated Files
124+
125+
In the project where you use generated files, ensure Dataverse SDK references are available (for example, `Microsoft.Xrm.Sdk`).
126+
127+
If your consuming project does not reference SDK assemblies, generated files will not compile.
128+
129+
## Exit Codes
130+
131+
- `0`: success
132+
- `1`: unexpected error
133+
- `2`: argument/path error
134+
- `3`: XML parsing error
135+
- `4`: invalid data shape
136+
- `130`: user canceled (Ctrl+C or interactive cancel)
137+
138+
## Troubleshooting
139+
140+
### "customizations.xml not found in zip"
141+
142+
- Ensure the zip is a Dataverse solution export.
143+
- Verify the archive includes `customizations.xml`.
144+
145+
### No entities generated
146+
147+
- Check whether `--filter` excluded all entities.
148+
- Run without filter to validate metadata extraction.
149+
150+
### Existing files are skipped
151+
152+
- Use `-y`/`--yes`, or answer `y` at overwrite prompts.
153+
154+
### Build succeeds but generated code fails in another project
155+
156+
- Add Dataverse SDK references to the consuming project.
157+
- Validate that generated namespace/import placement matches your project conventions.
158+
159+
## Development
160+
161+
Local project files:
162+
- `Program.cs`: generator implementation
163+
- `DataversePluginWrapper.csproj`: project configuration
164+
165+
Build locally before committing:
166+
167+
```sh
168+
dotnet build
169+
```

0 commit comments

Comments
 (0)