2017-10-27 9 views
0

私はasp.netコア1.1アプリを持っています。<EnableDefaultContentItems>はどのコンテンツアイテムを有効にしますか?

それがエントリー

<EnableDefaultContentItems>false</EnableDefaultContentItems> 

を持っているため.csproj私はこのオンラインを検索すると、私は見つけることすべてが重複コンテンツのエラーについての質問です。 ここで有効になっている(またはむしろ有効になっていない)デフォルトアイテムは何ですか?そして、Microsoftはこれを文書化して、私が見て知っておくべきどこかに書いていますか?

答えて

1

これは新しいプロジェクト形式の一部です。特に、ASP.NETコアプロジェクトに使用されている新しいMicrosoft.NET.Sdk.WebプロジェクトSDKです。

デフォルトでは、EnableDefaultContentItemsset to trueです。その後、SDKのMSBuildのプロパティプロジェクトcontains the following

<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を手に入れることなくプロジェクトを迅速に実行できる共通のデフォルトです。

もちろん、これらがデフォルトであるため、デフォルトのコンテンツアイテムを無効にすることなく、後で個々のパスについてより明示的なルールを設定することができます。

関連する問題