467,925 Members | 2,024 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,925 developers. It's quick & easy.

web deployment project AfterBuild

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.

Feb 23 '07 #1
  • viewed: 2729
Share:
10 Replies
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>
Feb 23 '07 #2
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.

Feb 23 '07 #3
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="$(OutputPath)"
Command="$(netfxdir)aspnet_regiis.exe -pef connectionStrings ." />
.....................
============================

I use the "$(OutputPath)" variable to set the working directory so that I
can use "." to represent the physical path of the output precompiled
ASP.NET application. Based on my test, such path like "..\ ..." or
".\debug" will not work.

You can try the above configuration to see whether it work o your side.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 26 '07 #4
Thanks, Steven
That got it.
Feb 27 '07 #5
I wish their was a way to get the location of the compiler. I know something
installs an environment variable vs80comntools that contains the path to a
batch file to set environment variables.

When I compile with batch files, I do the following.
if "%VS80COMNTOOLS%"=="" goto error_no_VS80COMNTOOLS

rem set path of aspnet_compiler for the framework in vs80
call "%VS80COMNTOOLS%vsvars32.bat"

echo.
echo compling with Framework %FrameworkVersion%

Feb 27 '07 #6
Thanks for your reply Chuck,

Yes, it would be much better if the .net framework system folder has a
system environment variable point to it. So far there is only some
variables of path to visual studio tools (if the machine has visual studio
installed). Anyway, since the .net framework folder structure is always
fixed, you can use the %windir% to concatenate the other part so as to
construct the whole path.

Also, if you meet any other problem we can help, please feel free to post
here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 28 '07 #7
I don't really understand how the web deployment project addin interfaces
with msbuild.
When you build a web deployment project in VS how does it know what version
of the framework to pick and where the complier is?

Feb 28 '07 #8
Hi Chuck,

Thanks for your followup.

For your further question about how the web deployment project deal with
..net framework version. It is actually what Visual Studio do, web
deployment project do not to care about this. Each version of visual
studio only targets a fixed version of .net framework. For example, VS.NET
2002 target .net framework 1.0, VS.NET 2003 target .net framework 1.1
while Visual Studio 2005 only target .net framework 2.0 development.

therefore, the web deployment project will surely pickup .net framework 2.0
to compile.

Also, webdeployment project do not quite care whether it is invoked by
visual studio or MSBUILD. From underlying view, it only product a build
configuration file(xml format) which can be parsed by both visual studio
and MSBUILD.exe so that both of them can correctly perform the compiling
according to the setting in the web deployment project file(xml config).

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 1 '07 #9

Thanks Steven,
FYI,
I found a (reserved property) variable to the compiler

$(MSBuildBinPath)
Mar 8 '07 #10
Thanks for your followup and share your finding with us.

Have a nice day!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

Mar 9 '07 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by andrewbb | last post: by
2 posts views Thread by GaryDean | last post: by
3 posts views Thread by =?Utf-8?B?Q2h1Y2sgUA==?= | last post: by
1 post views Thread by shapper | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.