Exclude App_Code directory on Azure

Using Octopus 3.2.15, we are attempting to deploy an ASP.NET Web Forms (VB) project to an Azure Web App (using a process step).

Deployment works, but the site crashes with “The directory /App_Code is not allowed because the application is precompiled”. We have pages under App_Code that we need currently.

We do not have this problem with Web Deploy. Publishing from Visual Studio works.

We are using OctoPack. Excluding the folder appears to require a .nuspec file, but once we add we have to be explicit about which files to include, and we have a lot of folders/files. That would create significant maintenance overhead.

Another option appears to be using a PostDeploy script, but since we aren’t using a tentacle, we’re unsure how to target Azure with that. (We are using Azure deployment slots if that matters.)

What is the simplest way to deploy this through Octopus?

Hi Bill,

Thanks for reaching out.

Before pushing files to Azure, Octopus unpacks the nuget/zip package to a temp work folder. When the files are there, you can do anything you want to them using a pre-deploy script. If you were for example to add a script that goes remove-item .\App_Code -recurse -force, It’ll delete the folder App_Code so it wont be there for Octopus to push it to azure.

If you are using the “Deploy an Azure Web App” step type (which doesn’t run on a Tentacle), you can simply add the feature “Custom deployment scripts” and add the code snippet as a pre-deploy script. See attached images for reference.

Hope that helps,