Web部署项目AfterBuild [英] web deployment project AfterBuild

查看:45
本文介绍了Web部署项目AfterBuild的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Web部署项目中,我想加密连接字符串。

我用这样的批处理文件来做这件事。


aspnet_regiis.exe -pef" connectionStrings" .. \ -prov" HrCustomProvider"

我知道我需要使用

< Exec Command =''aspnet_regiis.exe -pef"的ConnectionStrings" .. \ -prov

" HrCustomProvider"''/>


但我无法让它工作。

我不想硬编码aspnet_regi的路径来改变这种情况。

我不知道web.config的相对路径在哪里运行。

解决方案

你好Chuck,


见那里 http://msdn2.microsoft.com/en-us/library/ms998280.aspx


---

WBR,Michael Nemtsev [C#MVP]。

我的博客: http://spaces.live.com/laflour

团队博客: http://devkids.blogspot.com/


对我们大多数人来说,最大的危险并不是我们的目标太高而且我们错过了b $ b它太低了我们达到了它 (c)米开朗基罗


CP在一个Web部署项目中我想加密连接

CPstrings。我用一个批处理文件来做这个,比如

CP这个。

CP>

CPaspnet_regiis.exe -pef" connectionStrings" .. \ -prov

CP" HrCustomProvider"

CP>

CPI知道我需要使用

CP< Exec Command =''aspnet_regiis.exe -pef" connectionStrings" .. $ \\

CP-prov

CP" HrCustomProvider"''/>

CP但我无法让它工作。

CP>

CPI不想硬编码aspnet_regi的路径来支持这个

CPchanges。我不知道web.config的相对路径在什么时候

CP这个运行。

CP>


< blockquote>我可能并不清楚。


这就是我现在这样做的方式。

我想改变的是放那些命令进入Web部署

项目并实际完成它们。

我知道我需要编辑WDP项目文件并添加如下内容:

在Web部署项目中,我想加密连接字符串。

我用这样的批处理文件来执行此操作。

< Exec Command = ''aspnet_regiis.exe -pef" connectionStrings" .. \ -prov

" HrCustomProvider"''/>


但我无法让它工作。

如果这种情况发生变化,我不想硬编码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/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

CPIn a web deployment project I want to encrypt the connection
CPstrings. I use to do this with a batch file with something like
CPthis.
CP>
CPaspnet_regiis.exe -pef "connectionStrings" ..\ -prov
CP"HrCustomProvider"
CP>
CPI know I need to use
CP<Exec Command=''aspnet_regiis.exe -pef "connectionStrings" ..\
CP-prov
CP"HrCustomProvider"'' />
CPbut I cant get it to work.
CP>
CPI don''t want to hard code the path to aspnet_regiis incase this
CPchanges. I don''t know where the relative path to web.config when
CPthis 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 Deployment
Project 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 project
post-build event problem, I think it is caused by the path of the
aspnet_regiis.exe tool and the path of the precompile application(its
application root dir).

For the aspnet_regiis.exe, unless you''re executing it in a command promtp
that has already add the framework path into environment variables, you
need to use the full qualified path .e.g.

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspn et_regiis.exe

If you want to add flexibility, you can add a custom property in your build
xml 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆