Razor class library static assets in combination w...
# help-with-umbraco
l
I recently had an issue where all my static assets of an Umbraco package (all css, js files, the manifest file etc) wouldn't work after I added a appSettings schema to the package. It's a razor class library package where all files are in wwwroot/App_Plugins/Example. After adding the appSettings schema, nothing in the backoffice related the package worked anymore. I found the solution and thought I'd share! So I added my custom schema to the Umbraco NuGet package: appsettings-schema.ExamplePackage.json. After that, I added a buildTransitive/ExamplePackage.props file with the following content based on Kevins blog (https://dev.to/kevinjump/umbraco-razor-class-library-packages-pt4-15f4):
Copy code
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <ItemGroup>
        <UmbracoJsonSchemaFiles Include="$(MSBuildThisFileDirectory)..\appsettings-schema.Example.json" Weight="-80" />
    </ItemGroup>
</Project>
However, by adding this custom props file, you apparently override default behaviour related to static assets. I found out by comparing the actual nupkg files of a package with and without the custom schema. So the solution was to update my own props file so it will also have the default behaviour:
Copy code
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <!-- Import the default Razor Class Library .props file -->
    <Import Project="../buildMultiTargeting/ExamplePackage.props" Condition="Exists('../buildMultiTargeting/ExamplePackage.props')" />

    <ItemGroup>
        <UmbracoJsonSchemaFiles Include="$(MSBuildThisFileDirectory)..\appsettings-schema.Example.json" Weight="-80" />
    </ItemGroup>
</Project>
This fixes the issue. I hope this is something that helps you. Or if I'm failing to see a better solution, please let me know 🙂
15 Views