且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何部署ASP.NET网站当你处理连接字符串?

更新时间:2023-02-17 09:25:19

使用一个 Web部署项目并更新wdproj文件(这只是一个MSBuild文件)与一些后生成任务输出正确的config文件。我把一个web.config和web.release.config然后在wdproj文件中使用这样的:

Use a Web Deployment Project and update the wdproj file (it's just an MSBuild file) with some post build tasks to output the correct .config file. I keep a web.config and web.release.config then use this in the wdproj file:

<Target Name="AfterBuild">
    <Copy Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " SourceFiles="$(SourceWebPhysicalPath)\web.release.config" DestinationFiles="$(OutputPath)\web.config" />
    <Delete Files="$(OutputPath)\web.release.config" />
</Target>

更多信息

有一个简单的解决方案有的喜欢用的appSettings和是connectionStrings的configSource属性,然后再从不覆盖生产服务器上的文件。

A simpler solution some like is using configSource property of appSettings and connectionStrings and then never overwriting that file on the production server.