简体   繁体   English

Nuget 包 Microsoft.TypeScript.MSBuild 在 Dockerfile 中失败

[英]Nuget package Microsoft.TypeScript.MSBuild fails in Dockerfile

I have an ASP.NET Core project that includes several TypeScript files.我有一个包含多个 TypeScript 文件的 ASP.NET Core 项目。 The project has Microsoft.TypeScript.MSBuild reference to automatically compile these TS files to JavaScript files.该项目具有Microsoft.TypeScript.MSBuild引用,可自动将这些 TS 文件编译为 JavaScript 文件。

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

The setting worked until I tried to dockerize my project.该设置一直有效,直到我尝试对我的项目进行 dockerize。 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. /root/.nuget/packages/microsoft.typescript.msbuild/3.2.3/tools/Microsoft.TypeScript.targets(305,5):错误 MSB6003:无法运行指定的任务可执行文件“节点”。 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没有这样的文件或目录 [/app/MyProject.csproj] 命令“/bin/sh -c dotnet publish -c Release -o out”返回非零代码:1

How to resolve the issue?如何解决问题?

On Windows, Microsoft.TypeScript.MSBuild includes tsc.exe.在 Windows 上, Microsoft.TypeScript.MSBuild包括 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.在非 Windows 平台上,例如在 Docker 容器中, Microsoft.TypeScript.MSBuild不包含 ts.exe,而是外壳到 TypeScript 编译器的节点。 The official dotnet/sdk Docker images I think included Node at one point in the past, but they no longer include Node.我认为官方的 dotnet/sdk Docker 镜像过去曾包含 Node,但它们不再包含 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.您需要使用 dotnet-sdk 和 Node 制作或查找 Docker 镜像,或者配置一些涉及官方 Node 镜像的多阶段构建。

Thanks for the question!感谢提问! Saved me from asking it myself.让我免于自己问。

For me the fix was as simple as running sudo apt-get install nodejs (Using Ubuntu 18.04)对我来说,修复就像运行sudo apt-get install nodejs一样简单(使用 Ubuntu 18.04)

In linux containers You have to install node first.在 linux 容器中您必须先安装节点。 Add the following lines to your dockerfile.将以下行添加到您的 dockerfile。 Add it before "RUN dotnet build"在“RUN dotnet build”之前添加它

RUN apt-get update -yq && apt-get upgrade -yq && apt-get install -yq curl git nano
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && apt-get install -yq nodejs build-essential
RUN npm install -g npm
RUN npm install

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 NuGet Microsoft.NET.Build.Containers 使用新的隐式 dockerfile 功能发布 do.net 在 GitLab cicd 中失败 - dotnet publish with new implicit dockerfile feature using NuGet Microsoft.NET.Build.Containers fails in GitLab cicd MSBuild nuget 包:要添加到 .csproj 文件中的内容? - MSBuild nuget package: what to add to .csproj file? 无法添加本地nuget package到Dockerfile - Unable to add local nuget package to Dockerfile MSBuild忽略已安装的nuget(NuGet 3),失败 - MSBuild ignores installed nugets (NuGet 3), fails 从 NuGet 包实现 StyleCop MSBUILD - Implementing StyleCop MSBUILD From NuGet Package Azure广告无法在microsoft.systemForCrossDomainIdentityManagement nuget程序包上使用补丁更新用户 - Azure Ad fails to update users using Patch on microsoft.systemForCrossDomainIdentityManagement nuget package NuGet 无法找到现有包 - NuGet fails to find existing package NuGet恢复后,MSBuild在单元测试项目(.NET Core)上失败 - MSBuild fails on Unit Test Project (.NET Core) after NuGet Restore Microsoft.WindowsAzure.ServiceRuntime的NuGet包在哪里? - Where is the NuGet package for Microsoft.WindowsAzure.ServiceRuntime? 哪个nuget软件包在Nuget中包含Microsoft.WindowsAzure.StorageClient.dll - Which nuget package holds the Microsoft.WindowsAzure.StorageClient.dll in Nuget
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM