dotnet publish doesn´t publish correct appsettings.{env.EnvironmentName}.json

后端 未结 5 1497
难免孤独
难免孤独 2020-11-29 03:27

When I issue the following command in the command line:

dotnet publish -o \"./../output\" -c Release

The dotnetcli publishes the pr

5条回答
  •  -上瘾入骨i
    2020-11-29 03:37

    For the new csproj project format you have to add a new ItemGroup with the content

    
      
        PreserveNewest
      
      
        PreserveNewest
      
    
    

    In case you have multiple appsettings.{env}.json files simply repeat the Content tag inside the same ItemGroup and all your settings files will end up in the publish folder.

    As mentioned in the comments an even cleaner solution is to use a wildcard include:

    
      
        PreserveNewest
      
    
    

    And all your appsettings files will be published!

提交回复
热议问题