web deployment project AfterBuild

G

Guest

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.
 
M

Michael Nemtsev

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

CP> In a web deployment project I want to encrypt the connection
CP> strings. I use to do this with a batch file with something like
CP> this.
CP>
CP> aspnet_regiis.exe -pef "connectionStrings" ..\ -prov
CP> "HrCustomProvider"
CP>
CP> I know I need to use
CP> <Exec Command='aspnet_regiis.exe -pef "connectionStrings" ..\
CP> -prov
CP> "HrCustomProvider"' />
CP> but I cant get it to work.
CP>
CP> I don't want to hard code the path to aspnet_regiis incase this
CP> changes. I don't know where the relative path to web.config when
CP> this runs either.
CP>
 
G

Guest

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.
 
S

Steven Cheng[MSFT]

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\aspnet_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.50727\</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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.

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



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

Guest

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%
 
S

Steven Cheng[MSFT]

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.
 
G

Guest

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?
 
S

Steven Cheng[MSFT]

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.
 
G

Guest

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

$(MSBuildBinPath)
 
S

Steven Cheng[MSFT]

Thanks for your followup and share your finding with us.

Have a nice day!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top