6

I customized my project using a solution I found in this question:

Why doesn't ClickOnce in Visual Studio deploy content files from dependent assemblies?

<ItemGroup>
<AdditionalPublishFile Include="$(OutputPath)\**\*.rpt">
  <Visible>False</Visible>
</AdditionalPublishFile>
</ItemGroup>
<Target Name="BeforePublish">
  <Touch Files="@(IntermediateAssembly)" />
  <CreateItem Include="@(AdditionalPublishFile)" AdditionalMetadata="TargetPath=%(RecursiveDir)%(Filename)%(extension);IsDataFile=false">
    <Output TaskParameter="Include" ItemName="_DeploymentManifestFiles" />
  </CreateItem>
</Target>

it was working fine with VS 2010, until I upgraded to VS 2012,the additional files were not included in the application manifest !! so when the user install the application, the files mentioned were missing from the application main folder.

what has changed in VS 2012? or maybe the changes are in MSBuild?

EDIT:

I mentioned the original question where from I got the idea, basically I'm using Dependency Injection to load some assemblies, which means there is no hard reference between my project and the assemblies, so the click-once deploy will not take into consideration those assemblies, which force me either to add them to the project, or to use the mentioned solution, I chose the mentioned solution as it is invisible and easy.

but it was broken after migrating to VS 2012.

Community
  • 1
  • 1
Nour
  • 5,252
  • 3
  • 41
  • 66

2 Answers2

1

I found your question baffling because I've never seen anybody do this with ClickOnce before, so I talked to the ClickOnce guy at Microsoft about it. He said that what you are doing it not supported, so it's not something they would have tested for. There are multiple changes to msbuild that could have broken what you are doing.

Is what you are trying to do is get files associated with a secondary reference included in the deployment? In other words, you have a main project that references another assembly that is created by building a second project, and the second assembly has content files, and you want them included in your project?

If that's what you are trying to do, you should consider linking those files to the main project instead. To do that, you can add an existing item as a link, and point it to the content in the second project. Then the content will be included when you build the first project.

RobinDotNet
  • 11,723
  • 3
  • 30
  • 33
  • Thank you Robin, I thought no one will notice this question :), I edited my question to add more details, However, I didn't try to link the assemblies as you suggested, but I feel like it is similar to adding the assemblies directly to the project (not referencing them). – Nour Mar 06 '13 at 05:00
  • It's not the same, because when you link to the assemblies, it will pick up the new version when you build them. If you copy them to the project and add references to them there, they don't get updated unless you update them. – RobinDotNet Apr 07 '13 at 00:59
  • 2
    Seems like ClickOnce and VS should be symmetrical in recognizing the content files from the second assembly. – tofutim Jan 16 '14 at 05:55
  • 2
    I'm going to come out and say that the ClickOnce team is really screwing the pooch in this regard. There are plenty of scenarios where you need to include files in a referenced project. Why should I need to go through and link files from all my dependencies? I'd love to hear an explanation for this absolutely hair tearing inefficiency in the design. – SomeInternetGuy Feb 02 '16 at 17:46
1

Move the CreateItem task to the BeforeBuild step and remove the Touch task:

<ItemGroup>
  <AdditionalPublishFile Include="$(OutputPath)\**\*.rpt">
    <Visible>False</Visible>
  </AdditionalPublishFile>
</ItemGroup>
<Target Name="BeforeBuild">
  <CreateItem Include="@(AdditionalPublishFile)" AdditionalMetadata="TargetPath=%(RecursiveDir)%(Filename)%(extension);IsDataFile=false">
    <Output TaskParameter="Include" ItemName="_DeploymentManifestFiles" />
  </CreateItem>
</Target>
Ben Arroyo
  • 351
  • 2
  • 10