0

I have an ASP.NET Core application that I'm attempting to perform web deploy to a server and no matter what build configuration I select in the profile wizard, it always deploys multiple appsettings files as well as the PDB files for the DLLs. Anyone know what could be causing this?

Set
  • 47,577
  • 22
  • 132
  • 150
clockwiseq
  • 4,189
  • 9
  • 38
  • 61
  • I haven't tried this just yet, but I found this question and it seems like it's what I'm looking for: https://stackoverflow.com/questions/46364293/automatically-set-appsettings-json-for-dev-and-release-environments-in-asp-net-c – clockwiseq Mar 07 '18 at 16:34
  • Now I've discovered that part of the configuration is the launchSettings.json file that I've never seen. Now I'm researching that to see if I can configure each environment. – clockwiseq Mar 07 '18 at 16:43

1 Answers1

2

If you want to exclude .pdb files for release publishing, then you may disable their generation during release build by adding next property to .csproj file (found this here)

<PropertyGroup>
  <DebugType Condition=" '$(Configuration)' == 'Release' ">None</DebugType>
</PropertyGroup>

Regarding any configuration (or not) file, it will be published based on CopyToPublishDirectory attribute value. So again, you may use Condition attribute and have something like this (just an idea):

<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
   <Content Update="appsettings.debug.json" CopyToPublishDirectory="Always"/>
   <Content Update="appsettings.release.json" CopyToPublishDirectory="Never"/>
</ItemGroup>

<ItemGroup Condition=" '$(Configuration)' == 'Release' ">
   <Content Update="appsettings.debug.json" CopyToPublishDirectory="Never"/>
   <Content Update="appsettings.release.json" CopyToPublishDirectory="Always"/>
</ItemGroup>

But in general, it's better to depend on environment setting (Dev, Prod) when we are talking about configs.

Set
  • 47,577
  • 22
  • 132
  • 150