Include TypeScript files in azure git deploy

2019-02-17 06:23发布

I'm trying to include TypeScript files in my automatic git deploy so I can showcase code for a framework I'm building. However, whenever I deploy to azurewebsites the deployments do not include the TypeScript files.

Site in question: http://endgate-samples.azurewebsites.net/Samples/AnimatedSprites/

What I've tried:

  1. Copy all TypeScript files to output folder by setting TypeScript properties to "Copy Always". Issue with this is that I need to change the references to all the files (do not want to do this).

  2. MSBuild pipeline. This works for file system deploy but not web deploy... https://github.com/NTaylorMullen/EndGate/blob/master/EndGate/samples/EndGate.Core.JS.Samples/EndGate.Core.JS.Samples.csproj#L896-L909.

  3. Manual publish to FTP endpoint (works like a charm), but not automatic. Also requires the msbuild pipeline (#2)

What am I doing wrong or what can I do (that I haven't tried) to get my TypeScript files deploying automagically?

1条回答
Anthone
2楼-- · 2019-02-17 07:10

So after a lot of work it turns out that with the msbuild pipeline piece (#2) it will actually deploy the typescript files. One thing that I was missing was adding the appropriate mime type to handle typescript files.

It turns out by default IIS won't serve the TypeScript files correctly.

To add the Custom mime type I did:

<system.webServer>
    <staticContent>
      <remove fileExtension=".ts"/>
      <mimeMap fileExtension=".ts" mimeType="text/plain" />
    </staticContent>
</system.webServer>

It's important that we remove the existing .ts mime type (if there is one) prior to adding the mime type. If you deploy onto a machine that has the .ts mime type already and you do not remove prior to adding, it will pretty much destroy your existing mappings and will fail to serve any css, js files etc.

This has been a battle but I finally got it working, hope this helps somebody else in the future!

查看更多
登录 后发表回答