Some PS Script to install and uninstall Farm WSP

Following PowerShell Scripts are used often to install and deinstall SharePoint WSP Package (Farm Solution) without Visual Studio.

  • Add solution:

Add-SPSolution -LiteralPath “C:\temp\MySolution.wsp”

  • Install solution in GAC with the given WebApplication:

Install-SPSolution –Identity MySolution.wsp –WebApplication http://mywebapplication –GACDeployment

(If solution is only needed to be updated, the command “Update-SPSolution” should be executed, e.g.

Update-SPSolution –Identity Solution.wsp –LiteralPath “C:\temp\MySolution.wsp” –GacDeployment )

  • Uninstall and remove in the certain WebApplication:

Uninstall-SPSolution –Identity MySolution.wsp –WebApplication http://mywebapplication

Remove-SPSolution –Identity MySolution.wsp

 

Sometimes, Farm Feature should be enabled and disabled by PS.

Enable-SPFeature –Identity “MyFeatureName(or GUID)” –URL http://mywebapplication -Force

Disable-SPFeature –Identity “MyFeatureName(or GUID)” –URL http://mywebapplication

Parameters “-URL” and “-Force” are optional.

More details are included in TechNet site:

https://technet.microsoft.com/en-us/library/ff607534.aspx

 

Advertisements

Show call stack of web part in SharePoint

Correlation Id  as follows is not the useful debug information for developer.

webpart_callstack1

It is possible to use ULS Viewer to trace the log file in the background. (ULS View Download:http://www.microsoft.com/en-us/download/details.aspx?id=44020 )

In order to display the call stack of the web part, we should change the configuration in “web.config” file of the application directory ,e.g. “C:\inetpub\wwwroot\wss\VirtualDirectories\80”.

Set the attribute “CallStack” in Element “SafeMode” to “true”,

Set the attribute “mode” in Element “customErrors” to “Off”.

The better error message will be shown.

webpart_callstack2

Thinking SharePoint just as Service

I totally agree with “Thinking SharePoint as Service”. Pesonal opinion, this is one of the best article to describe that the “gold time” of SharePoint is gone.

http://www.andrewconnell.com/blog/developers-sharepoint-isn%E2%80%99t-a-platform-sharepoint-is-a-service

http://www.andrewconnell.com/blog/developers-sharepoint-isn-t-a-platform-sharepoint-is-a-service-part-two

It doesn’t mean that SharePoint will not be used in the future but only just be considered as a service. For example, it may be integrated with MVC just because Workflow is required. “Injecting things in the host web or customizing master page is just like cat & mouse game”.

So for developer, it can not be to write some just running code. Just like Andrew Connell said in his blog, “I think that if you’ve hired me to do some work for you, you didn’t hire someone to bang away at a keyboard and give you some running bits in a few days / weeks / months. I think you hired me for my experience.”

Edit PDF File with Adobe Acrobat Reader DC using Out-Of-Box Behavior of SharePoint 2013

It is convenient to edit a PDF in SharePoint 2013. The following steps are not to edit PDF file in the browser directly by configuring Office Web Apps. It is the Out-of-Box behavior in SharePoint 2013 and will be configured with following steps.

  • Add items in “\Web Server Extensions\15\Template\XML\DOCICON.xml”:

<Mapping Key=”pdf” Value=”icpdf.gif” OpenControl=”AdobeAcrobat.OpenDocuments”/>

  • In CA, set “Browser File Handling” to “Permissive”konfiguration.
  • Execute the following PowerShell code:
    $webApplication = Get-SPWebApplication “http://webapplication/
    $webApplication.AllowedInlineDownloadedMimeTypes.Add(“application/pdf”)
    $webApplication.Update()

Now, the “Edit Document” in SharePoint 2013  is enabled and PDF file can be edited as follows:

E1

Open and Checkout with  Adobe Acrobat Reader DC:

E2

After editing, Checkin and add comment, just like editing a word document with desktop application.

E4

E5

There are more details to control PDF file behavior in SharePoint in the article of the following link:

http://stevemannspath.blogspot.de/2013/04/sharepoint-2013-pdf-support-and.html

Add default action “Sign in as a different user”

There is no default action to sign in as a different user in SharePoint 2013. So a module must be added as follows:

<CustomAction
Id=”SignInDifferentUser”
GroupId=”PersonActions”
Location=”Microsoft.SharePoint.StandardMenu”
Sequence=”1000″
Title=”Sign in as a different User”>
<UrlAction Url=”/_layouts/closeConnection.aspx?loginasanotheruser=true”/>
</CustomAction>

The button appears again.

Untitled

More about default Custom Action ID: https://msdn.microsoft.com/en-us/library/bb802730%28v=office.15%29.aspx

Fremde JavaScript Datei in “CommandUIHandler” von Ribbon hinzufügen

Wenn JavaScript direkt in “CommandAction” hinzugefügt wird, ist es schwer zu debuggen.  Solche JS Code können in eine Datei zusammengefasst werden, dann wird nur in “CommandAction” als Methode aufgerufen werden.

Beispiel:

<CommandUIHandler Command=”Test.Command1″
CommandAction=”javascript:Command1Handler()”>
</CommandUIHandler>

<CustomAction Id=”TestAction”
Location=”ScriptLink”
ScriptSrc=”/_Layouts/15/ProjectName/RibbonAction.js”>
</CustomAction>

Ein kleiner Unterschied zwischen SharePoint 2010 und SharePoint 2013 ist der Pfad von “ScriptSrc”. In SharePoint 2010 muss folgendes sein.

ScriptSrc=”/_Layouts/ProjectName/RibbonAction.js”