WebMatrix doesn’t Publish All my Files

I’m trying to publish my project to a local website running under IIS 7 on my dev machine and I noticed that some of my .cshtml files were not being published. How does that happen??

It turns out that WebMatrix caches the list of files and whether or not they’ve been changed since the last publish action. But if for example you’ve gone and manually deleted some files from your test website (as I’d done), and then tried to publish them again – when there had been no changes to them – it will think they aren’t changed, so therefore don’t need to be sync’d again.

This is the default behaviour of WebMatrix thanks to a nice little checkbox that is tucked away in the options settings. Go to the Application menu and click on the Options menu item. The Application menu is the menu to the left of the Home tab:

When the Options dialog appears, click Publish on the left hand side and you will see that the first checkbox is ticked by default:

Uncheck the first option and all of your project files will be sync’d each time you go to publish your site. You will still be able to manually de-select any files you want when the Publish dialog is opened.

Lastly, if you are using a a version control system (you are aren’t you?? :o) ) such as Subversion (SVN) you don’t want all the SVN admin folders and files published to your production website. So it’s a good idea to also check the last checkbox on the same screen so that they can be filtered out:

You may need to close and restart WebMatrix for these changes to take effect. The first time I tried it, it didn’t seem to work properly, so I shutdown WebMatrix, restarted and tried again, this time successfully.

You can also clear WebMatrix’ cached list of published files. See here for details.