Showing posts with label config. Show all posts
Showing posts with label config. Show all posts

Friday, April 30, 2010

how to make web deployments with .net C# and VSTS 2010

visual studio 2010 introduce finally a solution for the paradigma of test / live config files. the solution is a config transformation per xsl.

Step 1:


Once you have executed this you get 2 web.config files:

- web.debug.config
- web.release.config

if you want you have also the ability to add additional config files as long as you support the naming convention: web.integration.config. The files area actually only contain the changes and are not copies of you main config files.

Step 2:
so here an example how to manage that:

<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/configuration/appSettings">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
<xsl:element name="add">
<xsl:attribute name="key">NewSetting</xsl:attribute>
<xsl:attribute name="value">New Setting Value</xsl:attribute>
</xsl:element>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>


more infos and samples can be found here.

Wednesday, January 16, 2008

Text File does not get deployed from Class Library Project into Asp.NET Web Application

The issue sounds simple to me:

Text File does not get deployed from Class Library Project into Asp.NET Web Application

"We have a webproject and would like to deploy HTML and
Text Templates from a common Project into the web project
output folder.

The Attributes on the text / html files are set like this:
Build Action: Content
Copy to Output Directory: Copy Always
it just copy the files into the common csharp project under the bin/debug
but it doesn't appears within the web project.

any idea how to solve this issue without a lot of post build scripts?"

This have been posted 2 days ago I posted the following problem at:
http://forums.asp.net/t/1205184.aspx

To fix this issue you simply need to think in different direction - the oposite one :-)

Step 1: Don't add your files you would like to share in TFS (Team Foundation Server) into your Class Library Project - add files (html / xml / text / etc.) into your App_Data folder in your Asp.NET Web Application Project Type.
Step 2: Create your Folder within your Class Library Project you like to have the files. Once you have created the folder, you can right click on the folder and select : Add -> Existing Item

This will open you a dialog folder with a small HINT which is the BIG SHOOT for this issues. Don't simply add it while you press "Add" you need to select the small arrow near the Button and select "Add As Link" like the below printscreen shows:















Once you have done above steps, select your file and look at the file properties within your Visiual Studio. There you find some Attributes you need to check, you should check that the "Build Action:" is equal to "Content" and the "Copy to Output Directory:" is set to "Copy Always" or "Copy if newer".

In my case I do not need now to held the files redunded and sync them upon changes ....


just think different you will solve the problem!! was the motto upon this issue !

Wednesday, July 11, 2007

How To: update within app.config file a key

today I had the pleasure to write a Setup for my project indeXus.Net Shared Cache (available on Codeplex). While others will install this WinService on various Hosts I needed a way how I can take the administration effort from the user.

In my case I had to update an appSettings Key within various *.config files and backup them into an Application Data Folder.

The solution seems to be very easy after I found all tricks....

15 static string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase).Replace(@"file:\", "");
16 static string appPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\MergeSystem\backup";

(thanks here to atif) some more coding between....

70 ///


71 /// Evaluates the and update machine IP within all Config files
72 ///

73 private static void EvaluateAndUpdateMachineIP()
74 {
75 IPHostEntry localMachineInfo = Dns.GetHostEntry(Dns.GetHostName());
76 DirectoryInfo dir = new DirectoryInfo(path);
77 foreach (FileInfo fi in dir.GetFiles("*.config"))
78 {
79 ExeConfigurationFileMap map = new ExeConfigurationFileMap();
80 map.ExeConfigFilename = fi.Name;
81
82 //Configuration config = ConfigurationManager.OpenExeConfiguration(fi.FullName);
83 Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
84 if(config.AppSettings != null && config.AppSettings.Settings != null)
85 {
86 if(config.AppSettings.Settings[WinServiceCommon.Constants.ConfigServiceCacheIpAddress] != null)
87 {
88 config.AppSettings.Settings[WinServiceCommon.Constants.ConfigServiceCacheIpAddress].Value = localMachineInfo.AddressList[0].ToString();
89 config.Save(ConfigurationSaveMode.Modified);
90 ConfigurationManager.RefreshSection("appSettings");
91 }
92 }
93 }
94 }

Saturday, March 10, 2007

How To: Implement your email sending with the asp:PasswordRecovery control

after a while i finally figured out what i have missed to prevent emails to sent twice - once over the control and once over my own logic.

Markup:

<asp:PasswordRecovery
ID="PasswordRecovery"
runat="server"
OnSendingMail="PasswordRecovery_SendingMail"


Code Behind:

protected void PasswordRecovery_SendingMail(object sender, MailMessageEventArgs e)
{
e.Cancel = true;
e.Message.Dispose();

.. here my own logic starts.
}

in the web.config file you need minimum the following configuration:

<system.net>
 <mailsettings>
  <smtp from="your email address">
 </mailsettings>
 </system.net>
</configuration>

.. evoila.. that's all - happy email sending.

Monday, February 26, 2007

How To: Read Profile outside of ASP.NET

first of all thanks to daniel larson with his blog entry :-)

in case you're using your own classes and not just properties then here a small overview what you need to do:


namespace YourNameSpace.Profile.Extension
{
///


/// UserAddress contains the users address information,
/// this class is used in the profile .net 2.0 approach
///

[Serializable]
public class UserAddress
{
public UserAddress() { }

#region Property: Street
private string street;

///
/// Gets/sets the Street
///

public string Street
{
[System.Diagnostics.DebuggerStepThrough]
get { return this.street; }

[System.Diagnostics.DebuggerStepThrough]
set { this.street = value; }
}
#endregion


... all you other stuff ....

the web.config looks like this:


<profile>
<properties>
<add name="UserAddress" type="YourNameSpace.Profile.Extension.UserAddress" serializeAs="Xml"/>

and finally in your code you run the following code lines:

ProfileBase profile = ProfileBase.Create(data.Login);

string street = (profile.GetPropertyValue("UserAddress") as Profile.UserAddress).Street;

Wednesday, October 26, 2005

Login Control :: Password Recovery :: How-To send emails

that the emails issues are working fine, you will need to adapt the web.config with the following element:

≶blockquote>≶strong>≶system.net>
≶mailsettings>
≶smtp deliverymethod="Network">
≶network host="smtp.xyz.com" from="roni.schuetz@hotmail.com">
≶/smtp>
≶/mailsettings>
≶/SYSTEM.NET>≶/strong>≶/blockquote>

Shared Cache - .Net Caching made easy

All information about Shared Cache is available here: http://www.sharedcache.com/. Its free and easy to use, we provide all sources at codeplex.

Facebook Badge