Replace web.config in asp.net core vs 2017 with publication

I am trying to replace web.config with a production version.

I have a production version in ~\production\web.config(tilda as the root of my project folder).

I found this in a migration document

<ItemGroup>

  <Content Include="Views\**\*" PackagePath="%(Identity)" />

  <None Include="notes.txt" CopyToOutputDirectory="Always" />
  <!-- CopyToOutputDirectory = { Always, PreserveNewest, Never } -->

  <None Include="publishnotes.txt" CopyToPublishDirectory="Always" />
  <!-- CopyToPublishDirectory = { Always, PreserveNewest, Never } -->
</ItemGroup>

I tried to use something like this

<ItemGroup>   
     <None Include="_production\web.config" CopyToPublishDirectory="Always" /> 
</ItemGroup>

but in this way the folder and file will be copied to the publication directory. it is a combination of mapping and publishing and, unfortunately, the documentation suffers from the lack of an example, so I tried to guess / understand it by combining the comparison example with the publication.

I tried this first:

<None Include="_production\web.config" CopyToPublishDirectory="Always"  PackagePath="in/web.test"/>

so I expected to see the folder inin the publication directory, but didn’t.

I tried

<None Include="_production\web.config" CopyToPublishDirectory="Always"  PublishPath="in/web.test"/>

but didn’t work.

you can find the migration document here

+4
1

, , , Copy:

<Target Name="CustomScript" AfterTargets="GeneratePublishRuntimeConfigurationFile">
    <Copy SourceFiles="_production\web.config" 
          DestinationFolder="$(PublishDir)" 
          OverwriteReadOnlyFiles="true"
          SkipUnchangedFiles="false" />
</Target>
  • AfterTargets="GeneratePublishRuntimeConfigurationFile", , web.config
  • OverwriteReadOnlyFiles="true" - web.config cannnot
+3

Source: https://habr.com/ru/post/1680046/


All Articles