typescript for web forms typescript for web forms asp.net asp.net

typescript for web forms


Found the answers to my problems:

  1. I was trying to find "Typescript file" in Web folder of the "Add New Item" dialog, although it is in the "Visual C#" folder ..... Why?

  2. Unless you have a .ts file created with "Add New Item" in your project, the option "TypeScriptCompile" on the "Build Action" of the file properties is not available and it raises an exception. After the first file is created, then you find this option and can manually set it to a .ts file.

  3. The option "Typescript file" is not available in the "Add File" options unless you have a .ts file created with "Add New Item" in your project and you are in a "Scripts" folder (if you name differently the folder where you want to add this file, this option wont be available). Of course you can add a .ts file from "Add New Item".

  4. You cannot easily create a ts file by your own, you must use "New Typescript file" from menu. That is because: A) The code page of the file must not be Unicode (I was trying to figure out that problem for many hours). if you try to compile a unicode .ts file with tsc, nothing happens!! After I saved the .ts file as Greek(Windows) - in my case-, everything worked fine! B) The .csproj properties that must be set for each file to work correctly are quite complex. (I was trying to create a .ts file starting from a .js file and renaming afterwards.... and then playing with .csproj)


I just created a new Web Application using web forms (empty project).

I found I have to add the Target to my project file...

   <Target Name="BeforeBuild">    <Exec Command=""$(PROGRAMFILES)\Microsoft SDKs\TypeScript\0.8.0.0\tsc" @(TypeScriptCompile ->'"%(fullpath)"', ' ')" />  </Target>

You need to right-click and select "Unload project", then right-click and select "Edit". This block can go right at the end, just before the </Project> tag.

I didn't have any problems adding a TypeScript file in Visual Studio 2012.