在 appsettings 或 connectionstring 之外替换 web.config 中的变量

Substitute Variables in web.config outside of appsettings, or connectionstring

我的 nupkg 文件中的 web.config 输出如下:

<host>
          <baseAddresses>
            <add baseAddress="#{Url.AccountService}"/>
          </baseAddresses>
        </host>

根据 Octopus 在 Substitute variables in files 上的文档,只要我在我的项目中定义了变量,上面的语法应该没问题。哪个,我知道。

此时我也仅将此包部署到 DEV 环境。

此外,在 Deploy Website 步骤中,在 Substitute Variables in Files > 我已将 web.config 添加到要执行替换的文件列表中。

但是,当部署完成时,octopus 不会将此变量替换为预期值。我做错了什么?

根据我们上面的对话和您尝试过的事情。 这是我唯一剩下的想法来回答你:

文档 Substitute Variables in Files 指出:

You need to state the full path of the file, relative to the installation directory. So, if you need to replace variables on a file called app.config that is inside of a configfolder on the root of your package, you need to put config\app.configon the Target files field.

Octopus Deploy 可能无法找到您声明需要变量替换的文件。关于您的示例和代码的其他所有内容看起来都是正确的。