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!