【问题标题】:Web Config being ignoredWeb 配置被忽略
【发布时间】:2016-09-13 18:32:57
【问题描述】:

我编写了一个 web-api 服务并使用慢 cheetah 进行转换。当我使用 Visual Studio 编译并发布到服务器时,一切都很好,一切都在许多不同的配置和许多不同的配置文件(connectionStrings.config 等以及 web.config)中进行了转换。

但是,当我使用 msbuild 构建时,情况并非如此。使用了原版 web.config,没有进行任何转换。

我已确定我正在使用正确的 /p:Configuration 运行,并且还尝试专门运行 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 预览版安装慢速猎豹插件 4) 为 UAT 添加基于 release 的新配置。 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\14.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\14.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\14.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\14.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 文件,但是当您查看时,您会注意到调试值(唯一的转换)没有改变。

【问题讨论】:

    标签: visual-studio-2015 msbuild slowcheetah


    【解决方案1】:

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

    目前看来,我试图完成的初始任务对于缓慢的猎豹是不可能的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-06
      • 1970-01-01
      • 2019-09-11
      • 1970-01-01
      相关资源
      最近更新 更多