Build Steps...Clarification

I know this is well trodden ground, but after re-reading the docs and past Forum postings, I still can’t get this to work. The answer has to be so simple, that I just can’t see it. As my wife says: ‘you know the mustard jar is in the refrigerator but you can’t see it until someone else points it out’ :wink:

Testing a WebApp for XojoCloud. I simply want to transfer files into the Builds folder in order to deliver those files (javascripts, css, etc) on request.

Here is what I tried:

  1. Shared Settings > Use Build Folder = True
  2. Project Navigator Toolbar > Insert > Build Step > Copy Files
  3. Inspector > Changed name of step to: IncludeFiles
  4. Inspector > Behavior > Applies to = Both
  5. Inspector > Architecture = Any
  6. Inspector > Subdirectory = includes
  7. Inspector > Destination = Resources folder

Then …

  1. Drag both the ‘IncludeFiles’ step and the Build gear icon into my Target: XojoCloud
  2. Drag-reorder the ‘IncludeFiles’ step below the Build gear icon
  3. Navigator middle pane > Click the Add Folder icon and select the source folder (which resides at the same level as my project file). Navigator now displays ‘…/includes/’ in the middle pane as the correct path to the source folder.

Now, Run and Debug. The App functions as intended, but inspecting the App.debug folder (which also lies next to my Project file), the Resources folder does not contain any subfolders, and neither my ‘includes’ directory (nor any of the files) were copied to the App.debug/Resources folder. To test, I deleted the App.debug folder and hit Run (again). A fresh App.debug folder is created but still no files copied into the Resources (or other) folder.

The files must be somewhere? Since I am testing a WebApp locally, the available options in the Project menu are Run | Deploy, but there is no Project > Build option. However, since I set the Behavior to ‘Both’ , I would expect the App.debug/Resources folder to be updated with an ‘/includes’ folder.

In Xojo Preferences > Build Tab I have the following settings:
Show Built apps in Finder = true
When not using build folders… = Replace the file
Build unsaved apps in = My Project parent folder

Where is the mustard jar (aka my ‘includes’ folder)

TIA

Did you inspect the folder while the app was still running? The IDE will attempt to delete everything when the app quits.

Oh… you’ll need to duplicate the build step for the platform you are running the IDE on.

Greg:

Found the mustard jar :crazy_face: !!

I was intending to deploy on Xojo Cloud, but doing all the development on Mac Desktop. They have separate build steps (duh), so, as you pointed out, I needed to create a duplicate Build Step for MacOS specifically for testing. Although the Framework requires unique names (Ex: IncludeFilesMac, IncludeFilesCloud), now when I Run on the development machine (Mac), the files are definitely copied to its Resources folder.

The key was adding an identical Build Step for my local machine and not expecting the Build Step for the deployment target to cover both.

(I knew it had to be something simple…)

Thanks again…

Back to the code to create more dilemnas !!

Next dilemna…although this is not a Xojo specific problem, any advice appreciated…

After succeeding in setting up my Build Steps properly, I tried to deliver a javascript file from the Includes folder by placing a script tag in the html file head element…

<script src="includes/myScript.js"></script>

By setting a breakpoint in App.HandleURL, the browser is definitely trying to grab that file from my ‘/includes/’ folder. So, I deliver with it via the WebResponse, but every time the browser blocks the file b/c it sees it as MIME “text/html” and the browser console spits out a ‘no-sniff’ policy violation:

The resource from “http://127.0.0.1:8080/_files/2245-9198-0139-6617-3500/includes/myScript.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).

Curiously, none of the headers I can examine (either in the incoming WebRequest or those I place in the outgoing WebResponse) display the offending policy:

“X-Content-Type-Options: nosniff”

The WebRequest even specifies a header for all file types. When I loop through the WebRequest.headerNames() I see:

<Warning>: Accept:*/*

And, yes I was careful to set the MIME type of the outgoing javascript file to “text/javascript” before writing the WebResponse. Here is a quick peak at my outgoing (WebResponse) headers which I build in a module subroutine:

setStandardHeaders (extends response as WebResponse, content as string, optional statusCode as integer = 200)
    
    response.status = statusCode
    response.Header ("charset") = "utf-8"
    response.Header ("Content-Type") = "text/javascript"
    response.header("http-equiv") = "x-ua-compatible content='ie-edge'"
    response.Header ("Accept")  = "text/javascript"
    response.header("Content-Language") = "en"
    response.Header ("Cache-Control") = "no-cache"
    response.Header ("Content-Length") = Str(content.Length)

Then, in App.HandleURL, I deliver the package back to the browser by:

    Var stream As BinaryStream = BinaryStream.Open(f, False)
    Var content As String = Stream.read (stream.length)
    response.setStandardHeaders (content)              '200 OK
    response.MIMEType = "text/javascript"
    response.Write content
    response.Reset

Something tells me I am not creating the WebResponse properly. I have also tried just setting the WebResponse.file to the folderItem for the javascipt file. I have also tried removing some/all of the headers, but same result.

Its surely simple…

Soooooo…I found the mustard jar, but now I can’t find the ketchup !!

Thanks for any assistance.

This is part of your problem. Reset will put things back to ground zero.

I really think that you’re over-thinking this though. Try this:

In the header:

<script src="includes/myScript.js" type="text/javascript"></script>

In HandleURL:

Response.file = SpecialFolder.Resources.Child("includes").child("myscript.js")
Response.MimeType = "text/javascript"
Response.StatusCode=200

I think that’s all you should need.

Simple is always best…Always glad to delete unnecessary steps…Thanks… esp for the tip to set the ‘type’ attribute in the script tag (which I forgot).

I tried your code verbatim but still no .js file downloaded until I specifically output the file contents via the WebResponse.write method…

Var f As FolderItem = SpecialFolder.Resources.child ("includes").child(fileName)
response.MIMEType = "text/javascript"
response.Status = 200
Var inStream As BinaryStream = BinaryStream.Open (f)
Var content As String = inStream.read (inStream.length)
response.Write content

Now everything is going great. No errors in the FireFox console and my .js file appears in the resulting iFrame and properly executes. Whew… and many thanks again.

Let’s mark this topic resolved !