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

Chr*_*nch 5 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
Run Code Online (Sandbox Code Playgroud)

在.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>
Run Code Online (Sandbox Code Playgroud)

它看起来像TSC编译器没有正确解析路径.有人可以验证吗?

谢谢

Fen*_*ton 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>
Run Code Online (Sandbox Code Playgroud)

来源

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