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)
The term 'typescript'—sometimes abbreviated in a bibliographical or publishing context to 'TS', 'Ts' or 'ts'—means a page, or series of pages, of text produced by the use of a typewriter. ... From: typescript in A Dictionary of English Manuscript Terminology 1450–2000 »
You can use npm to install TypeScript globally, this means that you can use the tsc command anywhere in your terminal. To do this, run npm install -g typescript . This will install the latest version (currently 4.7).
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.
Based on Stas Berkov's answer, I am conditionally including the .ts
files only when the source maps are generated (as configured in the TypeScript Build
tab of the project's properties).
<Target Name="AddTsToContent" AfterTargets="CompileTypeScript" Condition="'$(BuildingProject)' != 'false'"> <ItemGroup> <Content Include="@(TypeScriptCompile)" Condition="'$(TypeScriptSourceMap)' == 'true'"/> </ItemGroup> </Target>
I placed this as the last element in <Project>
of the .csproj
file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With