Visual Studio Setup Project with all files from a folder

前端 未结 10 579
陌清茗
陌清茗 2021-01-13 17:27

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

相关标签:
10条回答
  • 2021-01-13 17:43

    OH no you can drag and drop files and folders to setup directory in vs

    0 讨论(0)
  • 2021-01-13 17:44

    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.

    0 讨论(0)
  • 2021-01-13 17:44

    You can right click on the folder in explorer and click copy and then right click the folder in the file system view in the setup project and click paste. Dragging and dropping did not work for me.

    0 讨论(0)
  • 2021-01-13 17:54

    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.

    0 讨论(0)
提交回复
热议问题