missing TS pane in VS 2013 project properties, and _references.ts is ignored?

Topics: General
Jan 10, 2014 at 2:42 PM
One of the items on the 0.9.5 changelog is a build pane for visual studio 2013 in the project properties to configure TS build settings. I haven't however seen this pane in either an existing project or in test projects. This is an ASP.NET MVC application project. I also have Web Essentials 2013 installed.

The other issue I'm having is that it looks like _references.ts is being ignored. I'm still getting the "implicitly reference all .ts files in the project" behavior from pre-0.9.5, which causes issues, for example, when I'm using both angular-scenario and jasmine typings in the same project (duplicate definitions errors). I have _references.ts in ~/Scripts/_references.ts. Does it need to be somewhere else?
Jan 10, 2014 at 3:28 PM
Regarding your first issue, you need to import TypeScript targets. See https://typescript.codeplex.com/workitem/2014


This might help with the second issue: https://typescript.codeplex.com/workitem/2071
Jan 10, 2014 at 4:14 PM
Hmm.. it might be because I'm referencing a local copy of the TypeScript target files, and not the globally installed one. I'm doing this so that the build server can still build the project without TypeScript globally installed. Here is where I'm including the target file in my .csproj project:
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
    <TypeScriptTarget>ES5</TypeScriptTarget>
    <TypeScriptIncludeComments>true</TypeScriptIncludeComments>
    <TypeScriptSourceMap>true</TypeScriptSourceMap>
    <TypeScriptModuleKind>AMD</TypeScriptModuleKind>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)' == 'Release'">
    <TypeScriptTarget>ES5</TypeScriptTarget>
    <TypeScriptIncludeComments>false</TypeScriptIncludeComments>
    <TypeScriptSourceMap>false</TypeScriptSourceMap>
    <TypeScriptModuleKind>AMD</TypeScriptModuleKind>
  </PropertyGroup>
  <Import Project="$(SolutionDir)\Tools\TypeScript\v$(VisualStudioVersion)\Microsoft.TypeScript.targets" />
  <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
And here is my customized version of Microsoft.TypeScript.targets (modified to use the compiler from $(SolutionDir)\Tools\TypeScript\0.9 instead of the one installed globally).
<!--
***********************************************************************************************
Microsoft.TypeScript.targets

WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
          created a backup copy.  Incorrect changes to this file will make it
          impossible to load or build your web deploy projects from the command-line or the IDE.

This file defines the steps in the standard build process for TypeScript files.

Copyright (C) Microsoft Corporation. All rights reserved.
***********************************************************************************************
-->
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <TsToolsPath>$(SolutionDir)\Tools\TypeScript\v$(VisualStudioVersion)</TsToolsPath>
  </PropertyGroup>

  <UsingTask TaskName="TypeScript.Tasks.VsTsc" AssemblyFile="$(TsToolsPath)\TypeScript.tasks.dll" />
  <UsingTask TaskName="AssignTargetPath"       AssemblyName="Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

  <PropertyGroup>
    <CompileDependsOn>
      CompileTypeScript;
      $(CompileDependsOn);
    </CompileDependsOn>
  </PropertyGroup>

  <PropertyGroup>
    <PublishPipelineCollectFilesCore>
      $(PublishPipelineCollectFilesCore);
      TypeScriptCollectPublishFiles;
    </PublishPipelineCollectFilesCore>
  </PropertyGroup>

  <PropertyGroup>
    <GetCopyToOutputDirectoryItemsDependsOn>
      $(GetCopyToOutputDirectoryItemsDependsOn);
      GetTypeScriptCopyToOutputDirectoryItems;
    </GetCopyToOutputDirectoryItemsDependsOn>
  </PropertyGroup>

  <PropertyGroup>
    <!-- Indicates to the language service that this project supports TypeScript -->
    <TypeScriptEnabled>true</TypeScriptEnabled>

    <!-- Controls Compile-on-Save in the IDE -->
    <TypeScriptCompileOnSaveEnabled Condition="'$(TypeScriptCompileOnSaveEnabled)' == ''">true</TypeScriptCompileOnSaveEnabled>
  </PropertyGroup>

  <PropertyGroup Condition="'$(TypeScriptBuildConfigurations)' == ''">
    <TypeScriptBuildConfigurations Condition="'$(TypeScriptRemoveComments)' == 'true'">$(TypeScriptBuildConfigurations) --removeComments</TypeScriptBuildConfigurations>
    <TypeScriptBuildConfigurations Condition="'$(TypeScriptNoImplicitAny)' == 'true'">$(TypeScriptBuildConfigurations) --noImplicitAny</TypeScriptBuildConfigurations>
    <TypeScriptBuildConfigurations Condition="'$(TypeScriptGeneratesDeclarations)' == 'true'">$(TypeScriptBuildConfigurations) --declaration</TypeScriptBuildConfigurations>
    <TypeScriptBuildConfigurations Condition="'$(TypeScriptModuleKind)' != '' and '$(TypeScriptModuleKind)' != 'none'">$(TypeScriptBuildConfigurations) --module $(TypeScriptModuleKind)</TypeScriptBuildConfigurations>
    <TypeScriptBuildConfigurations Condition="'$(TypeScriptOutFile)' != ''">$(TypeScriptBuildConfigurations) --out &quot;$(TypeScriptOutFile)&quot;</TypeScriptBuildConfigurations>
    <TypeScriptBuildConfigurations Condition="'$(TypeScriptOutDir)' != ''">$(TypeScriptBuildConfigurations) --outDir &quot;$(TypeScriptOutDir)&quot;</TypeScriptBuildConfigurations>
    <TypeScriptBuildConfigurations Condition="'$(TypeScriptSourceMap)' == 'true'">$(TypeScriptBuildConfigurations) --sourcemap</TypeScriptBuildConfigurations>
    <TypeScriptBuildConfigurations Condition="'$(TypeScriptTarget)' != ''">$(TypeScriptBuildConfigurations) --target $(TypeScriptTarget)</TypeScriptBuildConfigurations>
    <TypeScriptBuildConfigurations Condition="'$(TypeScriptNoResolve)' == 'true'">$(TypeScriptBuildConfigurations) --noResolve</TypeScriptBuildConfigurations>
    <TypeScriptBuildConfigurations Condition="'$(TypeScriptAdditionalFlags)' != ''">$(TypeScriptBuildConfigurations) $(TypeScriptAdditionalFlags)</TypeScriptBuildConfigurations>
    <TypeScriptBuildConfigurations Condition="'$(TypeScriptMapRoot)' != ''">$(TypeScriptBuildConfigurations) --mapRoot &quot;$(TypeScriptMapRoot)&quot;</TypeScriptBuildConfigurations>
    <TypeScriptBuildConfigurations Condition="'$(TypeScriptSourceRoot)' != ''">$(TypeScriptBuildConfigurations) --sourceRoot &quot;$(TypeScriptSourceRoot)&quot;</TypeScriptBuildConfigurations>
    <TypeScriptBuildConfigurations Condition="'$(TypeScriptCodePage)' != ''">$(TypeScriptBuildConfigurations) --codepage $(TypeScriptCodePage)</TypeScriptBuildConfigurations>
  </PropertyGroup>

  <PropertyGroup>
    <TypeScriptToolsVersion Condition="'$(TypeScriptToolsVersion)'==''">0.9</TypeScriptToolsVersion>
    <TscToolPath Condition="'$(TscToolPath)' == ''">$(SolutionDir)\Tools\TypeScript</TscToolPath>
    <TscToolPath Condition="'$(TypeScriptToolsVersion)' != ''">$(TscToolPath)\$(TypeScriptToolsVersion)</TscToolPath>
    <TscToolExe Condition="'$(TscToolExe)' == ''">tsc.exe</TscToolExe>
    <TscYieldDuringToolExecution Condition="'$(TscYieldDuringToolExecution)' == ''">true</TscYieldDuringToolExecution>
  </PropertyGroup>

  <ItemGroup>
    <PropertyPageSchema Include="$(MSBuildThisFileDirectory)\$(LangName)\TypeScriptProjectProperties.xaml;">
      <Context>Project;BrowseObject</Context>
    </PropertyPageSchema>
  </ItemGroup>

  <ItemGroup>
    <ProjectCapability Include="TypeScript" />
  </ItemGroup>

  <Target Name="CompileTypeScript" Condition="'$(BuildingProject)' != 'false'">
    <VsTsc
      ToolPath="$(TscToolPath)"
      ToolExe="$(TscToolExe)"
      Configurations="$(TypeScriptBuildConfigurations)"
      FullPathsToFiles="@(TypeScriptCompile)"
      YieldDuringToolExecution="$(TscYieldDuringToolExecution)"
      OutFile="$(TypeScriptOutFile)"
      OutDir="$(TypeScriptOutDir)"
      ProjectDir="$(ProjectDir)"
      >
      <Output TaskParameter="GeneratedJavascript" ItemName="GeneratedJavascript" />
    </VsTsc>
  </Target>

  <Target Name="TypeScriptCollectPublishFiles" DependsOnTargets="CompileTypeScript">
    <Message Text="Adding to FilesForPackagingFromProject: @(GeneratedJavascript->'%(Identity)')"/>
    <ItemGroup>
      <FilesForPackagingFromProject Include="@(GeneratedJavascript->'%(Identity)')"/>
    </ItemGroup>
  </Target>

  <Target Name="GetTypeScriptCopyToOutputDirectoryItems">
    <AssignTargetPath Files="@(TypeScriptCompile)" RootFolder="$(MSBuildProjectDirectory)">
      <Output TaskParameter="AssignedFiles" ItemName="TypeScriptCompileWithTargetPath" />
    </AssignTargetPath>
    <Message Text="Adding items with BuildAction=TypeScriptCompile to the same collections that will be populated (with items of other BuildActions) by the GetCopyToOutputDirectoryItems target"/>
    <ItemGroup>
      <AllItemsFullPathWithTargetPath            Include="@(TypeScriptCompileWithTargetPath->'%(FullPath)')" Condition="'%(TypeScriptCompileWithTargetPath.CopyToOutputDirectory)'=='Always' or '%(TypeScriptCompileWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest'"/>
      <_SourceItemsToCopyToOutputDirectoryAlways Include="@(TypeScriptCompileWithTargetPath->'%(FullPath)')" Condition="'%(TypeScriptCompileWithTargetPath.CopyToOutputDirectory)'=='Always'"/>
      <_SourceItemsToCopyToOutputDirectory       Include="@(TypeScriptCompileWithTargetPath->'%(FullPath)')" Condition="'%(TypeScriptCompileWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest'"/>
    </ItemGroup>
  </Target>

</Project>
Jan 10, 2014 at 4:52 PM
Aha, I found the issue. I accidently copied the v11 version of the typescript msbuild files to the v12 directory. Also I was missing this line at the top of the project:

// Standard version:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')" />
// My customized version:
<Import Project="$(SolutionDir)\Tools\TypeScript\v$(VisualStudioVersion)\Microsoft.TypeScript.Default.props" Condition="Exists('$(SolutionDir)\Tools\TypeScript\v$(VisualStudioVersion)\Microsoft.TypeScript.Default.props')" />