3

When I try to build my solution in Visual Studio 2012, the javascript file is not generated. It only happens for a specific file.

1
  • If you delete the file and create it again through VS that will probably fix the problem. Commented Jun 6, 2013 at 17:35

5 Answers 5

8

The problem for me was that the file's Build Action was set incorrectly.

Go to the file's properties and make sure that it is set to TypeScriptCompile.

File Properties: TypeScriptCompile

Sign up to request clarification or add additional context in comments.

Comments

2

I found that for a fresh project my .csproj file was missing some important lines - no idea why, but easy fix which I talk about it a bit in my TypeScript blog:

...despite the “Build Action” for the .ts file being correctly set to “TypeScriptCompile”. To fix this I had to

Right click on the project in solution explorer and choose Unload Project Right click the project and choose Edit Add the bold lines from the code below in their relevant sections

<PropertyGroup Condition=”‘$(Configuration)’ == ‘Debug'”>

<TypeScriptTarget>ES3</TypeScriptTarget>

<TypeScriptRemoveComments>false</TypeScriptRemoveComments>

<TypeScriptSourceMap>true</TypeScriptSourceMap>

<TypeScriptModuleKind>AMD</TypeScriptModuleKind>

</PropertyGroup>

<PropertyGroup Condition=”‘$(Configuration)’ == ‘Release'”>

<TypeScriptTarget>ES3</TypeScriptTarget>

<TypeScriptRemoveComments>true</TypeScriptRemoveComments>

<TypeScriptSourceMap>false</TypeScriptSourceMap>

<TypeScriptModuleKind>AMD</TypeScriptModuleKind>

</PropertyGroup>

<Import Project=“$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets” />

The import line should go towards the end of the project file where other Import elements appear. After making this change my .ts files compiled properly. It would appear to me that this bug was taken care of in subsequent releases of TypeScript as it is not a problem with Visual Studio 2013 and TS 1.4.

Right click on the project in the solution explorer and reload the project.

Comments

1

Install Web Essentials http://visualstudiogallery.msdn.microsoft.com/07d54d12-7133-4e15-becb-6f451ea3bea6

It has a setting for compile on build: enter image description here

2 Comments

As of Web Essentials 3.0, all TypeScript support has been removed. More info here: madskristensen.net/post/…
ProVega's Link updated: madskristensen.net/post/… (no .aspx suffix)
0

Install the TypeScript for Visual Studio plugin you will be able to see the JS code as soon as you save the TS file. You can also debug the JS this way.

Comments

0

The current Typescript plugin for VS2013 compiles only on save, not on build. This can be a pain if some typescript files are edited outside or if the project has to be rebuilt from scratch.

I added the following at the end of the csproj, in the <Target Name="AfterBuild"> section.

<Exec Command="tsc.exe -target ES5 --sourcemap _core.ts"
    WorkingDirectory="$(MSBuildProjectDirectory)\js" />

where js is the directory where the typescript files are and _core.ts is the main typescript referencing all other typescripts in its header.

Now even if a co-workers fetches the project, it will automatically rebuild all javascript files.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.