Web 配置被忽略

Web Config being ignored

我已经编写了一个 web-api 服务并使用慢速猎豹来进行转换。当我使用 visual studio 编译并发布到服务器时,一切都很好,所有内容都在许多不同的配置和许多不同的配置文件(connectionStrings.config 等以及 web.config)中进行了转换。

但是,当我使用 msbuild 构建时,情况并非如此。使用原版 web.config,没有任何改变。

我已经确保我 运行 是正确的 /p:Configuration 并且还尝试了 运行ning TransformAllFiles 具体目标但是结果文件再次没有考虑我的Web.UAT.config 文件。

我已经安装了 slow cheetah nuget package version 2.5.15 并且项目是用 visual studio 2015.

生成的

我想进行转换的原因是我可以用章鱼打包并部署到多个服务器。此刻我卡住了。

顺便说一句,如果我 运行 /t:TransformWebConfig 目标确实会转换文件,但我相信这不是 slowcheetah 功能,因此并不是真正需要的。

重现此问题的步骤

1) 创建一个web api 2个工程熊骨 2)添加慢速猎豹 3) 为 visual studio 2015 预览版安装 slow cheetah 插件 4) 为基于版本的 UAT 添加新配置。 5) 退出到命令行。

发出命令 msbuild /t:TransformAllFiles /p:Configuration=UAT .csproj.

请注意,在输出中您会看到类似于以下内容的内容:

> G:\dev\c#\TestCheetah\TestCheetah>msbuild /t:TransformAllFiles
> /p:Configuration=UAT TestCheetah.csproj Microsoft (R) Build Engine
> version 14.0.25123.0 Copyright (C) Microsoft Corporation. All rights
> reserved.
> 
> Build started 17/05/2016 19:32:44. The target "_ConvertPdbFiles"
> listed in a BeforeTargets attribute at "C:\Program Files
> (x86)\MSBuild.0\Microsoft.Com
> mon.targets\ImportAfter\Xamarin.Common.targets (34,37)" does not exist
> in the project, and will be ignored. The target "_CollectPdbFiles"
> listed in an AfterTargets attribute at "C:\Program Files
> (x86)\MSBuild.0\Microsoft.Com
> mon.targets\ImportAfter\Xamarin.Common.targets (34,70)" does not exist
> in the project, and will be ignored. The target "_CollectMdbFiles"
> listed in a BeforeTargets attribute at "C:\Program Files
> (x86)\MSBuild.0\Microsoft.Com
> mon.targets\ImportAfter\Xamarin.Common.targets (40,38)" does not exist
> in the project, and will be ignored. The target "_CopyMdbFiles" listed
> in an AfterTargets attribute at "C:\Program Files
> (x86)\MSBuild.0\Microsoft.Common
> .targets\ImportAfter\Xamarin.Common.targets (40,71)" does not exist in
> the project, and will be ignored. Project
> "G:\dev\c#\TestCheetah\TestCheetah\TestCheetah.csproj" on node 1
> (TransformAllFiles target(s)). TransformAllFiles:   Copying file from
> "Web.config" to "obj\UAT\TestCheetah.csproj-sc.App.config". Done
> Building Project
> "G:\dev\c#\TestCheetah\TestCheetah\TestCheetah.csproj"
> (TransformAllFiles target(s)).
> 
> 
> Build succeeded.
>     0 Warning(s)
>     0 Error(s)

请注意,它说它转换了 web.config 文件,但是当您查看时,您会发现调试值(唯一的转换)没有改变。

最后我想出了如何做到这一点。我意识到我可以简单地在 octopus 中的环境之后重命名我的配置,并将自定义转换包含在 Octopus 部署用户表单中。因此,我最初的方法是有缺陷的。我仍然使用慢速猎豹进行本地部署,效果很好,但我让章鱼执行部署实例的转换以测试、UAT 和生产。

看来我试图完成的初始任务目前无法通过慢速猎豹实现。