ASP.NET Core: Exclude or include files on publish

前端 未结 9 800

There were before aspdotnet1.0 include/exclude sections on project.json file

{
  \"exclude\": [
    \"node_modules\",
    \"bower_c         


        
相关标签:
9条回答
  • 2020-11-27 05:22

    In my case I need local.settings.json locally during debug, but I do not want it included in my WebDeploy zip file during Release builds or Publish:

      <ItemGroup>
        <Content Include="..\local.settings.json" Link="local.settings.json" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
          <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </Content>
        <Content Include="..\local.settings.json" Link="local.settings.json" Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
          <CopyToOutputDirectory>Never</CopyToOutputDirectory>
        </Content>
      </ItemGroup>
    

    **

    0 讨论(0)
  • 2020-11-27 05:26

    After Visual Studio 2017 15.3

    Edit the .csproj file to manually exclude files/folder from being published

    <ItemGroup>
      <Content Remove="src\**" />
      <Content Remove="node_modules\**" />
    </ItemGroup>
    

    ref: https://www.danielcrabtree.com/blog/273/fixing-the-duplicate-content-error-after-upgrading-visual-studio-2017

    0 讨论(0)
  • 2020-11-27 05:27

    For Visual Studio 2019, I managed to exclued a wwwroot subfolder named "dummy" (including all subfolders of "dummy") from publish output using the following code:

    <ItemGroup>
      <Content Update="wwwroot\dummy\**\*">
        <CopyToPublishDirectory>Never</CopyToPublishDirectory>
      </Content>
    </ItemGroup>
    

    Note: The requirement was to keep the wwwroot and its subfolder(s) included in project but just exclude while publishing.

    0 讨论(0)
提交回复
热议问题