0

I'm trying to add master page created in an html format (as it is described here for example) to my VS2013 project. I'm following these answers.

The problem is that the .master file is not generated after deployment. If I modify it somehow afterwards the .master file appears.

Actually I have the same issue with custom refiner templates (.js files not generated from html templates before I change them).

Is it possible to initiate some kind of "touch" here?

2 Answers 2

1

You can use a list item event receiver to "touch" these files and initiate the transformation process, but doing so introduces a bunch of unnecessary complexity into your project for a dubious gain. The only benefit of using this pattern is to support designer customization - which in your case would have already been done prior to deployment. Event receivers are notoriously fickle and difficult to debug and maintain.

Unless you have a requirement to support further customizations of your master pages post-deployment, you are better off just provisioning the .master files and being done with it.

2
  • Yeah receiver is a bit too much, aspecially on _catalogs library.
    – ilius33
    Commented Apr 29, 2015 at 4:57
  • Lets say I have a test server where I continiously upgrade my solution. And every deployment will require me to do something with my templates. Changing master files directly is not recomended now. And as for refiner templates it is not documented how to code js files directly, and nobody blogposts with that syntax. So I've been thinking to add some powershell script which would "touch" all files in my catalog on deployment.
    – ilius33
    Commented Apr 29, 2015 at 5:04
0

Wrote a little PS script. It helps. Not sure if Checking In and Out is the best choice to "touch", but it works.

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$web = Get-SPWeb("<my web>");
$folder = $web.GetFolder($web.Url + "/_catalogs/masterpage/<my folder>");

function updateTemplates($fld) {
    foreach ($file in $fld.Files) {
        $file.CheckOut();
        $file.CheckIn("deployment");
        $file.Update();
    }

    foreach ($f in $fld.SubFolders) {
        updateTemplates($f);
    }
}

updateTemplates($folder);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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