4

I've been trying to get my TypeScript files compiled to JavaScript files in my CI build process on VSTS. Once the JavaScript files have been generated then my gulp file process can process them to the wwwroot folder. The project builds fine in Visual Studio 2017 with VS obeying the tsconfig.json file by compiling the file on change and then the Task Runner running the gulp file on detected changes and build. All the correct files are genereated when building or publishing locally in Visual Studio.

When trying to set up my build process in VSTS as part of my CI/CD process the C# code is built using the "dotnet.exe build" command which does not appear to compile the TypeScript files.

How can I have the .Net Core 2 project build both the C# AND the TypeScript files compiled and built in VSTS?

1 Answer 1

8

By default, dotnet build command won’t compile TypeScript file. You can install Microsoft.TypeScript.MSBuild package, then the TypeScript file will be compiled through dotnet build command.

On the other hand, you also can call tsc command to compile TypeScript file.

3
  • Thanks. Will that obey the tsconfig.json file settings or is there another way to set the options for the typescript compiler? Jan 16, 2018 at 22:55
  • Yes, it will obey the tsconfig.json file in your project. Jan 17, 2018 at 1:19
  • As an addition to this answer: please make sure you use the right version of the package. We're currently using TypeScript 2.5, installing the latest version of the NuGet package (2.7) breaks the build. The NuGet package versions seem to be in line with TypeScript versioning. Feb 28, 2018 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.