我遇到了同样的问题:
2>C:...\Microsoft.Web.Publishing.targets(4270,5): 错误:“db-Web.config 连接字符串”参数不能为空或为空。2>C:...\Microsoft.Web.Publishing.targets(4270,5):错误:“dbAudit-Web.config 连接字符串”参数不能为空或为空。2>C:...\Microsoft.Web.Publishing.targets(4270,5): 错误:“dbLog-Web.config 连接字符串”参数不能为空或为空。
正如我使用的那样:
<connectionStrings>
<add name="db" providerName="MySql.Data" connectionString="server=mysql.gko.local;user=maindk;database=gavekortet;port=3306;password=123456" />
<add name="dbLog" providerName="MySql.Data" connectionString="server=mysql.gko.local;user=maindk;database=logs;port=3306;password=123456" />
<add name="dbAudit" providerName="MySql.Data" connectionString="server=mysql.gko.local;user=maindk;database=audit;port=3306;password=123456;pooling=false" />
</connectionStrings>
当我在这里阅读时,问题与发布配置文件有关,然后我打开了.pubxml
文件,发现:
<ItemGroup>
<MSDeployParameterValue Include="$(DeployParameterPrefix)db-Web.config Connection String" />
<MSDeployParameterValue Include="$(DeployParameterPrefix)dbAudit-Web.config Connection String" />
<MSDeployParameterValue Include="$(DeployParameterPrefix)dbLog-Web.config Connection String" />
</ItemGroup>
添加<UpdateDestWebConfig>False</UpdateDestWebConfig>
到每个节点,所以它会变成:
<ItemGroup>
<MSDeployParameterValue Include="$(DeployParameterPrefix)db-Web.config Connection String">
<UpdateDestWebConfig>False</UpdateDestWebConfig>
</MSDeployParameterValue>
<MSDeployParameterValue Include="$(DeployParameterPrefix)dbAudit-Web.config Connection String">
<UpdateDestWebConfig>False</UpdateDestWebConfig>
</MSDeployParameterValue>
<MSDeployParameterValue Include="$(DeployParameterPrefix)dbLog-Web.config Connection String">
<UpdateDestWebConfig>False</UpdateDestWebConfig>
</MSDeployParameterValue>
</ItemGroup>
只需删除此条目,一切都恢复正常......