Skip to content

Commit f890f3c

Browse files
committed
Provide public documented extension point to add resources
This follows the pattern we have in other packages.
1 parent bae6b79 commit f890f3c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/ThisAssembly.Resources/ThisAssembly.Resources.targets

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828
</EmbeddedResource>
2929
</ItemDefinitionGroup>
3030

31+
<Target Name="PrepareEmbeddedResources" DependsOnTargets="PrepareResourceNames" />
32+
3133
<Target Name="_InjectResourcesAdditionalFiles"
3234
BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun"
33-
DependsOnTargets="PrepareResourceNames">
35+
DependsOnTargets="PrepareEmbeddedResources">
3436
<ItemGroup>
3537
<EmbeddedResource Condition="!$([System.IO.Path]::IsPathRooted('%(RelativeDir)')) OR '%(Link)' != ''">
3638
<AreaPath Condition="!$([System.IO.Path]::IsPathRooted('%(RelativeDir)'))">%(RelativeDir)%(Filename)</AreaPath>

src/ThisAssembly.Resources/readme.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,19 @@ The following MSBuild properties can be used to customize the generated code:
5252
| ThisAssemblyNamespace | Sets the namespace of the generated `ThisAssembly` root class. If not set, it will be in the global namespace. |
5353
| ThisAssemblyVisibility | Sets the visibility modifier of the generated `ThisAssembly` root class. If not set, it will be internal. |
5454

55+
## Adding dynamic resources
56+
57+
You can also provide additional embedded resources dynamically, by running a target before
58+
`PrepareEmbeddedResources`:
59+
60+
```xml
61+
<Target Name="AddDynamicResources" BeforeTargets="PrepareEmbeddedResources">
62+
<ItemGroup>
63+
<EmbeddedResource Include="Content/Docs/$(Configuration).md" />
64+
</ItemGroup>
65+
</Target>
66+
```
67+
5568
<!-- #resources -->
5669
<!-- include https://github.com/devlooped/sponsors/raw/main/footer.md -->
5770
<!-- exclude -->

0 commit comments

Comments
 (0)