I am trying to deploy elements like JavaScript files and CSS using SharePoint hosted app inside the app itself, by default the app shows modules like content, scripts, pages etc.. inside these modules the deployment url is: Scripts/App.js.

Does that mean there is a document library called Scripts? I try to open the App url appended by /Scripts, but it tells me page not found. What's these content and scripts that are the target for file deployment?


My guess is it is a folder in the virtual file system, meaning the files are ultimately stored in a content DB. "Scripts" in this case is not a document library, but a folder. But, since the folder doesn't really exist, you can't see its contents by just appending /Scripts to the app URL.

If you want the content you are deploying to be accessible in that way, through a browser, you will also need to deploy a document library where you want that content to go. Here is a sample module Elements.xml that deploys a couple JS files to a document library called "Scripts". Keep in mind that the document library is also part of the same app project.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="ScriptDeployment" Url="Lists/Scripts">
    <File Path="ScriptDeployment\jquery-1.8.2.min.js" Url="jquery-1.8.2.min.js" ReplaceContent="TRUE" />
    <File Path="ScriptDeployment\jquery.SPServices-2014.01.min.js" Url="jquery.SPServices-2014.01.min.js" ReplaceContent="TRUE" />

Using this method, if I browse to https://my/app/url/Lists/Scripts, then a normal document library list view comes up.

| improve this answer | |
  • I am afraid that's not right, if you make a new sharepoint hosted app, you will see that the module is deploying to Content/App.css or Scripts/App.js not Lists/Scripts/App.js, if you try to go to this url you will not reach it. – Max Mar 6 '15 at 17:41
  • Yes, if you add a module to an App project, then by default the deployment URL will be "ModuleName/filename.js". But you need to change that, because there is no place in the resulting app web that corresponds with that URL. That's why you also have to deploy a document library, so there is somewhere for your files to go. – Dylan Cristy Mar 6 '15 at 17:56
  • But in fact, my files go somewhere, that's why if you type: /Scripts/App.js it will download the js file for you, so what's the /Scripts? – Max Mar 6 '15 at 21:04
  • Ah, gotcha. I had not done it that way before. I have changed my answer. – Dylan Cristy Mar 6 '15 at 21:33
  • ahaa, ok now that makes sense – Max Mar 6 '15 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.