Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget package Microsoft.TypeScript.MSBuild fails in Dockerfile

I have an ASP.NET Core project that includes several TypeScript files. The project has Microsoft.TypeScript.MSBuild reference to automatically compile these TS files to JavaScript files.

  <ItemGroup>
    <PackageReference Include="Microsoft.TypeScript.MSBuild" Version="3.2.3" />
  </ItemGroup>

The setting worked until I tried to dockerize my project. When I follow the example here, the error occurs:

/root/.nuget/packages/microsoft.typescript.msbuild/3.2.3/tools/Microsoft.TypeScript.targets(305,5): error MSB6003: The specified task executable "node" could not be run. No such file or directory [/app/MyProject.csproj] The command '/bin/sh -c dotnet publish -c Release -o out' returned a non-zero code: 1

How to resolve the issue?

like image 422
Robert Vandenberg Avatar asked Jan 02 '19 13:01

Robert Vandenberg


1 Answers

On Windows, Microsoft.TypeScript.MSBuild includes tsc.exe. On non-Windows platforms, such as in a Docker container, Microsoft.TypeScript.MSBuild does not include ts.exe and instead shells out to a Node for the TypeScript compiler. The official dotnet/sdk Docker images I think included Node at one point in the past, but they no longer include Node. You will either need to make or find a Docker image with both the dotnet-sdk and Node, or configure some multi-stage build involving the official Node image.

like image 62
kamcma Avatar answered Nov 03 '22 02:11

kamcma