Jeff Sanders Technical Blog

I am a Microsoft employee that has worked on all aspects of the Web Stack for a long time. I hope these blogs are useful to you! Use this information at your own risk.


<< Go Back

Image Files Do Not Deploy When I Add Them To Asp Net Project

- 30 Nov 2017

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!

<< Go Back