azureblazor-webassemblyazure-static-web-app

Blazor WASM Deployment Not Including All wwwroot Folders and Files


I created a Blazor WASM application (.NET 9) and am deploying it to an Azure Static Web App. When running it locally, I have an xml file in a folder called 'resources' (under wwwroot) that it reads from when it loads and it works well. However, when deploying into an Azure Static Web App, the 'resources' folder doesn't deploy. How do I get it to deploy the resources folder that contains the xml file?

Deployed file structure (Azure) Project file structure showing wwwroot folder and subfolders

I set the Build Action of the Xml file to 'Content' and set 'Copy to Output Directory' to both 'Copy if newer' and 'Copy always' but neither has worked.

I've tried moving the xml file to the scripts folder where it is properly deploying download.js but that doesn't work. I've redeployed this countless times into different Azure Static Web Apps and I'm at a loss as to what else to try. Thanks in advance for any assistance.

I've also created other new blank WASM projects (with and without being a Progressive Web App) and deployed them as-is to Azure Static Web Apps and they all have the same issue as well of not deploying all additional wwwroot subfolders.


Solution

  • In the .razor file I had to add a script tag with type "text/template" and I moved the file to the 'scripts' folder as well.

    <script src="scripts/MTD.xml" type="text/template"></script>
    

    Interesting tidbit, for this to work the extension has to be .xml (albeit there may be other extensions that work but custom extensions I tried did not work).