Search code examples
asp.net-corevisual-studio-codenlog

Visual Studio Code does not copy nlog.config


How can I include file as resource output from Visual Studio Code? I want nlog.config to be copied to the output directory.

This is ASP.NET Core Web API project.

In VS 2017 this would be: "Build Action: Content" option in the properties menu.


Solution

  • I had to manually edit project and add nlog settings.

    In VS 2017 this can be done through the UI: - "Build Action: Content" option in the properties menu of the nlog.config.

    Final version of the project in VS Code:

      <PropertyGroup>
        <TargetFramework>netcoreapp2.0</TargetFramework>
        <EnableDefaultContentItems>false</EnableDefaultContentItems> //added
      </PropertyGroup>
    
      //commented
      <!-- <ItemGroup>
        <Folder Include="wwwroot\" />
      </ItemGroup> -->
    
      //added
      <ItemGroup>
        <Content Include="nlog.config">
          <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </Content>
      </ItemGroup>