【发布时间】:2021-02-09 20:06:28
【问题描述】:
当使用诸如
之类的例子时<!--Include in publish-->
<ItemGroup>
<None Include="exampleDirectory\**\*.*" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always" />
</ItemGroup>
此文件夹包含 .cshtml 和 .cshtml.cs 文件,但仅复制 .cshtml.cs 文件。这些文件没有复制过来是否有特定原因?
将所需文件夹复制并粘贴到发布输出目录中即可。这意味着如果这种复制机制正常工作并复制了所有文件,这将不是问题。
我将其设置为 <None,因为我需要有两个目录,而使用 <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]
当 EnableDefaultContentItems 设置为 false 时,它仍然不会复制 .cshtml 文件,只复制 .cshtml.cs 文件。
【问题讨论】:
-
@JeremyLakeman 我不这么认为。我正在寻找这些文件夹的直接副本。这样做,代码库可以呈现这些根本不连接到 RazorPages 的视图。他们用
System.IO.File.ReadAllTextAsync(读入