Skip to main content

technical blog

Go Search
Home
Technical Blog
Resumé
Travel
Skydiving
Contact
  
Random Image

chrishines.com > technical blog > Categories
Setup Project, Setting files as "Content Files"

I am currently working on an installer using a Setup Project in Visual Studio. The project does not really fit the mould when it comes to selecting the files I want to output as it’s a kind of "overlay" for the customisation of SharePoint.

The files in my overlay are largely .aspx, .htm, .css, and .js however I do have some other types such as .xls, .dwp and .stp. These other types posed more of a problem to lay down in my setup project because they are not automatically considered to be "Content Files" (or "Source" etc). I could have selected the files individually but this would have been both boring and difficult to maintain.

A better solution I found was to set the Build Action property of the files in the original project to be "Content". The when I include the "Content Files" in my setup project it will include them.

Custom Actions for a Visual Studio Setup Project
I have recently been writing a moderately complex installer using Visual Studio’s Setup Project. Something which tripped me up for more than five minutes was how to pass a file path to a Custom Action Install method using the CustomActionData property. I setup a User Interface stage with a Textbox to capture the file path. I then gave the Textbox a property name DIR.
In my CustomActionData property I was then hoping to refer to pass DIR to my Install method using the syntax:

/dir="[DIR]\"

(You see I read the documentation! click here for documentation)

However, when I came to run the MSI it fell over at my Custom Action stage reporting a System.IO.FileNotFoundException. This exception confused me no end because in my Install method I was doing some file manipulation so I thought it must be my code which was failing. This turned out to not be the case it was actually the CustomActionData property which was at fault. It transpires that I needed a double backslash at the end of my value:

/dir="[DIR]\\"

Hope this article helps you if you are stuck with the same problem. When I write these technical tips I try to include as many relevant keywords as possible to as to ensure the best chance of being indexed for a relevant search. I used to work in online marketing and have an intellectual interest in SEO. I’d be interested to hear from you if you found this article solved your problem.