ASP.NET Core:在发布时排除或包含文件

编程入门 行业动态 更新时间:2024-10-21 12:00:03
本文介绍了ASP.NET Core:在发布时排除或包含文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

project.json文件中的aspdotnet1.0包含/排除部分之前

There were before aspdotnet1.0 include/exclude sections on project.json file

{ "exclude": [ "node_modules", "bower_components" ], "publishExclude": [ "**.xproj", "**.user", "**.vspscc" ] }

ASP.NET Core 1.1中的此部分在哪里(没有project.json)? .csproj文件或.pubxml上是否有类似的部分?

Where is this section in ASP.NET Core 1.1 (there is no project.json)? Are there similar sections on .csproj file or .pubxml?

推荐答案

来自文档:如果您希望指定(例如,一些文件要随您的应用发布),您仍然可以使用csproj中的已知机制(例如,<Content>元素).

From documentation: if you wish to specify, for example, some files to get published with your app, you can still use the known mechanisms in csproj for that (for example, the <Content> element).

对于ItemGroup 元素,有一个CopyToPublishDirectory属性.确定是否将文件复制到发布目录,并且可以具有以下值之一:

There is a CopyToPublishDirectory attribute for ItemGroup elements that determines whether to copy the file to the publish directory and can have one of the following value:

  • 总是
  • PreserveNewest
  • 从不

请注意,输出文件夹也有类似的CopyToOutputDirectory属性.

Note, that there is also similar CopyToOutputDirectory attribute for output folder.

示例(来自此处):

<ItemGroup> <None Include="notes.txt" CopyToOutputDirectory="Always" /> <!-- CopyToOutputDirectory = { Always, PreserveNewest, Never } --> <Content Include="files\**\*" CopyToPublishDirectory="PreserveNewest" /> <None Include="publishnotes.txt" CopyToPublishDirectory="Always" /> <!-- CopyToPublishDirectory = { Always, PreserveNewest, Never } --> </ItemGroup>

如果您很感兴趣project.json -.csproj迁移如何使用CopyToPublishDirectory属性来迁移发布选项,则可以查看 MigratePublishOptionsRule 类.

If you are interesting how project.json -.csproj migration use CopyToPublishDirectory attribute to migrate publish options, you may look into MigratePublishOptionsRule class in dotnet cli repo.

更多推荐

ASP.NET Core:在发布时排除或包含文件

本文发布于:2023-11-07 11:04:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1566282.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   ASP   NET   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!