Skip to content

Commit

Permalink
Provide public documented extension point to add resources
Browse files Browse the repository at this point in the history
This follows the pattern we have in other packages.
  • Loading branch information
kzu committed Nov 26, 2024
1 parent bae6b79 commit f890f3c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ThisAssembly.Resources/ThisAssembly.Resources.targets
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
</EmbeddedResource>
</ItemDefinitionGroup>

<Target Name="PrepareEmbeddedResources" DependsOnTargets="PrepareResourceNames" />

<Target Name="_InjectResourcesAdditionalFiles"
BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun"
DependsOnTargets="PrepareResourceNames">
DependsOnTargets="PrepareEmbeddedResources">
<ItemGroup>
<EmbeddedResource Condition="!$([System.IO.Path]::IsPathRooted('%(RelativeDir)')) OR '%(Link)' != ''">
<AreaPath Condition="!$([System.IO.Path]::IsPathRooted('%(RelativeDir)'))">%(RelativeDir)%(Filename)</AreaPath>
Expand Down
13 changes: 13 additions & 0 deletions src/ThisAssembly.Resources/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ The following MSBuild properties can be used to customize the generated code:
| ThisAssemblyNamespace | Sets the namespace of the generated `ThisAssembly` root class. If not set, it will be in the global namespace. |
| ThisAssemblyVisibility | Sets the visibility modifier of the generated `ThisAssembly` root class. If not set, it will be internal. |

## Adding dynamic resources

You can also provide additional embedded resources dynamically, by running a target before
`PrepareEmbeddedResources`:

```xml
<Target Name="AddDynamicResources" BeforeTargets="PrepareEmbeddedResources">
<ItemGroup>
<EmbeddedResource Include="Content/Docs/$(Configuration).md" />
</ItemGroup>
</Target>
```

<!-- #resources -->
<!-- include https://github.com/devlooped/sponsors/raw/main/footer.md -->
<!-- exclude -->

0 comments on commit f890f3c

Please sign in to comment.