How to manually edit a SharePoint wsp file

Today, one of our most-read blog posts gets an update. MVP Joao Ferreira offers a new method (and free software!) to manually modify a WSP file, eliminating the hassles of adware pop-ups.

UPDATE

Over the years, I’ve received feedback about adware being added to computers during the installation process of the third-party software. I recently tried to install this software and my antivirus automatically popped up saying that the file was not safe. To eliminate this issue for good, I have built a specific application to repackage all the files inside of the WSP solution.

New WSP Repackage Software

A WSP is nothing more than a CAB file that contains a few XML files linking to the resources that will be copied to SharePoint. CAB files can be easily opened with a zip tool like 7zip but most software does not compress files in the CAB format.

Tip: If you don’t use third-party compressors you can rename your WSP and change the extension to ZIP, this way you will be able to extract the files using Windows built-in compressor tool.

The WSP Repackage is easy to use, you just need to select the folder where all the files are located, select the output directory and provide the name to the WSP file, in a matter of seconds the compressed WSP solution will be ready.

SharePoint WSP Repackage

The WSP Repackage will only compress the files. If you want to add or remove files to the solution, make sure that you reference them in the XML files otherwise they might be ignored when you deploy the solution or you can get an activation error.

A tool like this is useful in scenarios where you need to edit a solution or web part and you don’t have access to the Visual Studio project.

Tip: Errors are common when editing a WSP Solution, if you leave the WSP Repackage open while testing you only need to click repackage to generate a new WSP.

How can this be useful with BindTuning Themes?

If you want to apply a CSS change to a theme and have several site collections where the theme is installed the fastest way to do it is to modify the WSP, instead of manually modifying the CSS using the SharePoint designer for each site collection. Of course, this is only relevant for Classic SharePoint themes, as our new themes settings panel for Modern themes makes CSS advanced coding effortless. Learn more about it here.

I made this software open source and you can have access to the entire project from GitHub. Here are the links to the software and solution:

Download WSP Repackage
Explore Solution on GitHub

Getting Ready for Microsoft Ignite 2018

Advice for First Time Attendees. We are only 3 days away from the biggest Microsoft event dedicated to the Tech Community and if you are attending – this article is for you.

With so many things going on, it can be overwhelming especially for first time attendees. This will be my 4th Ignite and based on my experience from previous years, I’ll share with you a few tips and tricks to make it a smooth ride.

Continue reading “Getting Ready for Microsoft Ignite 2018”

How to add Google Analytics to SharePoint without modifying the master page

Mainly targeted to public sites, Google Analytics can also be used to monitor your SharePoint or Office365 intranet. It will not only help you understand if employees are using the company intranet but also how they are using it and if anything needs to be improved.

Below I explain step by step how you can build and deploy a script link using a custom action in SharePoint, and will also provide the installation files and the instructions to use the script in case you don’t want to build it yourself.

How to setup Google Analytics

Before we get into the SharePoint bits let’s set up Google Analytics and get everything you need.

  1. Sign in to your Analytics account
  2. Select the Admin tab
  3. Select an account from the menu in the Account column, or Create New Account if you don’t have one already
  4. Select a property from the menu in the Property column
  5. Under Property, click Tracking Info Tracking Code
  6. Save the Website tracking script code

    Save Google Analytics tracking code

Find more information about google analytics setup

Create SriptLink Custom Action

If you don’t want to deal with code at all, jump to the next section.
Heads up! The solution built in this tutorial uses a declarative SandBox solution to deploy Google Analytics. These type of solutions are supported by Microsoft in the most recent versions of SharePoint, including SharePoint 2016 and SharePoint Online. You can read more about this type of solution here.
  1. Open Visual Studio and create a new project
  2. Select Office/SharePoint templates and SharePoint Empty Project
  3. I will call it SharePointGoogleAnalytics, but you can call it whatever you want

    New SharePoint project

  4. Provide the URL of the site you will use to debug
  5. Select Deploy as sandboxed solution and click Finish

    SharePoint Customisation Wizard

  6. Once your project opens, go to the Properties and set Include Assembly in Package to False. This is required to build a declarative sandbox solution

    SharePoint Solution Properties

  7. Right click on your project, go to Add and select New Item
  8. Select Empty Element and call it AnalyticsCA – this will be the ScriptLink Custom Action

    Add new item

  9. Right click on your project again, go to Add and select New Item
  10. Select Module and call it Style Library
  11. Delete the Sample.txt file that is created by default
  12. Create the folder structure bellow inside the Style Library Module
    GoogleAnalytics js
  13. Right click in the js folder, go to Add and select New Item, from the Web group select the JavaScript File and call it ga.js

    SharePoint Project Structure

  14. At this point, your project structure should look like the image bellow

    SharePoint Feature Properties

  15. Open the Elements.xml file inside the Style Library module. This file is generated by Visual Studio automatically. However, I prefer to modify it and publish the files automatically once the solution is activated. I also replace the files, if a previous version already exists in the system.Select the entire content of the file and replace it with the code bellow.
    Note: If you are not using the same names I used previously, make sure you adjust the URL and Path
    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <Module Name="StyleLibraryJS" Url="Style Library/GoogleAnalytics/js" RootWebOnly="FALSE" Path="Style Library\GoogleAnalytics\js">
        <File Url="ga.js" Type="GhostableInLibrary" Level="Published" ReplaceContent="TRUE"  />
      </Module>
    </Elements>
  16. Open the Elements.xml inside the AnalyticsCA module and paste the code bellow.
  17. <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <CustomAction
        ScriptSrc="~SiteCollection/Style Library/GoogleAnalytics/js/ga.js"
        Location="ScriptLink"
        Sequence="1">
      </CustomAction>
    </Elements>

    This XML file will register the custom action and will execute the ga.js on all sites of your site collection.

    Note: If you are not using the same names I used previously, make sure you adjust the ScriptSrc
  18. Open the Features folder and rename the Feature1 to GoogleAnalytics feature
  19. Open GoogleAnalytics feature
  20. Type a Title and Description for your features. Both fields will be visible on your site collection
  21. Change the scope from Web to Site, this way the script will be deployed to all the sites in the site collection

    Add JavaScript File

  22. Open the ga.js file in the Style Library module and paste there the script code you got from Google, without the script tags. Your code will be like the code bellow, except for the Track ID.
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
    
      ga('create', 'Track ID', 'auto');
      ga('send', 'pageview');
    
  23. Compile your project and deploy the solution to all the site collections you want to track

Once you deploy the solution, your Google Analytics dashboard will immediately display real-time data.

Add JavaScript File

Install Google Analytics on SharePoint

Note: This topic is mainly for the users that didn’t build their own custom action project.

To install the solution in your SharePoint and start tracking your sites follow these steps:

  1. Download the solution
  2. On your site collection root site go to Settings Site Settings Solutions
  3. Upload and activate the solution. Once you activate the solution, the Google Analytics script is immediately added to your site however, it is not tracking your site yet, you still need to add your track id to the script
  4. Open your site with SharePoint designer
  5. Go to All Files Style Library Google Analytics js
  6. Check out and edit the ga.js file in advanced mode
  7. Locate the words TRACK ID and replace it with your own track id from Google Analytics

    Add JavaScript File

  8. Save the file, check it in and publish it as a major version.

That’s it, you are good to go! Your site collection is now being tracked by Google Analytics.

If you have multiple site collections and don’t you want to open SharePoint Designer for each site collection, to edit the JavaScript file, you can use my SharePoint WSP Repackage tool to modify the solution and create your own unique WSP with your Track ID.

How to deactivate Google Analytics tracking

If you want to stop tracking a specific site collection do the following:

  1. On your site collection root site and go to Settings Site Settings Site Collection Features
  2. Locate the Google Analytics feature and deactivate it

    Add JavaScript File

Conclusion

In this article, you have learned how to add Google Analytics to SharePoint without editing the master pages and also how to create a script link custom action.

If the master page was blocking the analytics adoption in your company either because you are on SharePoint Online or because you don’t want to break your beautiful custom master pages, this is the way to go.

Unfortunately, this solution will not work on the new Team Sites and Document Libraries on SharePoint Online because for now, there are no script sites available. As soon as something comes out to support those sites I’ll review this article again.

As always the source code of this project is available on my personal GitHub repository and you can download the WSP solution from this article, the links are down below.

Download Google Analytics WSP

Explore Solution on GitHub

Customize SharePoint from Mac OS

Creating and editing SharePoint files in Windows is easy with SharePoint Designer but, if you are a Mac user, you are in a tough position. In this article, we will explain how you can save time and get access to all the files and folders needed to customize SharePoint sites from your Mac.

This article only covers SharePoint on-premises, because unfortunately, SharePoint Online is not accessible with these methods.

Option 1 – Map SharePoint as a network driver

This option uses the WebDAV protocol that provides a framework for users to create, change and move documents on a server, typically a web server or web share.

  1. From finder click on Go Connect a Server
  2. Type the address to your SharePoint site including the protocol

    Open SPD folder

  3. Type your credentials and wait, this may take a few minutes

    SharePoint credentials

  4. Once it’s mapped it will open Finder and will show all the files as a network folder
    As an alternative you can map only the library where you want to work. (e.g. Style Library)

    SharePoint mapped folder

How to edit the files?

To modify the files, you first need to check them out; since this option is not available in Finder you will need to do this using a browser.

Using Visual Studio Code, as we do in the steps bellow, is optional. You can use any other IDE.
  1. On your browser navigate to the library where you have the branding files
    (e.g. http://sharepoint.com/Style%20Library/Forms/AllItems.aspx)
  2. Check out all the files you will be modifying
  3. Open Visual Studio Code
  4. Go to File Open
  5. Select your SharePoint shared driver

    SharePoint Mapped Folder

  6. Select the library where the files are located and click Open
  7. In the explorer pane select the file you want to modify; it might take a few seconds to sync the file

    Visual Studio Code

  8. Save your file and keep in mind that you will need to wait a few seconds
  9. Go to the browser, check in and publish your files as major version to make them visible to all the users

Bellow you have my SharePoint site, with a red page title, customized from a Mac.

SharePoint alternate css

Option 2 – Microsoft Document Connection

This option is only for users still using Office 2011, if you already upgraded to 2016 this software is no longer available.
To open SharePoint sites, your Office version cannot be Home or Education, on these versions the SharePoint option will be greyed out.
  1. Open Microsoft Document Connection
  2. Click on Add Location and select Connect to a SharePoint Site

    SharePoint Mapped Folder

  3. Fill the address and credentials fields

By default, this software does not display all libraries, if you want a library that is not listed you will need to provide the address to it in the address field.

Once the library opens you will have the option to Edit, Check Out and Check in the files
The edit option opens the local software defined for the file type

SharePoint Mapped Folder

Once you finish editing your files check them in as a major version to make the changes visible for all the users

Pros and Cons

Option 2 is faster than Option 1 and does not require you to go to the browser to check in and check out the files but it uses a software that is 5 years old and was discontinued.

On the other hand, if you are editing multiple files at the same time, Option 1 allows you to see the tree view, Option 2 requires you open all the files individually.

With Option 1 you will add the infamous DS_Store files to the libraries and Windows users will be able to see them.

In conclusion…

Although there is no perfect option to achieve this goal, both described solutions will allow you to customize your SharePoint site from your Mac. It’s up to you to decide on which best suits your needs.

Unfortunately, SharePoint Online is not supported but you can keep an eye on this thread. Apparently Microsoft has plans to support it with the OneDrive App ;)

Can you still use SharePoint Sandbox Solutions in 2017?

The answer is yes, but not with all situations and not all types of sandbox solutions. SharePoint sandbox solutions were introduced with SharePoint 2010 and provided a mechanism to execute code outside of the ISS worker process. The sandbox solutions do not affect the entire farm, they are installed per site collection and they can be installed by the site collection administrator.

sandbox solutions in 2017

Continue reading “Can you still use SharePoint Sandbox Solutions in 2017?”

Create a modern breadcrumb navigation in SharePoint

Breadcrumb navigation was available by default on SharePoint 2007 and 2010 but with the introduction of SharePoint 2013 it was removed and until today it wasn’t reintroduced.

Today I’m revisiting one my most read articles. Back in 2013, I wrote an article to explain how this functionality can be added again to SharePoint and, judging by the number of views this article still has, there’s a lot of people trying to get the breadcrumb back.

The method from the previous article is still valid but it requires you to manually modify the master page. If you are not going to customize the layout of your site, there’s no need to mess with it.

SharePoint Breadcrumb

The new version that I bring you today adds the breadcrumb navigation to all SharePoint pages, using the breadcrumb style defined by the Fabric UI.

In this version, the breadcrumb is created with a script that is deployed globally by a custom action. The original script was created by André Lage and is available in the Office PNP repository; I did some modifications to it to create a modern breadcrumb following the Fabric UI design rules.

Breadcrumbs should be used as a navigational aid in your app or site. They indicate the current page’s location within a hierarchy and help the user understand where they are in relation to the rest of that hierarchy. They also afford one-click access to higher levels of that hierarchy.

Fabric UI breadcrumb

Breadcrumbs are typically placed, in horizontal form, under the header or navigation of an experience, above the primary content area.

This solution creates a site collection feature and deploys the JavaScript and CSS files. It’s deployed as a declarative sandbox solution; even though declarative sandbox solutions are still supported by Microsoft I know that some of you want to stay away from it. With that in mind, I’ll build a new version of the modern breadcrumb to be deployed using the add-in model.

To install the modern breadcrumb, download the WSP using the link provided at the bottom of the article, and proceed as follows:

  1. Go to Settings > Site Settings
  2. Click on Solutions under Web Designer Galleries
  3. Upload and activate the solution

    Activate breadcrumb solution

  4. Once the solution is activated the breadcrumb will be visible in all sites

If, for some reason, you want to disable or uninstall the breadcrumb, proceed as follows:

  1. Go to Settings > Site Settings
  2. Click on Mange Site Collection features under Site Collection Administration
  3. Deactivate the feature SharePoint Breadcrumb Navigation

    Deactivate breadcrumb solution

  4. Go to Settings > Site Settings
  5. Click on Solutions under Web Designer Galleries
  6. Deactivate and delete the solution

This solution is compatible with SharePoint 2013/2016 and SharePoint Online and supports Seattle and Oslo master pages.

Bellow you have the links to download the solution and the link to the GitHub repository where you can find the complete Visual Studio Solution.

Download Breadcrumb WSP
Explore Solution on GitHub

Heads up

If you are using the latest version of Bind Tuning themes you don’t have to do anything to get the breadcrumb back, it’s included by default :)

Bind Tuning breadcrumb

How to solve the most common issues on SharePoint Designer

If you work with SharePoint, you’ve probably realized that SharePoint Designer is one of your best allies but it is still a bit temperamental and it sometimes just refuses to work properly.

In this article, we’ll cover the most common issues with SharePoint Designer and how to fix them.

#1 Unable to open a site

…the version of Microsoft Foundation on the server is more recent than the version of SharePoint Designer you are using…

Usually, when SharePoint Designer (SPD) is not able to open a site, it displays a message telling you that the site is not compatible with the version that you have installed.

If you are using SharePoint Designer 2010, you will see this message in all most recent versions of SharePoint, including SharePoint Online.

Microsoft didn’t release a new version of SharePoint Designer with SharePoint 2016, however, SPD 2013 can work with all SharePoint versions.

So why does this message still appears if my version is supported?

This is a common problem with SharePoint Online and Office 365; like all other Office apps, SPD has the option to sign in with a live or corporate account and this will save some of your settings.

SharePoint Designer

If you are using your corporate account in SPD and a different live account on Windows, it is possible that after installing a Windows update your corporate account on SPD will be replaced by the Windows account.

This message will also be displayed if you manually switch accounts.

To continue and open your SharePoint online site do the following:

  1. On SPD go to File > Account
  2. Click on Switch Account
  3. Sign in with your corporate account

  4. Open your SharePoint site

#2 Unable to check in file

…the file is no longer checked out…

This is another common issue and it is caused by the settings that are save in the SPD cache. Unfortunately, this issue only goes away after cleaning SPD’s cache and this procedure will wipe all your site’s history.

How to clear SPD cache

  1. Make sure SPD is closed
  2. On your keyboard press Windows + R

    Open SPD folder

  3. Paste the path bellow in the text box
%USERPROFILE%\AppData\Local\Microsoft\WebsiteCache
  1. Delete everything in the folder
  2. On your keyboard press Windows + R again
  3. Paste the path bellow in the text box
%APPDATA%\Microsoft\Web Server Extensions\Cache
  1. Delete everything in the folder
  2. Open SharePoint Designer
  3. Go to File > Options > General

    SPD Options

  4. Click on Application Options
  5. On the General tab uncheck Cache site data across SharePoint Designer sessions

    SPD cache

After clearing the cache, you will be able to check in your file using SPD.

#3 Unable to see list and libraries on SPD

This happens because you have a corrupted list in your site or because you have a list that was deployed by a feature that no longer exists.

Open SPD Lists

To fix this, you will need to delete the corrupted list. If you don’t know which list is causing the issue, you will need to open the lists in your site one by one until you find the typical error message “Something went wrong”.

After deleting all faulty list instances, refresh your SPD.

In summary…

I hope this can help you using SPD. If you have any suggestions to add to this list, please feel free to add it in the comments section.

Get Ready for the New SharePoint Framework

The new SharePoint Framework, announced on May 4th, introduced a new model for developing SharePoint web parts that are radically different from its predecessors.

SharePoint development previously required a specific environment, with SandBox and Farm web parts you need at least one server with SharePoint and Visual Studio to develop and debug the code. The App model introduced in 2013 eliminated the need for a SharePoint server but it still requires Visual Studio and a Developer site collection hosted on Office 365.

This new framework frees you to choose your environment and the only requirement is a computer that can run the latest web technologies. You can even use Mac OS or a Linux distro.

SharePoint Framework

Continue reading “Get Ready for the New SharePoint Framework”

Customize Office 365 Sign In page

Until now, no matter the effort you invested in branding your Office 365 sites and keep your collaborators involved with your company brand, the Sign In page was impossible to change.

Now if your Office 365 environment is associated with the Azure Active Directory you are able to customize the appearance of the Sign In page so that it includes your company logo, color scheme and a few other settings.

Office 365 Sign In page (1)

Continue reading “Customize Office 365 Sign In page”

Deactivate SharePoint 2013 mobile view

By default SharePoint 2013 detects if the site is being displayed in a mobile device and shows the content in a very simplified portal that remove most of the features. Sometimes you just want more control over your mobile website.

Deactivating this view can be useful if you want to get the full site to be displayed on mobile devices, or if you have a custom responsive theme.

In this article I’ll show 3 different methods to change this behavior, and display the full website when in mobile devices.

Option #1 – Deactivate SharePoint Mobile feature

This is ideal if you are using Office 365 or if you don’t have access to the SharePoint server. If you don’t want to remove the mobile view from all sites this is the process you should follow.

SharePoint Mobile View

  1. Open your site and go to Site Settings -> Manage site features
  2. Locate Mobile Browser View and click Deactivate
  3. Deactivate Mobile View

  4. Refresh your browser on your mobile device and you should see your entire SharePoint site

SharePoint

Option #2 – Change the redirect behavior of a mobile browser

This process is just available for the SharePoint 2013 on-premises, and you need to have access to the server where it is installed, you should follow this method if you want to remove the mobile view from all sites.

  1. On your server click Start, click Administrative Tools, and then Internet Information Services (IIS) Manager
  2. Right-click the IIS website where the SharePoint web application is installed, and then click Explore
  3. IIS Explorer

  4. In Windows Explorer, double-click the App_Browsers folder
  5. Open the compat.browser file in a text editor
  6. Find the node that corresponds to the mobile browser or device that you want to modify
  7. Find the element
  8. Set the value attribute to false to display a standard view of the site in the mobile browser
  9. Save your changes to the compat.browser file
  10. Restart IIS by entering the following command at the command prompt
    iisreset /noforce
  11. After the restart open your SharePoint site in your mobile device
  12. Responsive SharePoint site

Option #3 – Create a device chanel

This method is only available for SharePoint publishing sites, it will work on Collaboration sites also but you need to activate first the Publishing features. Since it’s only available for publishing it will not work on SharePoint Foundation.

A device channel is a feature that enables you to render specific site content while maintaining the same URL across a pool of different devices, with it you can have different layouts for the same URL and SharePoint will manage them based on the user agent of the browser.

Device Chanels

To Create a new device channel do the following:

  1. On your SharePoint site go to the site settings
  2. Open Device Channels, it is located under Look and Feel
  3. Add a new item to the list. When you create a device channel item, there are five required and optional fields to supply for the process the table below lists these fields and describes what type of information must be provided.

  4. Field Required Value Value
    Name Yes This is the name of your design channel. It can be a friendly name to identify the channel
    Alias Yes The alias name enables you to identify your device channel in code, device channel panels (discussed later in this article), previews, and other contexts
    Description No A field for supplying a general description for the device channel
    Device inclusion rules Yes A field for supplying the user agent substring such as Windows Phone OS. Device redirection to a specific master page depends on what is entered for this value. For more information about what values to supply in this field, see the table with the User agent substrings.
    Active No Selecting this check box activates your device channel.

     

    Device User Agent Substring
    Windows Phone 7.5 Windows Phone OS 7.5
    Windows Phone Windows Phone OS
    iPhone iPhone
    iPad iPad
    Any Mobile Device $FallbackMobileUserAgents;
    Default Default
  5. For all mobile devices fill the Device inclusion rules with:
    $FallbackMobileUserAgents;
  6. Add New Device Chanel

  7. Go to the site Settings and open Mater Pages, it is located under Look and Feel
  8. Set your desired master page to show on mobile devices
  9. Mobile Devices