c# - 如何将文件夹从 dotnet core 项目复制到发布文件夹。特别是 .cshtml 文件
问题描述
使用示例时,例如
<!--Include in publish-->
<ItemGroup>
<None Include="exampleDirectory\**\*.*" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always" />
</ItemGroup>
此文件夹有.cshtml
和.cshtml.cs
文件,但仅.cshtml.cs
复制文件。这些文件不复制是否有特定原因?
将所需文件夹复制并粘贴到发布输出目录中即可。这意味着如果这种复制机制刚刚工作并复制了所有文件,这将不是问题。
我之所以设置它,是<None
因为我需要有两个目录,并且 using<Content
给出了使用两个内容的错误。
C:\Program Files\dotnet\sdk\3.1.404\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets(318,5): error NETSDK1022: Duplicate 'Content' items were included. The .NET SDK includes 'Content' i
tems from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultContentItems' property to 'false' if you want to explicitly include them in yo
ur project file. For more information, see https://aka.ms/sdkimplicititems. The duplicate items were: 'dirName\fileName.cshtml'; 'dirName\fileName.cshtml' [C:\path\to\projectName.csproj]
当设置为 false 时,EnableDefaultContentItems
它仍然不会复制.cshtml
文件,只是复制.cshtml.cs
文件。
解决方案
为什么你有“无”?
例子:
<ItemGroup> <Content Include="AppData\**" CopyToPublishDirectory="PreserveNewest"/> </ItemGroup>
推荐阅读
- r - R应用和过滤很慢,替代品?
- angular - 加载资源失败:服务器在 Angular-7 和 Laravel-5.8 中响应状态为 422(无法处理的实体)
- java - 为什么我不能从 AsyncTask 加载位图?
- django - Django通过具有多个关系的两个值的总和进行注释
- python - 这种类型的导入是什么意思?
- asp.net-core - 如何解决异常 HotChocolate.SchemaException:“无法创建类型的实例。” GraphQl-热巧克力
- javascript - 如何使用数学 jax?
- python - 遍历 MultiDict 中的键和所有值
- azure-cosmosdb - 宇宙数据库。一旦数据最终一致,是否会触发更改提要?
- vue.js - 使用单独的组件显示嵌套列表