如果这种情况发生变化,我不想硬编码aspnet_regiis的路径。 我不知道web.config的相对路径在哪里运行。 Hello Chuck, 至于通过Web部署项目加密web.config部分 构建后事件问题,我认为它是由 aspnet_regiis.exe工具的路径和预编译应用程序的路径引起的(它的 应用程序root目录。 对于aspnet_regiis.exe,除非你在命令promtp 中执行它,它已经将框架路径添加到环境中变量,你 需要使用完整的限定路径。例如, C:\ WINDOWS \ MicrosoftMosrosoft.NET \ Framework \v2.0.50727 \ aspn et_regiis.exe 如果是你想增加灵活性,你可以在你的构建 xml文件中添加一个自定义属性,并使用该属性来设置框架目录,例如 == ================== < Project DefaultTargets =" Build" xmlns =" http:/ /schemas.microsoft.com/developer/msbuild/2003"> < PropertyGroup> < netfxdir>%windir%\ Microsoftoft.NET\Framework \v2.0.50 727 \< / netfxdir> ................... < Exec WorkingDirectory =" In a web deployment project I want to encrypt the connection strings.I use to do this with a batch file with something like this.aspnet_regiis.exe -pef "connectionStrings" ..\ -prov "HrCustomProvider"I know I need to use<Exec Command=''aspnet_regiis.exe -pef "connectionStrings" ..\ -prov"HrCustomProvider"'' />but I cant get it to work.I don''t want to hard code the path to aspnet_regiis incase this changes.I don''t know where the relative path to web.config when this runs either. 解决方案 Hello Chuck,See there http://msdn2.microsoft.com/en-us/library/ms998280.aspx---WBR, Michael Nemtsev [C# MVP].My blog: http://spaces.live.com/laflourTeam blog: http://devkids.blogspot.com/"The greatest danger for most of us is not that our aim is too high and wemiss it, but that it is too low and we reach it" (c) MichelangeloCPIn a web deployment project I want to encrypt the connectionCPstrings. I use to do this with a batch file with something likeCPthis.CP>CPaspnet_regiis.exe -pef "connectionStrings" ..\ -provCP"HrCustomProvider"CP>CPI know I need to useCP<Exec Command=''aspnet_regiis.exe -pef "connectionStrings" ..\CP-provCP"HrCustomProvider"'' />CPbut I cant get it to work.CP>CPI don''t want to hard code the path to aspnet_regiis incase thisCPchanges. I don''t know where the relative path to web.config whenCPthis runs either.CP>I probably wasn''t clear.That''s the way I do it now.What I want to change is to put those commands in to a Web DeploymentProject and have them actually complete.I know I need to edit the WDP project file and add something like:In a web deployment project I want to encrypt the connection strings.I use to do this with a batch file with something like this.<Exec Command=''aspnet_regiis.exe -pef "connectionStrings" ..\ -prov"HrCustomProvider"'' />but I cant get it to work.I don''t want to hard code the path to aspnet_regiis in case this changes.I don''t know where the relative path to web.config when this runs either. Hello Chuck,As for the encrypting web.config section through web deployment projectpost-build event problem, I think it is caused by the path of theaspnet_regiis.exe tool and the path of the precompile application(itsapplication root dir).For the aspnet_regiis.exe, unless you''re executing it in a command promtpthat has already add the framework path into environment variables, youneed to use the full qualified path .e.g.C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspn et_regiis.exeIf you want to add flexibility, you can add a custom property in your buildxml file and use that property to set the framework dir, e.g.====================<Project DefaultTargets="Build"xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><PropertyGroup><netfxdir>%windir%\Microsoft.NET\Framework\v2.0.50 727\</netfxdir>...................<Exec WorkingDirectory=" 这篇关于Web部署项目AfterBuild的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-11 05:40