Include a Folder in ClickOnce Application

前端 未结 5 769
萌比男神i
萌比男神i 2021-02-04 08:11

I\'ve created a Windows C# project and made it as ClickOnce Application(Publish feature in Project properties) for Installation. I want to Include a folder<

相关标签:
5条回答
  • 2021-02-04 08:57

    You have to add the items to the project and mark them as 'Content' (select the item in solution explorer, right click, properties, set Build Action).

    0 讨论(0)
  • 2021-02-04 09:06

    Let's say that we have two projects: main - ProjectA and some other ProjectB referencing to ProjectA. In ProjectB we have a folder FolderB with some files that should be included in publish (pdf, rpt, etc.) of ProjectA.

    Once we build ProjectA there will be all referenced files and folders in bin directory. But when we publish solution using ClickOnce tool, folders from referenced ProjectB won't be included in the installer and you won't see them in Application Files window in project publish settings.

    The solution for this is to create a new folder called FolderB in ProjectA and add existing items form FolderB in ProjectB to this new folder in ProjectA using Add As Link option. Then all files, including files linked to ProjectB folders, will be included in publish.

    0 讨论(0)
  • 2021-02-04 09:10

    It's been a long time since the OP, but when I add a folder to my solution, add a Crystal Report to that folder and mark it as "Content" (per Tom), then Publish and install - the folder and report gets added to the ClickOnce installation location. So Tom's solution worked for me.

    0 讨论(0)
  • 2021-02-04 09:13

    So Tom has explained how to add a file. You specifically say you would like to add a folder to your ClickOnce application once you publish it. Lets assume you have a folder sitting in the root of your solution named Dependencies which contains a folder Reports which contains all of your RPT files. Here is how you would make sure your deployed app contains all of the contents of the Dependencies folder:

    1. Right click your project in Visual Studio and select "unload project".

    2. Right click and select to edit the csproj file.

    3. Before the closing </Project> tag add this:

      <ItemGroup>
      <Content Include="$(SolutionDir)Dependencies\**\*">
      <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
      <Visible>false</Visible>
      </Content>
      </ItemGroup>

    4. That will add everything from the Dependencies folder into the project. We are using the \**\* syntax at the end of the Include and %(RecursiveDir) to ensure the Reports folder will be present in the published version as well as the report files. Having set <Visible>false</Visible> you won't see the items cluttering up the solution explorer.

    0 讨论(0)
  • 2021-02-04 09:14

    Barrie has the best solution, really solves all I needed! No need to include same files in multiple projects, just setup pre-build event that copies files in debug for local functionality and debugging. Solves my problem with rdlc (reports) having in one location and using them in multiple projects.

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