简体   繁体   English

在编译时编译的脚本不起作用

[英]Typescript compile on build not working

I have VS2015 and ASP.NET 5 RC1 project with some typescript files. 我有VS2015和ASP.NET 5 RC1项目与一些打字稿文件。 Files are located in scripts folder and tsconfig is in this folder too. 文件位于脚本文件夹中,tsconfig也位于此文件夹中。 When I'm saving typescript file, js file is generated and everything is ok. 当我保存typescript文件时,生成了js文件,一切正常。 But js files are not generated during build. 但是在构建期间不会生成js文件。

I have VS2013 installed also and some old projects using typescript, so may be there are some problems cause I have many TypeScript versions and many VS versions. 我也安装了VS2013和一些使用打字稿的旧项目,因此可能会出现一些问题,因为我有很多TypeScript版本和许多VS版本。

How can I troubleshoot compiling typescript during build? 如何在构建期间对编译打字稿进行故障排除? Build log says nothing about typescript. 构建日志没有说明打字稿。 Checkbox 'Compile TypeScript on build' is project settings is enabled. 复选框'在构建时编译TypeScript'是项目设置已启用。 In old ASP.NET projects TypeScript is enabled via custom target in csproj and it's easy to troubleshoot. 在旧的ASP.NET项目中,TypeScript是通过csproj中的自定义目标启用的,并且很容易进行故障排除。 But in xproj I don't see any typescript related things. 但在xproj中我没有看到任何打字稿相关的东西。

My current working solution is to add postbuild event which manually calls TypeScript compiler. 我目前的工作解决方案是添加手动调用TypeScript编译器的postbuild事件。

project.json: project.json:

"scripts": {
    "postbuild": ["tsc -p scripts\\tsconfig.json"]
}

(assumes you have tsc in your PATH variable) (假设您的PATH变量中有tsc)

I had the exact same issue. 我有完全相同的问题。 Worked for me when I edited tsconfig, and placed compileOnSave BEFORE compilerOptions in tsconfig : 在我编辑tsconfig时为我工作,并在tsconfig中的compilerOptions之前放置了compileOnSave

{
    "compileOnSave": true
    "compilerOptions": {
         ....
    },
}

确保在您的解决方案文件中添加“Import Project =”$(MSBuildExtensionsPath)\\ $(MSBuildToolsVersion)\\ Microsoft.Common.props“Condition =”Exists('$(MSBuildExtensionsPath)\\ $(MSBuildToolsVersion)\\ Microsoft.Common。道具')”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM