使用 tsc 命令就像运行一样简单:
tsc --out all.js js/*.ts
在构建项目时如何配置 Visual Studio 来执行此操作?
使用 tsc 命令就像运行一样简单:
tsc --out all.js js/*.ts
在构建项目时如何配置 Visual Studio 来执行此操作?
通过修改您正在构建的项目(.csproj / .vbproj)的构建属性,我找到了一个可能更简单的解决方案:
我不确定在哪个版本的 Typescript 中引入了此功能。但这似乎比 svallory 的解决方案简单得多
编辑:自 Visual Studio 2015 以来,现在很容易集成 Grunt/Gulp 任务并让它们在您的构建中运行。我个人非常喜欢使用 Gulp 来更精细地控制我构建和/或缩小的文件,我强烈推荐它。使用本指南作为起点应该会有所帮助。
刚刚得到它。添加这一行:
<Exec Command="tsc --out all.js @(TypeScriptCompile ->'"%(fullpath)"', ' ')" />
到您的或文件的BeforeBuild
目标,如下所示:.csproj
.vbproj
<Target Name="BeforeBuild">
<Message Text="Compiling TypeScript files" />
<Message Text="Executing tsc$(TypeScriptSourceMap) @(TypeScriptCompile ->'"%(fullpath)"', ' ')" />
<Exec Command="tsc$(TypeScriptSourceMap) @(TypeScriptCompile ->'"%(fullpath)"', ' ')" />
<Exec Command="tsc --out all.js @(TypeScriptCompile ->'"%(fullpath)"', ' ')" />
</Target>
似乎建议的解决方案适用于打字稿 0.8.1.1 而不是 0.8.2