Enable app SideLoading in your non-developer site collection

Visual Studio allows developers to sideload apps for development and test use only. In this post, we’ll walk through what app sideloading is, when it’s appropriate to sideload SharePoint apps, and how to solve the "Sideloading of apps is not enabled on this site” error commonly encountered when sideloading apps from Visual Studio.

What is app sideloading and why is it useful?

App sideloading, from a SharePoint context, is the ability to install a SharePoint app directly into a site to explicitly bypass the regular governance controls of SharePoint.

Warning: Sideloading apps is a developer/test feature not intended for production use. Do not sideload apps regularly, or keep app sideloading enabled for longer than you are actively using the feature!

The developer site is the intended place for app development to take place in SharePoint—it is designed specifically for app developers to install and test apps before they are released to the store. There are certain site collection templates, such as Search and Project, which are not compatible with the dev site template. This means that developers cannot test apps designed for use with those templates with the developer site alone. The sideloading feature enables development against site collections that use a different template without affecting the UI. By enabling sideloading, an admin opens the door for anyone with app install permissions to install apps that are not sourced from the app catalog or app store.

In addition to the above, the ability to sideload apps is also useful when one has either an Enterprise or Professional subscription. In this case, the developer site is not the default site. In this case, we recommend creating a new site collection using the developer site as the base template to test apps in, but app sideloading could also be used to load and/or test apps instead.

What is the “Sideloading of apps is not enabled…” error in Visual Studio and why am I seeing it?

Visual Studio calls the Microsoft.SharePoint.Client.AppCatalog.IsAppSideloadingEnabled method for the given site collection URL, which returns true if the site is a developer site or if the site has the sideloading feature enabled. For a Site Collection to work which is not a developer site, the sideloading feature must be enabled.

Enabling app sideloading requires tenant admin permissions (in a multi-tenant environment) or farm admin permissions (in a single tenant environment). When you begin development in Visual Studio against any of the site URLs above without these permissions, the error "Sideloading of apps is not enabled on this site" will appear and the app installation will fail.

App sideloading seems useful! Why isn’t it activated by default?

Sideloading apps is insecure. The main reason for blocking sideloading by default on non-developer sites is the risk that faulty apps pose to their host web/host site collection. Apps have the potential to destroy data and make sites or, given enough permissions, can even make site collections unusable. Therefore, apps should only be sideloaded in dev/test environments and never in production.

The secondary reason is that the user experience and management experience for sideloaded apps is inferior to apps published in the app catalog. There is no metadata about the app and updates have to be managed manually.

I understand sideloading apps is not something I should be doing regularly, but I need to just this once. How can I activate the feature?

  1. Install the SPO management shell

  2. Save the following code to your machine as “EnableSideLoading.ps1”.

     $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'
    
    if ($siteurl -eq '') {
        $siteurl = 'https://mytenant.sharepoint.com/sites/mysite'
        $username = 'me@mytenant.onmicrosoft.com'
        $password = ConvertTo-SecureString -String 'mypassword!'`
                    -AsPlainText -Force
    }
    $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
        $sideLoadingEnabled = `
        [Microsoft.SharePoint.Client.appcatalog]::IsAppSideloadingEnabled($cc);
    
        $cc.ExecuteQuery()
    
        if($sideLoadingEnabled.value -eq $false) {
            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, $false, `
                [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None);
                $cc.ExecuteQuery();
               Write-Host -ForegroundColor Green `
              'SideLoading feature enabled on site' $siteurl
        }
    
        Else {
            Write-Host -ForegroundColor Green `
              'SideLoading feature is already enabled on site' $siteurl
        }
    }
    
    Catch { 
        Write-Host -ForegroundColor Red `
          'Error encountered when trying to enable SideLoading feature' `
          $siteurl, ':' $Error[0].ToString();
    }
    

    (You can also download this script from our code repository.)

  3. Execute EnableSideLoading.ps1 from PowerShell.

  4. Provide the URL for the site collection where sideloading should be enabled.

  5. Enter your user credentials. You must be a Tenant Admin to activate this feature.

  6. Once the script has run successfully, you should be able to install apps from Visual Studio!

When you no longer need to sideload apps, make sure to disable app sideloading!

It is critical to only enable app sideloading for as long as you need the feature. Forgetting to disable this feature leaves your site collection open to potentially having malicious apps installed onto it. Disable the sideloading feature by executing the following script from PowerShell. Similar to the installation script, the SPO management shell must be installed to run this successfully.

 $programFiles = [environment]::getfolderpath("programfiles")

add-type -Path $programFiles'\SharePoint Online Management Shell\' + `
 Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll'

Write-Host 'To disable sideLoading, enter Site Url, username and password'
 
$siteurl = Read-Host 'Site Url'
 
$username = Read-Host "User Name"
 
$password = Read-Host -AsSecureString 'Password'
 
if ($siteurl -eq '') {
    $siteurl = 'https://mytenant.sharepoint.com/sites/mysite'
    $username = 'me@mytenant.onmicrosoft.com'
    $password = ConvertTo-SecureString -String 'mypassword!' `
      -AsPlainText -Force
}
 
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
 
    $site = $cc.Site;
    
    $sideLoadingEnabled = `
    [Microsoft.SharePoint.Client.appcatalog]::IsAppSideloadingEnabled($cc);
    
    $cc.ExecuteQuery()
    
    if($sideLoadingEnabled.value -eq $false)
    {
      Write-Host -ForegroundColor Green `
        'SideLoading is alreday disabled on site' $siteurl
        }
       else
       {
      Write-Host -ForegroundColor Yellow `
        'Disabling SideLoading feature on site' $siteurl
      $sideLoadingGuid = `
        new-object System.Guid "AE3A1339-61F5-4f8f-81A7-ABD2DA956A7D"
      $site.Features.Remove($sideLoadingGuid, $true);
      $cc.ExecuteQuery();
      Write-Host -ForegroundColor Green `
        'SideLoading disabled on site' $siteurl
        }

} catch {
    Write-Host -ForegroundColor Red `
      'Error encountered when trying to disable side loading features' `
      $siteurl, ':' $Error[0].ToString();
}

(You can also download this script from our code repository.)

Additional information

Activating app sideloading will enable you to load apps from Visual Studio, but will not get you any other features of the developer site—you will not have access to Napa or the app packages library. For these reasons, along with the other rationalizations above, it is highly recommended that you use a developer site for app loading/testing instead of sideloading.

To view the logs for sideloading activation/deactivation, execute the PowerShell cmdlet get-spologs.

About the authors

This post is provided by Anirudh Goel (SDET, Office Shared Experiences), Thomas Mechelke (PM, Office Developer Platform), and Dorrene Brown (PM, Office Developer Platform).