我无法让MS Build输出转换后的Web.Config
文件。我已经按照NuGet文档中的描述使用NuGet包还原设置了构建项目。除了转换之外,构建的每个部分(包还原、CI、web部署包)都可以工作。我已经尝试了基础设置和自定义项目文件以及许多其他选项,我没有得到任何地方。
我以前做过配置转换设置,没有问题。我已经安装了慢猎豹,可以预览我当前的转换,看到它的工作原理。当我通过MSBuild.exe
在本地运行构建时,转换实际上发生了:
TransformWebConfigCore:
Transforming Source File: G:MyProjectWeb.config
Applying Transform File: G:MyProjectWeb.Debug.config
Output File: objDebugTransformWebConfigtransformedWeb.config
Transformation succeeded
(如果我查看-v输出,我可以看到单个转换运行)
然后Web Deploy参数化我的web.config
:
Transformed Web.config using G:MyProjectWeb.Debug.config into objDebugTransformWebConfigtransformedWeb.config.
PipelineTransformPhase:
Publish Pipeline Transform Phase
PreAutoParameterizationWebConfigConnectionStrings:
Creating directory "G:MyProjectobjDebugCSAutoParameterizetransformedViews".
Copying objDebugTransformWebConfigtransformedWeb.config to objDebugCSAutoParameterizeoriginalWeb.config.
AutoParameterizationWebConfigConnectionStringsCore:
Transforming Source File: G:MyProjectViewsWeb.config
Applying Transform File: <?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add
connectionString="{% token='$(ReplacableToken_#(parameter)_#(tokennumber))' xpathlocator='name' parameter='$(name)-Web.config Connection String' description='$(name) Connection String used in web.config by the application to access the database.' defaultValue='$(connectionString)' tags='SqlConnectionString' %}"
xdt:Transform="SetTokenizedAttributes(connectionString)" xdt:SupressWarnings="True" />
</connectionStrings>
</configuration>
No element in the source document matches '/configuration/connectionStrings'
Not executing SetTokenizedAttributes (transform line 6, 15)
Output File: objDebugCSAutoParameterizetransformedViewsWeb.config
Transformation succeeded
PostAutoParameterizationWebConfigConnectionStrings:
Auto ConnectionString Transformed objDebugTransformWebConfigtransformedWeb.config into objDebugCSAutoParameterizetransformedWeb.config.
然后将参数化的文件移动到包中,并删除转换后的文件。复制obj 调试 CSAutoParameterize Web转换。配置到objDebugPackagePackageTmpWeb.config。删除文件"objDebugCSAutoParameterizetransformedWeb.config".
所以我有一个转换的web.config
文件,它不会在我的构建输出中结束。为什么转换发生,但没有被复制到输出目录或web部署包?
我在这里遇到了同样的问题。这是由Web部署模式造成的。它使用Web_Package
中的"project name".SetParameters.xml
来替换Deploy中的值。
因为你想使用SlowCheetah
,你需要绕过这个
您可以通过替换web中的connectionstrings设置来实现这一点。配置:
<connectionStrings configSource="connectionStrings.config">
</connectionStrings>
当然你需要connectionstring。配置文件。您可以手动创建它并将其放入原始的connectionStrings部分。该节点应该是文件中唯一的节点。
现在你可以在你的connectionStrings.config
文件上添加SlowCheetah
变换