为什么.Net Core 2.2现在发布了大量其他dll

问题描述 投票:0回答:1

我刚刚将.net core 2.0项目升级到2.2。据我所知,我没有更改任何其他设置,但现在当我发布到我的文件系统时,它发布了大量的文件夹和dll,它以前没有。

我需要发布它们吗?如果没有,我可以抑制他们的输出吗?

这是我的发布配置文件设置:enter image description here

以下是升级前输出目录的样子:enter image description here

现在,这里只是输出目录的一个片段:enter image description here

msbuild visual-studio-2017 asp.net-core-2.2
1个回答
1
投票

简介:此问题似乎来自.net core 2.0。

从您上面分享的图片。我知道你选择Framework-Dependent Mode。

在此模式下,生成的文件应该与picture1中的文件类似。如果您选择自包含模式,生成的文件应该与您在picture2中的文件类似。

但在.net core2.0中,似乎有些不同。当我们在.net core2.0中发布项目时,或者只是像你的那样从2.0升级。我们必须明确地将自包含属性设置为false,以便Framework-Dependent模式可以正常工作。

我需要发布它们吗?

不,当您选择框架相关模式时,您不需要从自包含模式发布生成的文件。

如果没有,我可以抑制他们的输出吗?

这是一个解决方法:

看起来您使用VS IDE发布它,发布时请确保选择“创建配置文件”。所以我们将有一个PublishProfile,我们可以在Solution Window中的Properties下面找到它。打开FolderProfile.pubxml并在<PublishWithAspNetCoreTargetManifest>true</PublishWithAspNetCoreTargetManifest>中添加PropertyGroup。另外,我们可以将<DeleteExistingFiles>false</DeleteExistingFiles>设置为true。

之后,再次发布项目可以解决问题。

PublishProfiles的最终格式如下所示:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    ...
    <publishUrl>bin\Release\netcoreapp2.2\publish\</publishUrl>
    <DeleteExistingFiles>True</DeleteExistingFiles>
    <PublishWithAspNetCoreTargetManifest>true</PublishWithAspNetCoreTargetManifest>
  </PropertyGroup>
</Project>

另外:您可以从this issue找到更多信息。感谢natemcmaster。他的建议在我身边起作用。

© www.soinside.com 2019 - 2024. All rights reserved.