sq / JSIL

CIL to Javascript Compiler
http://jsil.org/
Other
1.73k stars 241 forks source link

Content project manifest not including files with 'Build Action' of 'Content' #589

Open DrMiaow opened 10 years ago

DrMiaow commented 10 years ago

Background: I've written an Otome game interpreter in XNA/MonoGame that takes Twine files exported as .twee so these files are essentially text as well as other scripting files. More details here http://blog.metawrap.com/2014/07/29/the-game-progress-report-22/

I have a .contentproj and several.csproj.

The .contentproj contains content, some I want to put through the standard XNA Compile Importer/Processor pipeline. Most though I don't and I have them configured with a 'Build Action' of 'Content' with 'Copy To Output Directory' set to 'Copy If Newer'

So what I wanted was...

Content/script.hx Content/story.twee

... but what I got was.

Content/ *crickets*

So when I JSIL my solution the .contentproj manifest is missing any files that are 'Build Action' 'Content'.

I've tried moving some of these files to a .csproj under a 'Content' project folder but then I encountered some strangeness.

After JSIL I ended up with

Content/ *crickets* Files/Content/script.hx Files/Content/story.twee

But running the JSILed version TitleContainer.OpenStream("Content/script.hx") was not finding it.

IIS has all the correct mime types for my content.

When I build this under XNA/MonoGame I end up with ...

Content/script.hx Content/story.twee

... in the output folder.

From past experience https://github.com/mono/MonoGame/pull/2223#issuecomment-41558319 I stick to TitleContainer.OpenStream. MonoGame and Content and I have a complicated relationship. https://github.com/DrMiaow?tab=activity

In short TitleContainer.OpenStream is supported all other file access tricks are verboten, mainly it seems because of the XNA spec and the security model, So I go with the flow.

So I'm guessing that 'Files' end up being accessible via a different path?

Such as TitleContainer.OpenStream("Files/Content/script.hx") ?

I'm fine with a separate JSIL solution file and project set but I'd rather not split my content by type/path if I can avoid it.

So I ended up making a hack to JSIL.IO.js

(this is from memory - will check when I get home) 31-07-2014 2-10-57 pm

Which in effect virtually merges / into Files/ at least when called by TitleContainer.OpenStream/

Obvious issues are that

1) This is probably more likely to be useful inside resolvePath but I felt that path should reflect the remapping with a possible create there? 2) "Files/" is all configurable so "Files/' is wrong as soon as someone overrides the default.

kg commented 10 years ago

Did you try changing the root where files are mounted to just '/'? I think that might work here.

The interaction between content and regular files and title containers is definitely something the core XNA stubs don't handle well. Using Actual MonoGame might fix a lot for you.

I see what you were doing with files in your contentproj and it should be possible to support that.

If it's possible to get a test project that demonstrates these issues, that would be wonderful. Otherwise, I can try to assemble one myself.

DrMiaow commented 10 years ago

Is there an equivalent to the ContentOutputDirectory setting in the .jsilConfig settings for Files?

kg commented 10 years ago

fileVirtualRoot, see https://github.com/sq/JSIL/wiki/jsilConfig. It might not be able to do what you want, but I think it can, since I've had to use it before for ports.

DrMiaow commented 10 years ago

Managed to get something working by moving the uncompiled content into the .csproj

With the following .jsilconfig

{
  "OutputDirectory": "%configdirectory%/../../www/game/",
  "ProfileSettings": {
    "OverwriteExistingContent": true,
    "UsePNGQuant": true,
    "FileSettings": {
    }
  }
}

And the following config in the HTML file.

      var platform = "JSIL"
      var rootNamespace = "My64K.HexTheGame";     
      var clientNamespace = rootNamespace + ".Client." + platform;
      var jsilConfig = {
        printStackTrace: false,
        webgl2d: true,
        xna: 4,
        manifests: [
          clientNamespace + ".exe",
          "Content/" + clientNamespace + "Content.contentproj",
          "Files/" + clientNamespace + ".csproj"
        ],

        showProgressBar: true,
        showStats: true,

        scriptRoot: "",
        libraryRoot: "../Libraries/",
        fileRoot: "Files/",
        contentRoot: "Content/",
        fileVirtualRoot: "",
        webgl2d : true,
        readOnlyStorage : true,
      };
kg commented 10 years ago

Cool, glad it works!