I have a post build event that runs reflection code over some of my controllers to generate a definition of my routes in typescript. If I activate the TypescriptCompile option in my csproj, the DLL generation will fail if any Typescript file is not correct. Then my post build event will fail because the dll won't exists.
I want to implement the following schema :
The first 2 steps work fine but I'm stuck at the last one. Failing to find a command line to run typescript compilation on a csproj file.
Let's assume that in the post-build event the TypeScript source files are generated under .\\tsc-src
. And you are using TypeScript 2.0.
You can include a tsconfig.json
file in the tsc-src
folder with following content:
{
"compilerOptions": {
"baseUrl": "",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../tsc-dist",
"sourceMap": true,
"target": "es5"
}
}
Assuming your working directory is in the project folder, if you have already installed TypeScript and tsc
is in your PATH
, you can add a new post-build event command tsc -p ./tsc-src
to compile the TypeScript source files.
Depending on your requirement, you might want to change outDir
field to outFile
field to emit a single JavaScript file. Here's a pointer to the doc.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.