I have a sandbox solution that deploys an xsl file to the styles library. The solution is scoped to the web and what happens is when the solution is deployed, the xsl file is stilled checked. Now I have a solution to resolve this matter, but is there reason why this happens? I do have Publishing activated on the site collection level.
2 Answers
This is standard behavior for sandboxed solutions. I'm glad to hear you already have a fix to ensure your file gets checked in. For those that don't, I've written up a guide on my blog: http://thechriskent.com/2012/04/05/auto-publish-and-approve-your-solution-files-2/
To summarize, in the FeatureActivating
event handler you will need to loop through each deployed file and check them in and/or approve them depending on the settings of the library.
Check out the post for more details, but here is the basic code I use for all of my files deployed to the Style Library (Runs in the FeatureActivating
event handler):
Dim styleLibrary As SPList = topSite.Lists.TryGetList("Style Library")
If styleLibrary IsNot Nothing Then
Dim folders As SPListItemCollection = styleLibrary.Folders
Dim item As SPListItem = DirectCast((From i In folders Where DirectCast(i, SPListItem).Url = "Style Library/RICBranding" Select i).FirstOrDefault(), SPListItem)
ApproveAndPublish(item.Folder, styleLibrary.EnableModeration)
End If
Here is the helper method called above that I use to recursively check in/approve the files in all the subfolders:
Private Sub ApproveAndPublish(folder As SPFolder, Approve As Boolean)
If folder Is Nothing Then Return
For Each subfolder As SPFolder In folder.SubFolders
ApproveAndPublish(subfolder, Approve)
Next
For Each file As SPFile In folder.Files
If Not file.CheckOutType = SPFile.SPCheckOutType.None Then
file.CheckIn("Feature Activation", SPCheckinType.MajorCheckIn)
If Approve Then
file.Approve("Feature Activation")
End If
End If
Next
End Sub
This is a known behaviour for modules in the sandbox.
You should be able to added a Feature reciever on the feature that deploys your module, in that itterate through the target library and publish the list items that match your deplyed xslt files/