VS2010 web部署连接字符串参数不能为null或为空

MPD*_*MPD 27 iis-7 connection-string visual-studio-2010 visual-studio webdeploy

将网站部署到运行IIS7的Windows 2008 r2服务器时遇到问题.我之前已将另一个站点部署到此服务器.Web部署正在连接并将我的文件复制到服务器,但我看到以下错误.

1 The 'Connection String' argument cannot be null or empty
2   Web deployment task failed.((20/07/2012 14:19:16) An error occurred when the request was processed on the remote computer.)

(20/07/2012 14:19:16) An error occurred when the request was processed on the remote computer. Could not find a part of the path 'C:\Users\Me\Documents\Visual Studio 2010\Projects\MySite\MySiteClient\obj\Release\AutoScripts\EFDbContext-Deployment_SchemaOnly.sql'.     0   0   MySiteClient
Run Code Online (Sandbox Code Playgroud)

我已验证该路径存在于我的本地计算机上.

我尝试使用web.config转换发布,并使用xdt:transform函数设置远程服务器字符串.

我还在Package/Publish SQL选项卡中显式设置了目标和源数据库的连接字符串,但是我不知道问题是什么.

有任何想法吗?

Len*_*rri 44

这发生在我现在,我设法隔离问题... SQL Server在我手动添加一个新的连接字符串后,我Web.config开始遇到这个非常错误,当我尝试部署到远程服务器时.

当我在Visual Studio 2012中打开Web部署发布配置文件时,我在Settings选项卡下注意到它已设置此选项:在运行时使用此连接字符串(更新目标Web.config).

奇怪的是这是由VS 2012自动设置的......

要解决此问题,只需取消选中该复选框,然后再进行Web部署即可重新开始工作.

在此输入图像描述

  • 此外,如果上述步骤不起作用:删除发布配置文件,然后按照上面的步骤,这应该修复它.大家快乐编码! (4认同)

小智 15

除了Leniel的回答之外,如果您没有使用SqlClient或Entity Framework Code First而没有看到复选框,请暂时将web.config的连接字符串中的providerName设置为System.Data.SqlClient然后返回在您的发布设置中取消选中复选框.


bal*_*dre 12

我遇到了同样的问题:

2> C:...\Microsoft.Web.Publishing.targets(4270,5):错误:'db-Web.config连接字符串'参数不能为null或为空.2> C:...\Microsoft.Web.Publishing.targets(4270,5):错误:'dbAudit-Web.config连接字符串'参数不能为null或为空.2> C:...\Microsoft.Web.Publishing.targets(4270,5):错误:'dbLog-Web.config连接字符串'参数不能为null或为空.

因为我在使用:

<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>
Run Code Online (Sandbox Code Playgroud)

当我在这里看到问题是关于发布配置文件,然后我打开.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>
Run Code Online (Sandbox Code Playgroud)

添加<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>
Run Code Online (Sandbox Code Playgroud)

只需删除此条目,一切都在重新运作......