When deploying a SharePoint app in SharePoint Online, you may receive the “all too helpful” error message:
Error occurred in deployment step ‘Install App for SharePoint’: Failed to install App for SharePoint. Please see the output window for details.

If you force the installation to continue, you will most likely see a Correlation ID error page.
Then if you look at the Build Log within Visual Studio, you see another set of “all too helpful” information that may or may not be:
------ Build started: Project: Submittals, Configuration: Debug Any CPU ------ | |
------ Deploy started: Project: Submittals, Configuration: Debug Any CPU ------ | |
Active Deployment Configuration: Deploy App for SharePoint | |
Skipping deployment step because a pre-deployment command is not specified. | |
Skipping the uninstall step because the app for SharePoint is not installed on the server. | |
Install app for SharePoint: | |
Uploading the app for SharePoint... | |
Installation is in progress (00:00:01) | |
Installation is in progress (00:00:03) | |
Installation is in progress (00:00:05) | |
Installation is in progress (00:00:07) | |
Installation is in progress (00:00:09) | |
Installation is in progress (00:00:12) | |
Installation is in progress (00:00:14) | |
Installation is in progress (00:00:16) | |
Installation is in progress (00:00:18) | |
Installation is in progress (00:00:20) | |
Installation is in progress (00:00:22) | |
Installation is in progress (00:00:25) | |
Installation is in progress (00:00:27) | |
Installation is in progress (00:00:29) | |
Installation is in progress (00:00:31) | |
Installation is in progress (00:00:33) | |
Installation is in progress (00:00:35) | |
Installation is in progress (00:00:37) | |
App failed to install, cleaning up... | |
Successfully uninstalled the app for SharePoint. | |
App installation encountered the following errors: | |
6/11/2015 2:22:50 PM | |
@"Error 1 | |
CorrelationId: 6d55b159-5882-42cf-8f82-44921326da68 | |
ErrorDetail: There was a problem with activating the app web definition. | |
ErrorType: App | |
ErrorTypeName: App Related | |
ExceptionMessage: Dependency feature 'SOLUTIONName_Feature1' (id: 73a9d39a-4fbd-4c59-89a3-875b6e1d1560) for feature 'SOLUTIONName_Feature2' (id: 55662431-dea2-426b-80ca-838e85904460) is not activated at this scope. | |
Source: AppWeb | |
SourceName: App Web Deployment | |
Error occurred in deployment step 'Install app for SharePoint': Failed to install app for SharePoint. Please see the output window for details. | |
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ========== | |
========== Deploy: 0 succeeded, 1 failed, 0 skipped ========== | |
00:00.387 - Failed - Debug Any CPU - SOLUTIONFolder\SOLUTIONName.csproj | |
Total build time: 00:00.000 | |
========== : 0 succeeded or up-to-date, 1 failed, 0 skipped, Completed at 6/11/2015 10:22:50 AM ========== |
So what is the issue? Here are the possible issues (in no particular order):
- You may have another app deployed and in debug mode within Visual Studio. This happened to me once when I was trying to compare two apps from two clients. I thought I was working within the new app; however, I accidentally deployed the older other client app and left it running.
SOLUTION: Stopping debug via Visual Studio DEBUG > Stop Debugging. - You have files that are trying to be deployed and are no longer found within your solution. To check this, look at all of your
SharePointProjectItem.spdata
files (a XML file). It will look something like this:
Looking at line 4, locate the Elements.xml file and validate that the referencedElements.xml
file contains all the files.
<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Module Name="RootModule"> <File Path="App\app.js" Url="App/app.js" ReplaceContent="TRUE" /> <File Path="App\somefolder\jquery.custom.js" Url="App/somefolder/jquery.custom.js" ReplaceContent="TRUE" /> </Module> </Elements>
If you look at this example, theElements.xml
file is missingcommon.js
.
SOLUTION: To add it back, you can add it manually, but since Visual Studio has a lot happening under the hood, this can lead to less than desirable results. First, make sure you are not in Debug Mode (Start will have a Green > if you are not in Debug Mode). Next, locate the file, right-click and select Exclude From Project. Then, right-click and select Include in Project. If you watch theElements.xml
file, you will see that your file has been added. - You have files that are being deployed that do not have a proper
Elements.xml
file or is missing. Again, if you check all of yourSharePointProjectItem.spdata
files, you may find that a folder has been included and reference anElements.xml
in that particular folder.
SOLUTION: There are a few different ways to fix this, and you have another please let me know. However, in the past this has happened when I manually move files outside of the solution via the Explorer. To fix this, I added a new Empty Element Item and rebuilt the folder properly and deleting the offending folder. - You have an
Elements.xml
file that contains a typo. This is most likely due to an accidental keystroke (e.g., extra character somewhere). - You have an
Elements.xml
file that contains an unsupported node. One example of this is the Site ColumnElements.xml
. Please note that the Node/Tag names themselves and their values are case sensitive. For example:
This is WRONG.
<Field ID="{CD35883F-0814-4A9A-8FCD-9A7017E04742}" Name="CustomDateField" DisplayName="My Date Field" Type="DateTime" Format="DateOnly" Required="FALSE" Group="My Custom Group"> <Choices> <Choice>Choice A</Choice> <Choice>Choice B</Choice> <Choice>Choice C</Choice> </Choices> <Mappings> <Mapping Value="1">Choice A</Mapping> <Mapping Value="2">Choice B</Mapping> <Mapping Value="3">Choice C</Mapping> </Mappings> <Default>Choice A</Default> </Field>
As much as you may be like me and think that the XML should be consistent (Capitalized first letter, lower case for the rest), it isn’t.This is CORRECT way.
<Field ID="{CD35883F-0814-4A9A-8FCD-9A7017E04742}" Name="CustomDateField" DisplayName="My Date Field" Type="DateTime" Format="DateOnly" Required="FALSE" Group="My Custom Group"> <CHOICES> <CHOICE>Choice A</CHOICE> <CHOICE>Choice B</CHOICE> <CHOICE>Choice C</CHOICE> </CHOICES> <MAPPINGS> <MAPPING Value="1">Choice A</MAPPING> <MAPPING Value="2">Choice B</MAPPING> <MAPPING Value="3">Choice C</MAPPING> </MAPPINGS> <Default>Choice A</Default> </Field> - You have an
Elements.xml
file that contains a node with a valid attribute and an invalid attribute value. One example of this is in the Site ColumnElements.xml
. In theField
node, the attributeName
‘s value cannot have spaces. For example, this will cause an error:
<Field ID="{CD35883F-0814-4A9A-8FCD-9A7017E04742}" Name="CustomDateField" DisplayName="My Date Field" Type="DateTime" Format="DateOnly" Required="FALSE" - You may have a duplicate GUID somewhere.
SOLUTION: Find all GUIDs by typing Ctrl + Shift + F and enter this Regex[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}
and under Find Options select the Use Regular Expressions. And then click Find All. In the Find Results, you will be able to compare the GUIDs.
Sometimes in the output, you will have the warning:
Unable to remove directory “pkg\Debug\”. The directory is not empty.
To fix this, you can go to Solution Explorer and click the Show All Files icon until you see the pkg
folder. Expand the folder by clicking on the right arrow to the left of the folder. Then right click on the Debug
folder and select Delete.
And for good measure, do the same with pkg
folder. Expand the folder by clicking on the right arrow to the left of the folder. Then right click on the Debug
folder and select Delete.
Finally, if any of the above do not work. Remove all items from the feature, adding them back one by one in a logical order Building/Starting in between each item. This will eventually tell you which item contains the culprit.
Please let me know if you found any that I did not include here.