【问题标题】:Deploying .Net Core 2.0 App Includes 150+ Dlls部署 .Net Core 2.0 应用程序包括 150 多个 Dll
【发布时间】:2019-08-22 15:35:36
【问题描述】:

我最近将我的 Visual Studio 版本从 2017 年更新到 2019 年,还安装了 .net 核心版本 2.2。我有 .Net Core 2.0 Web 项目,其中仅包含通过 Nudget 打包系统添加的 dll,如下所示;

此文件夹仅包含 22 项。

但在 VS 更新后,当我发布应用程序时,我有一个输出文件夹,如下所示;

此文件夹包含近 200 个 dll。我什至没有更改发布设置。我没有任何这些依赖关系,我确保部署方法不是self-contained deployment而是Framework-dependent Deployment

我正在使用 CLI 命令发布我的应用程序;

dotnet 发布 -c 发布

我的已发布文件夹中有这么多 dll 的原因是什么?

编辑:

这是我的 .csproj 文件的样子:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="AstrodyneTdi.Web" Version="3.2.4" />
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
    <PackageReference Include="NLog.Extensions.Logging" Version="1.0.0-rtm-alpha4" />
    <PackageReference Include="RestSharp" Version="106.6.9" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
  </ItemGroup>

</Project>

【问题讨论】:

  • 我猜它被设置为一个独立的部署,正如你所说的。只需确保,您的“PublishWithAspNetCoreTargetManifest”是否设置为 true?
  • @Jordan 我没有在我的 .csproj 文件中提到那个标志。我更新了我的问题以显示它的样子。
  • 嗯,好吧,我添加了一个答案,因为它对评论来说太罗嗦了。我猜这不是你的问题。这就是我所得到的,祝你好运:)
  • @Jordan 有趣的是它确实有效!出于某种原因,将其升级到 VS 2019 需要我将该标志放入我的 .csproj 文件中。非常感谢。

标签: c# visual-studio .net-core webdeploy


【解决方案1】:

对我来说,我不得不在不久前将此部分添加到 .csproj 文件中,特别是 PublishWithAspNetCoreTargetManifest

MS Documentation

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <Platforms>AnyCPU;x64</Platforms>
    <PublishWithAspNetCoreTargetManifest>true</PublishWithAspNetCoreTargetManifest>
  </PropertyGroup>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-17
    • 2016-01-26
    • 1970-01-01
    • 2019-02-17
    • 1970-01-01
    • 2018-04-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多