Tuesday, 26 November 2013

TypeScript output missing from MSBuild published packages

Very quick note on something our lead front-end developer discovered today.
By default, MSBuild will not package up the output generated by the TypeScript compiler.

To correct this, you must update your .csproj

  <Target Name="TypeScriptJsCollectFiles">
    <ItemGroup>
      <_CustomFiles Include=".\**\*.js" />
      <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
        <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
      </FilesForPackagingFromProject>
    </ItemGroup>
  </Target>
  <PropertyGroup>
    <CopyAllFilesToSingleFolderForPackageDependsOn>
      TypeScriptJsCollectFiles;
      $(CopyAllFilesToSingleFolderForPackageDependsOn);
    </CopyAllFilesToSingleFolderForPackageDependsOn>

    <CopyAllFilesToSingleFolderForMsdeployDependsOn>
      TypeScriptJsCollectFiles;
      $(CopyAllFilesToSingleFolderForPackageDependsOn);
    </CopyAllFilesToSingleFolderForMsdeployDependsOn>

  </PropertyGroup>