Q:

Per-Page Javascript files from one project using Script#?

Is it possible to have one Script# project and make multiple Javascript files out of it? What I'd like to do is have one Script# project and have it emit one Javascript file per class or namespace. I know that you can't really generate multiple DLLs out of a .NET class project, but in this case it would be helpful to have the Javascript split out so you're not loading the whole thing. Or am I thinking about this the wrong way? I'm using VS2010.

A:

Yes, you can... but you have to be careful when you start doing this.
In your csproj, you can add the property
<WebAppPartitioning>True</WebAppPartitioning>

This will tell the script# build task to build a .js file per top-level folder in your project. Any code you want to include into every .js file can be put into a top-level folder named "Shared".
Here is where you need to be careful - the c# compiler compiles the entire project rather than one folder at a time. So for example, its easy for one folder to reference code in another folder, and csc.exe will compile just fine. The script# won't see things the same way, since it only looks at a folder at a time. However, the script# compiler was written to assume the code compiled using it was first successfully compiled with c#. So this whole per-folder compile model violates a basic design assumption.
Hence if you use this feature, you'll need to be careful. Hope that helps.

