我正在为 C# 创建自己的项目模板,其中包含更多项目。
我在其中添加了我自己的向导。这很好用。
但是,当我尝试将我的一些项目自定义参数放入替换字典中时,在我的向导库中,我在我的项目中获得了原始值(未替换)(它保持为 "$connectionString$")。
例如,如果我在RunStarted方法中添加这段代码:
private string _connectionString = "Lorem ipsum for example";
public void RunStarted(object automationObject, Dictionary<string, string>replacementsDictionary, WizardRunKind runKind, object[] customParams)
{
replacementsDictionary.Add("$connectionString$", _connectionString);
}
在我的 web.config 中:
<connectionStrings>
<add name="DAL.Database.Properties.Settings.MyConnectionString" connectionString="$connectionString$" providerName="System.Data.SqlClient" />
</connectionStrings>
即使在我的.vstemplate文件中,我也看到这个文件被标记为检查和修改参数:
<ProjectItem ReplaceParameters="true" OpenInEditor="true" TargetFileName="Web.config">Web.config</ProjectItem>
注意:仅当我将硬编码值放入.vstemplate文件中时才有效,例如:
<CustomParameters>
<CustomParameter Name="$connectionString$" Value="Some dummy value" />
</CustomParameters>
但这不是我想要的。现在我想知道,可能是什么问题?