Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Setup Project with all files from a folder

We have a setup project that currently adds Project Output's from different visual studio projects. We want to change the packaging system and use a folder with a bunch of deploy files that are prepared for deployment in the setup.
But this means that we need to add the files one by one, and keep adding them on each version when there are new files.
I saw in this question that we can't add files with rules like *.aspx.
So I'm considering creating a small tool that will change the vdproj file based on the files available. Can you help me with the format of this file? It seems there are some GUIDs associated with each file included.
Does anyone have a better solution on how to do this?
We're not thinking about using a different setup tool right just yet, we just look for a simple solution for the file packaging.

like image 735
pauloya Avatar asked Apr 14 '09 16:04

pauloya


2 Answers

To add the entire folder, just open a windows explorer window, then drag all the files you want to add into the file system view.

like image 199
Geoffrey Avatar answered Sep 20 '22 04:09

Geoffrey


I finally found a real solution to this problem. What I needed is to add all files in a given external directory, (which is not part of the project), to the setup project in build time, i.e. if a file is added to that external directory, it will be included automatically in the installer with the next build.

What I did is I created a new project in the solution (Class Library project) and removed everything from it: Class1.cs, AssemblyInfo.cs, and the relevant ItemGroups of the csproj file containing <Compile> elements for the files above and the <Reference> elements for the includes.

Then, I added a new ItemGroup:

<ItemGroup>
  <Content Include="Path\To\The\Directory\**\*.*">
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  </Content>
</ItemGroup>

This way, this new project does not contain any files, but it referencing all the files (recursively, indicated by the \**\ from the indicated directory) as Content files.

So, upon build, these files are treated as Content files, therefore copied to the output directory of the new project.

So, why did I do all the above? Just because, Setup Project has an option to include the Content files from another project!

So, this way you can make arbitrary external files "part" of the solution without actually listing them, the list of the files is evaluated in build time, and then reference them from a Setup project.

like image 45
Peter Avatar answered Sep 24 '22 04:09

Peter