SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When i retract my solution several files are not deleted including my custom master. Probably something simple but i want it deleted so that visual studio doesn't complain every time i deploy about deployment conflicts that it needs to resolve. Do i need to set something in the element.xml?

<File Path="Master_Pages\FamilyCare.master" Url="FamilyCare.master" IgnoreIfAlreadyExists="False"/>
share|improve this question
up vote 5 down vote accepted

When you deploy a file to a gallery using the File CAML element, SharePoint does not automatically remove the file when you deactivate the feature (or retract the solution). Presumably this is to prevent parts of the site that rely on the presence of that file from breaking if you were to accidentally deactivate the feature.

To get around it, you should attach a feature receiver to the feature that deploys your custom master page. In the "FeatureDeactivating" event, you can take care of removing the file manually. Something like this:

public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
   var site = properties.Feature.Parent as SPSite;
    var gallery = site.GetCatalog(SPListTemplateType.MasterPageCatalog);

    if (gallery != null) {
share|improve this answer
I prefer setting the old, original masterpage back as default masterpage, so before deleting, first set masterpage to i.e. v4.master. – Ernst Wolthaus Aug 24 '11 at 9:57
I agree with Ernst. You should re-set master page to original out-of-the-box master page so, hopefully, your custom master page is free to be deleted. – Aaronster Feb 5 '15 at 14:35

If you set the Type to GhostableInLibrary, then the file will be Ghosted in the library. Thus, when you come to redeploy the solution, the file in the library will reference the physical file in the SharePoint Root directory, and will always be up to date.

share|improve this answer
This does not cure deployment conflicts. – user6993 Feb 19 '12 at 0:59

Have you tried setting "IgnoreIfAlreadyExists" to TRUE? If I remember correctly, that will cause your solution to overwrite the existing file. I seem to remember thinking that it seemed backwards - what it's actually saying is 'ignore if the file already exists and overwrite it anyway'

From MSDN:

IgnoreIfAlreadyExists - Optional Boolean. TRUE to provision the view even if the file aready exists at the specified URL; otherwise, FALSE.

share|improve this answer
If it's set to false, it'll error. If it's True, it'll ignore and carry on. Does what it says on the tin. – James Love Aug 23 '11 at 16:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.