Frame up
I have a MVC project that has C# classes in it that are ultimately serialized and consumed via ajax, etc. I use TypeLite to generate definitions of these C# classes (alternatives to TypeLite are discussed here), so I can get compile time checking against the code that consumes these json serialized C# classes. This way, if the C# definition changes and my TypeScript code doesn't, I will get a compile time error because it's tied directly to the C# definition
Initial Problem
Currently my TypeScript exists in the same project as my C# classes. So I have a very weird circular dependency issue. To resolve this, I have to follow a very particular pattern
- Update the C# class
- Compile the MVC project
- Run TypeLite, generating the definitions
- Update the TypeScript or encounter a compilation error at next build time.
I don't like this because I can't automatically run TypeLite as part of my build process. I can't do that since TypeLite needs the C# assembly from the MVC project to be built first in order to run and get access to the definitions. Also, I have to include the generated definitions in the code repository, which I don't like to do since its generated code and someone could forget to generate it and commit it / check it in.
Proposed Solution
I can easily break this circular dependency if I have a TypeScript project that depends on my MVC project. That way I can include TypeLite in the build, by removing it from the MVC project and placing it in the TypeScript project.
This approach feels very correct to me, since the TypeScript project is a separate, compiled project, that has a dependency on an assembly that is built before its own project.
Actual Problem / Question
Unfortunately I don't know how to have a TypeScript project outside of my MVC project that builds and then copies the generated JavaScript back into the MVC project (for deployments via web deploy and/or azure web role deployments). So, how would I have a TypeScript project that is separate from my MVC project that builds AFTER the MVC project and then copies the generated JavaScript back into the MVC project for deployment?