发布时如何包含 TypeScript 文件? [英] How to include TypeScript files when publishing?
问题描述
我有一个 MVC 5.1 Web 应用程序,我最近开始使用 TypeScript.我想使用源映射,所以我在项目中包含了 .ts、.js 和 .js.map 文件.
I have an MVC 5.1 web application where I have recently started using TypeScript. I want to use sourcemapping, so I have included both the .ts, .js and .js.map-files in the project.
当我发布应用程序(例如文件系统或 Azure)时,只会复制 .js 和 .js.min 文件,而不是 .ts 文件.这意味着我没有在已发布的站点上获得源映射.
When I publish the application (to e.g. file system or Azure), only the .js and .js.min files are copied, not the .ts-file. This means that I do not get source mapping on the published site.
TypeScript 文件具有构建操作":TypeScriptCompile",我已经使用不复制"和始终复制"测试了复制到输出目录",但 .ts 文件仍未发布.
The TypeScript file has "Build Action": "TypeScriptCompile", and I have tested "Copy to Output Directory" both with "Do not copy" and "Copy always", still the .ts-file is not published.
如何在发布我的应用程序时包含 .ts 文件?
How can I include the .ts-files when publishing my application?
(我使用 VS2013 Update 2 with TypeScript 1.0.1 和 Web Essentials 2013 for Update 2)
(I am using VS2013 Update 2 with TypeScript 1.0.1 and Web Essentials 2013 for Update 2)
推荐答案
我通过编辑项目 (csproj) 文件实现了这一点.我将 .ts(它们存储在 TypeScriptCompile 项目中)文件包含到 Content 项目中,即
I achieved this by editing project (csproj) file. I included .ts (they are stored in TypeScriptCompile item) files into Content item i.e.
<Target Name="AddTsToContent" AfterTargets="CompileTypeScript" Condition="'$(BuildingProject)' != 'false'">
<ItemGroup>
<Content Include="@(TypeScriptCompile)" Condition="'$(Configuration)'=='Debug'"/>
</ItemGroup>
</Target>
注意:由于条件的原因,这仅包括 Debug
构建配置的 TypeScript 内容.
Note: Because of the condition, this includes the TypeScript content only for the Debug
build configuration.
这篇关于发布时如何包含 TypeScript 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!