Missing files in MSDeploy package

Problem

If you create an MSDeploy package for a SharePoint or O365 AddIn (a.k.a App) in a team build the package does not include all files (like i.e. language resources).

Reason

This seems to be a bug in MSDeploy. If you build the app only with /p:Ispackaging=True everything works fine. You get a web package inside the app.publish folder that contains all files.

image

image

If you work with multiple Publishing Profiles and specify an explicit profile strange things happen.

/p:DeployOnBuild=true /p:PublishProfile=NameOfPackageProfile

You still get the package but if you look inside the package the folders are missing.

image

Solution

If you can switch back to only using /P:IsPublishing=True your good. If not you have to look for the correct package.

If you use Build.VNext the package is in the source folder of your web project. You can use a copy file task to copy it to the staging directory before publishing your build artifacts.

image

If you use the classic XAML Builds you have to look for a _PublishedWebsites folder in your output (Binaries) directory.

image

I hope this helps. This fooled me in some projects yet.

4 thoughts on “Missing files in MSDeploy package

    1. To build the package you just need to add /p:IsPublishing=True
      To deploy the app you have to enable side loading:

      function Install-App($clientContext, $appPackage)
      {
      $appName = [System.IO.Path]::GetFileNameWithoutExtension($appPackage)
      $web = $clientContext.Web

      Write-Verbose "Start to install app $appName..."

      $productId = Get-ProductId $appPackage
      if (!$productId)
      {
      Write-Error "Cannot find product Id of app $appName."
      return
      }

      # Try to uninstall any existing app instances first.
      Uninstall-App $clientContext $productId

      Write-Verbose "Installing app $appName..."
      $appInstance = $web.LoadAndInstallAppInSpecifiedLocale(([System.IO.FileInfo]$appPackage).OpenRead(), $web.Language)
      $clientContext.Load($appInstance)
      $clientContext.ExecuteQuery()

      $appInstance = WaitForAppOperationComplete $clientContext $appInstance.Id

      if (!$appInstance -Or $appInstance.Status -ne [Microsoft.SharePoint.Client.AppInstanceStatus]::Installed)
      {
      if ($appInstance -And $appInstance.Id)
      {
      Write-Error "App installation failed. To check app details, go to '$($web.Url.TrimEnd('/'))/_layouts/15/AppMonitoringDetails.aspx?AppInstanceId=$($appInstance.Id)'."
      }

      throw "App installation failed."
      }
      }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s