Elton Stoneman

  Home  |   Contact  |   Syndication    |   Login
  120 Posts | 0 Stories | 3607 Comments | 0 Trackbacks

News

Archives

Post Categories

[Source: http://geekswithblogs.net/EltonStoneman]

One of the frustrations of working with WiX is that when you want to do something out of the ordinary, chances are it's provided somewhere in a WiX extension, but unless you trawl through the XSDs you're not likely to find it. I had this issue when I wanted to resolve the special folder My Music through WiX, so I could put the full path into a config file.

Various special folders are already available as properties to the installer, including My Documents and My Pictures, but not My Music. Adding an extension to expose Environment.GetSpecialFolder() to WiX is a trivial implementation in a couple of classes (comments omitted for brevity):

public class EnvironmentExtension : WiXExtension

{

private EnvironmentPreprocessorExtension preprocessorExtension;

 

public override PreprocessorExtension PreprocessorExtension

{

get

{

if (this.preprocessorExtension == null)

{

this.preprocessorExtension = new EnvironmentPreprocessorExtension();

}

return this.preprocessorExtension;

 

}

}

}

public class EnvironmentPreprocessorExtension : PreprocessorExtension

{

private const string SPECIALFOLDER = "specialFolder";

public override string[] Prefixes { get { return new string[] { SPECIALFOLDER }; } }

 

private List<string> _specialFolders;

private List<string> SpecialFolders

{

get

{

if (_specialFolders == null)

{

_specialFolders = new List<string>(Enum.GetNames(typeof(Environment.SpecialFolder)));

}

return _specialFolders;

}

}

 

public override string GetVariableValue(string prefix, string name)

{

string result = null;

if (prefix == SPECIALFOLDER && SpecialFolders.Contains(name))

{

Environment.SpecialFolder specialFolder = (Environment.SpecialFolder)Enum.Parse(typeof(Environment.SpecialFolder), name, true);

result = Environment.GetFolderPath(specialFolder);

}

return result;

}

}

Reference the folder you want from the Environment.SpecialFolders enum as a property in your WiX script:

<Property Id="MUSICPATH" Value="$(specialFolder.MyMusic)"/>

- and add the extension assembly to your light and candle calls, making sure the DLL is available at runtime :

candle -out x.y.z.WiXobj x.y.z.wxs -ext EnvironmentExtension

light -out x.y.z.msi x.y.z.WiXobj -ext EnvironmentExtension -cultures:en-us

 

But I suspect it's already available somewhere in WiX.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted on Tuesday, September 29, 2009 1:09 PM

Feedback

# re: Resolving Special Folders in WiX 3.0 5/31/2010 5:00 AM dormire a lucca
These are nice coding. These code helps a lot. Keep sharing such type of informative post.

# re: Resolving Special Folders in WiX 3.0 10/26/2010 4:39 AM firewall network security
New tool, Heat, that generates .wxs source files based on a file, directory, or website along with improved COM object registration capture are some of good point in wix 3.0

# re: Resolving Special Folders in WiX 3.0 11/22/2010 9:27 AM taxi privato Fiumicino
This is an updated release of WiX v3. It is recommended that we use WiX v2 for our personal product development.


# re: Resolving Special Folders in WiX 3.0 5/13/2011 11:58 PM celebrity news today
great info just what was needed

# re: Resolving Special Folders in WiX 3.0 6/5/2011 12:34 AM London Escorts
Thanx for the post, when our group gets bigger, we will come back to see if you have any more interesting follow up topics to link to from your new blog site ;-) Indian London escorts

# re: Resolving Special Folders in WiX 3.0 6/14/2011 8:21 PM car title loan
Quite possibly the most succinct and current info I came across about this subject. Sure pleased that I discovered that site by accident. I’ll probably be subscribing for your feed so that I will get the most current updates. Like the information here.

# re: Resolving Special Folders in WiX 3.0 6/14/2011 8:22 PM rim financing
This site is very interesting and also great. I'm glad to find out this ste immediately. It's very informative.

# re: Resolving Special Folders in WiX 3.0 6/22/2011 10:18 AM acai berry diet
Hello, I love reading through your post, I wanted to leave a little comment to support you and wish you a good continuation. Wishing you the best of luck for all your efforts.

# re: Resolving Special Folders in WiX 3.0 6/25/2011 8:03 AM ischgl
Its a great pleasure reading your post. Its full of information I am looking for and I love to post a comment that "The content of your post is awesome" Great work .

# re: Resolving Special Folders in WiX 3.0 6/28/2011 4:53 AM Civil War Spies
I recently came accross your blog and have been reading along. I thought I would leave my first comment. I dont know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: