Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Heroku:如何减少.NET核心/角度应用程序段塞大小?_Heroku_Heroku Nodejs - Fatal编程技术网

Heroku:如何减少.NET核心/角度应用程序段塞大小?

Heroku:如何减少.NET核心/角度应用程序段塞大小?,heroku,heroku-nodejs,Heroku,Heroku Nodejs,我收到Heroku关于我的鼻涕虫太大的警告: -----> Compressing... Done: 304.9M -----> Launching... ! Warning: Your slug size exceeds our soft limit (304 MB) which may affect boot time. 如何减少鼻涕虫的大小?它是.NET Core 2.1.401和Angular 6应用程序,因此我使用以下构建包: ) 赫罗库·诺德吉斯

我收到Heroku关于我的鼻涕虫太大的警告:

-----> Compressing...
   Done: 304.9M
-----> Launching...
 !     Warning: Your slug size exceeds our soft limit (304 MB) which may affect boot time.
如何减少鼻涕虫的大小?它是.NET Core 2.1.401和Angular 6应用程序,因此我使用以下构建包:

  • )
  • 赫罗库·诺德吉斯
运行heroku run“du.-h--max depth=3--threshold=1M”会产生以下结果:

2.5M    ./App/obj
524M    ./App/ClientApp/node_modules
16M     ./App/ClientApp/dist
9.4M    ./App/ClientApp/src
549M    ./App/ClientApp
2.5M    ./App/bin/Release
3.3M    ./App/bin
556M    ./App
16M     ./heroku_output/ClientApp/dist
16M     ./heroku_output/ClientApp
130M    ./heroku_output
189M    ./.heroku/dotnet/sdk
140M    ./.heroku/dotnet/shared
329M    ./.heroku/dotnet
27M     ./.heroku/node/lib
3.0M    ./.heroku/node/include
34M     ./.heroku/node/bin
63M     ./.heroku/node
391M    ./.heroku
11M     ./.apt/usr/lib
3.3M    ./.apt/usr/include
15M     ./.apt/usr
15M     ./.apt
1.1G    .
批量存储在
节点模块/
(524M)、
/heroku/dotnet/
(329M)和
/heroku\u输出
(130M)中

我认为我不能使用文件,因为构建过程需要
node\u modules
文件夹,所以我尝试在
dotnet publish
之后使用应用程序的
.csproj
中的此项删除
node\u modules/
文件夹,但它没有减少slug大小

<Target Name="CleanupNodeModules" AfterTargets="Publish">
  <Exec WorkingDirectory="$(SpaRoot)" Command="rm -rf node_modules" Condition=" '$(OS)' != 'Windows_NT' " ConsoleToMSBuild="true" />
</Target>

有什么想法吗

我创建了一个用于将.NET核心项目构建为一个独立的
exe
,然后删除.NET核心SDK

有了它,我就从304MB变成149MB了


看起来
节点\u模块
没有效果…

您可能希望使用它来进一步减小.NET核心输出的大小。本质上,它将检查未使用的依赖项,并删除那些代码无法访问的类库。我在macOS和Windows中看到独立的.NET Core控制台应用程序的大小减少了30-50%。

谢谢,我也会试试!此外,还有ILCompiler,它给了我5Mb的本机映像和~60Mb的标准自包含部署。虽然它在macOS上对我不起作用(启动时应用程序会崩溃)。也许对你有用。。。