Debugging Apps for SharePoint Online on a non-development site collection

In a previous post, I was talking about how you can use Project Server Online data in a SharePoint 2013 App using CSOM. One thing I was talking about was the fact that you cannot debug an application when you’re not using a development site collection. You will see this nice error:

Eli Sheldon (Program Manager at Microsoft) gave me this explanation (Thanks!):

SharePoint added a site collection level feature near RTM that, once enabled, will allow you to F5 deploy from VisualStudio, no matter what type of site collection you are targeting. Until the new bits roll online and this is documented, your best option here is to F5 debug on-prem and publish an app package and use the corporate catalog to test online.

Well, good news, SharePoint (online) is RTM (since a few weeks). Let’s find out how we can debug our SharePoint app on a non-development site. The reason why I really want to this, is because I have a Project Online App which requires a site collection where PWA (Project Web Access) is activated. Development sites cannot be created with an Active PWA.
I was hoping to see an option in the O365 SharePoint admin center where I could activate this ‘feature’. But unfortunately, there isn’t, or at least I couldn’t find it. So, the next thing I did was opening the solution of my previously created app, and hit F5 debug it. Note: be sure to install the latest version of the Office tools for Visual Studio 2012. As a result F5’ing my solution, I had this error:
So that’s a no-go, because “sideloading of apps is not enabled on this site“. After some research on the MSDN forums, I found a PowerShell script allowing you to enable Sideloading.  Because it’s not available in the interface, the only option you have is to run the PowerShell script to enable this feature. (There is not quite much information about this Sideloading thing yet though).
The first thing you have to do is download the SharePoint Online management Shell (link). The PowerShell script you can use is:
$programFiles = [environment]::getfolderpath("programfiles")
add-type -Path $programFiles'\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll'

Write-Host 'To enable SharePoint app sideLoading, enter Site Url, username and password'

$siteurl = Read-Host 'Site Url'
$username = Read-Host "User Name"
$password = Read-Host -AsSecureString 'Password'

$outfilepath = $siteurl -replace ':', '_' -replace '/', '_'

try
{
    [Microsoft.SharePoint.Client.ClientContext]$cc = New-Object Microsoft.SharePoint.Client.ClientContext($siteurl)
    [Microsoft.SharePoint.Client.SharePointOnlineCredentials]$spocreds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
    $cc.Credentials = $spocreds

    Write-Host -ForegroundColor Yellow 'SideLoading feature is not enabled on the site:' $siteurl

    $site = $cc.Site;

    $sideLoadingGuid = new-object System.Guid "AE3A1339-61F5-4f8f-81A7-ABD2DA956A7D"
    $site.Features.Add($sideLoadingGuid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None);
    $cc.ExecuteQuery();

    Write-Host -ForegroundColor Green 'SideLoading feature enabled on site' $siteurl
}
catch
{ 
    Write-Host -ForegroundColor Red 'Error encountered when trying to enable SideLoading feature' $siteurl, ':' $Error[0].ToString();
}
All you need to do is enter you site name, your username and your password. You will get:
That’s it. Now you can F5 your App, and it will be deployed and will also be debuggable on a non-development site, or in my case a PWA site collection. A small app that will load all Projects from my Project Site collection. Nothing fancy, just an example. Have fun!
Written by
Alexander Vanwynsberghe
Join the discussion

8 comments
  • Thank you for your page. What I do not understand is that your sample in the final screenshot is written in code-behind, resp. C#. I thought that is impossible in Apps for SharePoint 2013. Apps in SP2013 only can run client-side code, like Javascript?!

  • Hi everybody,

    I am very new in SharePoint. I want to make a simple project in Visual Studio 2012 then deploy it into SharePoint 2013 and use in our company.

    We have Microsoft Server 2012 DataCenter + SQL 2012 + SharePoint 2013

    I made a built-in app(document process) in SharePoint UI but

    i must develop a project which description likes :

    -can create tasks
    -each task must have begin+end dates
    -each task can be assigned to specific users
    -before the end date system will send warning mails to assigned users automatically
    -we can add attachments
    -assigned users can change their status as waiting, completed etc.

    Do i have to develop project on SharePoint Server or can i develop in my personal machine and deploy to SP Server?

    I am in war almost 1 week.

    Any help?

    Thanks in advance.

  • Hi Alexandre,

    I’ve run this exact script however it is still giving me the same error when trying to deploy. I even tried this with an empty solution and I continue to receive the “Error occurred in deployment step ‘Install app for SharePoint’: Sideloading of apps is not enabled on this site”.
    I’m working in a sandbox environment.

    Should I be doing something after running the script?
    Any ideas?

    Thanks in advance,
    Aruna

Menu

Alexander Vanwynsberghe

Belgium-based entrepreneur. Into technology, innovation and a bit of cycling and running too. Evangelist for everything related to smart-tech.