tbr*_*naw 4 msbuild asp.net-core
我有一个 ASP.NET Core 1.1 应用程序。
它的 .csproj 有一个条目
<EnableDefaultContentItems>false</EnableDefaultContentItems>
Run Code Online (Sandbox Code Playgroud)
当我在网上搜索这个时,我发现的只是关于重复内容错误的问题。什么是被启用的默认项(或者更确切地说,未启用)在这里?而且,微软是否在我应该知道的地方记录了这个?
pok*_*oke 10
这是新项目格式的一部分,特别Microsoft.NET.Sdk.Web是用于 ASP.NET Core 项目的新项目 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>
Run Code Online (Sandbox Code Playgroud)
所以基本上,EnableDefaultContentItems使项目自动:
wwwroot/,任何web.config及所有.cshtml与.json文件。Properties/在发布时忽略文件夹因此,如果您正在使用该wwwroot文件夹并且没有更改其名称,那么建议保留默认值以避免必须在您的项目中手动指定所有这些异常。这些只是常见的默认值,可让您在不妨碍 MSBuild 的情况下快速运行项目。
当然,仅仅因为这些是默认值,您以后仍然可以为各个路径设置更明确的规则,而不必禁用默认内容项。
| 归档时间: |
|
| 查看次数: |
4189 次 |
| 最近记录: |