在发布时替换asp.net core中的web.config vs 2017

编程入门 行业动态 更新时间:2024-10-26 15:21:02
本文介绍了在发布时替换asp core中的web.config vs 2017的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正尝试用生产版本替换web.config。

i'm trying to replace the web.config with the production version.

我在〜\production\中具有生产版本\web.config (以tilda作为我的项目文件夹的根)。

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

我在迁移文档中找到了这个

I found this in the 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 the file both will copy to the publish directory. it's a combination of mapping and publish and unfortunately the documentation is suffering from lack of example, so i tried to guess/figure it out by combining the mapping example with the publish.

首先我尝试了此方法:

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

所以我期望在中看到

so i was expecting to see a in folder in the publish directory but didn't.

我尝试过

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

但效果不佳。

您可以找到迁移文档

推荐答案

不确定这是否是最正确的方法,但是您可以使用直接复制任务:

Not sure if this is the most right way, but you may achieve this using Copy task directly:

<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 不能被替换
    • AfterTargets="GeneratePublishRuntimeConfigurationFile" as we want to do replacement only after default web.config will be generated in publish folder
    • OverwriteReadOnlyFiles="true" - without this web.config cannnot be replaced

更多推荐

在发布时替换asp.net core中的web.config vs 2017

本文发布于:2023-11-15 22:07:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1598379.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:core   net   asp   config   web

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!