Search code examples
.nettypescriptembedded-resource

Embedding TypeScript JS output in DLL as a resource


I am writing a DLL library that needs to provide some JavaScript code to the parent website. The JavaScript will be the compiled output from a TypeScript file in the project.

Since TypeScript was merged into Visual Studio it does not add the output files into the project. While this makes sense for a web project, for a DLL it does not.

At present, my workaround is to manually include the .js output file in the project and mark it as an embedded resource so that it can be exported and used in the website. However doing this causes the file to fall under TFS source control - and if checked in is read only causing compile errors. So I have to keep the .js files checked out all the time.

Wondering if there are any alternative solutions people might suggest?


Solution

  • There aren't any clear workarounds to this problem.

    When we were developing the TypeScript project system in Visual Studio, this was the exact problem we ran into when we included the .js file in the project (as a child item of the .ts file). Everyone using TFS complained that it was annoying to have the .js file be read-only, so we removed it from the project. At that point, everyone who wasn't using TFS complained that it was inconvenient to not have the .js file be in the project.

    Fortunately for them, it's easy to go from "in the project" to "not in the project" or vice-versa. Unfortunately for you, it sounds like you need to be in both states at once.

    You might try having a separate dependent project of the embedding project that checks out the .js file conditionally as part of a post-build step. I haven't tried, but it could work.