我有一个asp.net核心1.1应用程序。
它的.csproj有一个条目
<EnableDefaultContentItems>false</EnableDefaultContentItems>当我在网上搜索这个内容时,我发现的只是关于重复内容错误的问题。这里启用的默认项(或者更确切地说是未启用)是什么?而且,微软是否在某个我应该知道的地方记录了这一点呢?
发布于 2017-10-27 22:17:44
这是新项目格式的一部分,特别是用于ASP.NET核心项目的新的ASP.NET项目SDK。
默认情况下,EnableDefaultContentItems是true。SDK的MSBuild属性项目然后是包含以下内容
<ItemGroup Condition=" '$(EnableDefaultItems)' == 'true' And '$(EnableDefaultContentItems)' == 'true' ">
<!-- Publish everything under wwwroot, all JSON files, all web.config files and all Razor files -->
<Content Include="wwwroot/**" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
<Content Include="**/web.config" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);wwwroot/**" />
<Content Include="**/*.cshtml" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);wwwroot/**" />
<Content Include="**/*.json" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);wwwroot/**" />
<!-- Set CopyToPublishDirectory to Never for items under AppDesignerFolder ("Properties", by default) to avoid publishing launchSettings.json -->
<Content Update="$(AppDesignerFolder)/**" CopyToPublishDirectory="Never" Condition="'$(AppDesignerFolder)' != ''"/>
<!-- Remove Content items from other item types (in a way that CPS understands) -->
<None Remove="wwwroot/**;**/*.json;**/web.config;**/*.cshtml" />
<Compile Remove="wwwroot/**" />
<EmbeddedResource Remove="wwwroot/**" />
<!-- Keep track of the default content items for later to distinguish them from newly generated content items -->
<_ContentIncludedByDefault Include="@(Content)" />
</ItemGroup>因此,基本上,EnableDefaultContentItems自动使项目:
wwwroot/中的所有文件、任何web.config以及所有.cshtml和.json文件。Properties/文件夹因此,如果您使用的是wwwroot文件夹,并且没有更改它的名称,那么建议您保留默认设置,以避免在项目中手动指定所有这些异常。这些只是常见的默认设置,可以让您的项目在不受MSBuild影响的情况下快速运行。
当然,仅仅因为这些都是缺省值,以后对于单个路径仍然可以有更明确的规则,而不必禁用默认的内容项。
https://stackoverflow.com/questions/46983930
复制相似问题