none
dotnet publish ignores CopyToOutputDirectory option RRS feed

  • Question

  • I want to bundle only specific appsettings.Configuration.json file while building a project. In csproj file I added following lines:
    </ItemGroup>
        <ItemGroup Condition="'$(Configuration)' == 'Release'">
       <Content Update="appsettings.Development.json">
          <CopyToOutputDirectory>Never</CopyToOutputDirectory>
        </Content>
        <Content Update="appsettings.Debug.json">
          <CopyToOutputDirectory>Never</CopyToOutputDirectory>
        </Content>
        <Content Update="appsettings.Configuration1.json">
          <CopyToOutputDirectory>Never</CopyToOutputDirectory>
        </Content>
        <Content Update="appsettings.Configuration2.json">
          <CopyToOutputDirectory>Never</CopyToOutputDirectory>
        </Content>
       
        <Content Update="appsettings.Release.json">
          <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </Content>
        
      </ItemGroup>
    I was expecting to see only appsettings.Release.json in final artifact, but instead I see all files there. How can I fix this in MS pipeline process?
    Saturday, October 24, 2020 12:02 PM

Answers

  • Maybe you should change the “Build Action” property from “Content” to “None” (in Properties window for these files). The corresponding elements become <None> instead of <Content>.

    Saturday, October 24, 2020 12:24 PM

All replies

  • Maybe you should change the “Build Action” property from “Content” to “None” (in Properties window for these files). The corresponding elements become <None> instead of <Content>.

    Saturday, October 24, 2020 12:24 PM
  • This worked. Tnx.
    Saturday, October 24, 2020 1:56 PM
  • Hi,

    Your problem seems to be resolved, please click on the "Mark as answer" option of the reply that solved your question, so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, October 26, 2020 2:58 AM