代码之家  ›  专栏  ›  技术社区  ›  crichavin

为什么.NETCore2.2现在要发布大量其他DLL

  •  0
  • crichavin  · 技术社区  · 7 年前

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

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

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

    0 回复  |  直到 7 年前
        1
  •  1
  •   LoLance    7 年前

    简介:这个问题似乎源于.NETCore2.0。

    从你上面分享的照片。我知道你选择了框架依赖模式。

    在这种模式下,生成的文件应该与图片1中的一样。如果您选择自包含模式,生成的文件应该与图片2中的一样。

    但在.NETCore2.0中,似乎有些不同。当我们在.NETCore2.0中发布项目时,或者刚从2.0升级到像您这样的版本时。我们必须显式地将self-contained属性设置为false,这样依赖于框架的模式才能正常工作。

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

    这里有一个解决方法:

    看起来您使用VSIDE来发布它,发布时请确保选择“创建配置文件”。所以我们将有一个PublishProfile,我们可以在解决方案窗口的属性下面找到它。打开FolderProfile.pubxml并添加 <PublishWithAspNetCoreTargetManifest>true</PublishWithAspNetCoreTargetManifest> PropertyGroup . 另外,我们可以设置 <DeleteExistingFiles>false</DeleteExistingFiles> 是真的。

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

    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。他的建议确实对我有用。

    推荐文章