如果Typescript位于子文件夹中,则不会编译?

时间:2012-11-13 22:44:34

标签: visual-studio-2012 typescript

我在VS2012有两个项目。一个创建为“带有Typescript的HTML应用程序”和一个(DLL),我将一个Typescript文件添加到现有项目中(我将BeforeBuild Target添加到现有项目中)。

当我编译HTML App项目时,它很好地将TS编译为JS并将JS添加为内容。

当我编译我的DLL时,我没有从TSC获得任何结果...既不在我放TS文件的文件夹中也不在根目录或任何其他文件夹中...我没有得到任何错误或其他提示什么可能是错的。

在两个项目的属性中,TS文件显示为:

BuildAction: TypeScriptCompile
Copy to output....: Do not copy

在.csproj文件中,项目组内的部分如下所示:

<ItemGroup>
...(Lots of other "EmbeddedResources" in this ItemGroup)
    <TypeScriptCompile Include="C-DCommunication\ClientBin\CDEHTML5\cdeUX5.ts" />
    <Content Include="C-DCommunication\ClientBin\CDEHTML5\cdeUX5.js">
      <DependentUpon>cdeUX5.ts</DependentUpon>
    </Content>
...(more files in my ItemGroup)
</ItemGroup>

在我看来,TSC编译器没有正确解析路径。有人可以验证吗?

由于

1 个答案:

答案 0 :(得分:1)

当我将TypeScript添加到现有项目时,我倾向于将以下内容添加到我的项目文件中:

  <ItemGroup>
    <AvailableItemName Include="TypeScriptCompile" />
  </ItemGroup>
  <ItemGroup>
    <TypeScriptCompile Include="$(ProjectDir)\**\*.ts" />
  </ItemGroup>
  <Target Name="BeforeBuild">
    <Exec Command="&quot;$(PROGRAMFILES)\Microsoft SDKs\TypeScript\0.8.0.0\tsc&quot; @(TypeScriptCompile ->'&quot;%(fullpath)&quot;', ' ')" />
  </Target>

Source

但是如果您使用Web Essentials Visual Studio扩展,它会在保存时将TypeScript编译为JavaScript,我发现它可以为开发提供更好的流程。

相关问题