发布时如何包含TypeScript文件? [英] How to include TypeScript files when publishing?

查看:203
本文介绍了发布时如何包含TypeScript文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MVC 5.1 Web应用程序,我最近开始使用TypeScript。我想使用源代码,所以我已经在项目中包含了.ts,.js和.js.map文件。



当我发布应用程序例如文件系统或Azure),只复制.js和.js.min文件,而不是.ts文件。这意味着我没有在发布的网站上获取源映射。



TypeScript文件具有Build Action:TypeScriptCompile,我已经测试了复制到输出目录两者都有不要复制和永远复制,仍然没有发布.ts文件。



如何在.ts文件中添加发布我的应用程序?



(我正在使用带有TypeScript 1.0.1的VS2013 Update 2和更新2的Web Essentials 2013)

解决方案

我通过编辑项目(csproj)文件实现了这一点。我将.ts(它们存储在 TypeScriptCompile 项目中)文件放入内容项目,即

 code>< Target Name =AddTsToContentAfterTargets =CompileTypeScriptCondition ='$(BuildingProject)'!='false'> 
< ItemGroup>
< Content Include =@(TypeScriptCompile)Condition ='$(Configuration)'=='Debug'/>
< / ItemGroup>
< / Target>

注意:由于条件,这包括仅适用于调试构建配置。


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.

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.

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.

How can I include the .ts-files when publishing my application?

(I am using VS2013 Update 2 with TypeScript 1.0.1 and Web Essentials 2013 for Update 2)

解决方案

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>

Note: Because of the condition, this includes the TypeScript content only for the Debug build configuration.

这篇关于发布时如何包含TypeScript文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆