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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With