gpt4 book ai didi

c# - Visual Studio Online Build - web.config 连接字符串 configSource

转载 作者:太空宇宙 更新时间:2023-11-03 23:25:49 26 4
gpt4 key购买 nike

我的项目 Web.config 使用以下结构在单独的文件中定义了连接字符串:

<connectionStrings configSource="ConnectionStrings.config">
</connectionStrings>

这在协作项目或部署项目时非常方便。但是,我无法让 VSO Build 正常工作,因为它向我显示以下错误:

C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets (4105, 5) Could not copy the file "C:\a\1\s\MyProject\ConnectionStrings.config" because it was not found.

最佳答案

连接字符串必须已在 web.config 中定义,并且连接字符串名称必须与您在 Azure 中设置的连接字符串名称相同。然后 Azure 可以更新连接字符串。引用 Azure 的描述:

Connection strings work in a similar fashion, with a small additionalrequirement. Remember from earlier that there is a connection stringcalled “example-config_db” that has been associated with the website.If the website’s web.config file references the same connection stringin the configuration section, then Windows AzureWeb Sites will automatically update the connection string at runtimeusing the value shown in the portal.

However, if Windows Azure Web Sites cannot find a connection stringwith a matching name from the web.config, then the connection stringentered in the portal will only be available as an environmentvariable (as shown earlier).

Remember though that for Windows Azure Web Sites to override aconnection string and materialize it in the .NET Framework’sconnection string configuration collection, the connection string mustalready be defined in the web.config. For this example website, theweb.config has been updated as shown below:enter image description here

有关更多信息,请参阅此链接:https://azure.microsoft.com/en-us/blog/windows-azure-web-sites-how-application-strings-and-connection-strings-work/

关于c# - Visual Studio Online Build - web.config 连接字符串 configSource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33841535/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com