Image files do not deploy when I add them to ASP.Net project

Overview

You might notice that when you add files like images (.png .bmp) to your project that these are not updating to your Web App (Azure Web App or on premise).

Cause

This is by design and because of how Visual Studio treats these resources.  These types of resources can be bound as resources in code so they are not included.

Fix

You need to simply configure the resource to be copied.  In the ‘Solution Explorer’ click on the file and change the 'Copy to Output Directory' to 'Copy if newer':

capture20171128075005125

This in turn sets the attribute in the .csproj file.  So, you could simply edit the .csproj file directly as well!  Below is a sample of the csproj file from above.  You can see how CUY.jpg is configured in the csproj file as ‘Always’ and this maps to ‘Copy always’.  You can also see that ‘Copy if newer’ maps to ‘PreserveNewest’.

capture20171130164912382

Drop me a note if you found this useful!