5

I have an ASP.NET web application that consists of multiple ASP.NET Projects (in addition to multiple class libraries). Obviously one of the projects is the root project while the rest are sub projects (the detailed concept of this application structure is explained here). Each of the sub/child projects has its own directory and they all sit in a directory I called "Modules" under the root folder. Since IIS can deal with one project per application, all child projects will be treated as regular directories (upon run). Therefore, I modified the build output path for each of the child projects to "..\..\bin\" which is the root bin folder. That way, I have everything set up correctly. From Visual Studio perspective, I have the luxury of having different projects under one solution. And from the IIS perspective I have one project with one bin folder and one Web.Config file. Now it comes to publish. If I publish the root project (by right clicking on the project node --> publish) the published output will be that project only with no "Modules" folder. The resulting bin folder will also miss the sub projects output dlls. And that's expected. So I thought that the obvious way to fix this is to publish all my web projects (not only the root), having in mind that my sub projects publish path needs to be the "Modules" folder within the root project's publish path. All that worked great except for one essential problem. It turned out that each of the published sub projects has its own bin folder and consequently the root bin folder does not contain the output DLLs of the sub projects. So I figured, while Visual Studio lets me specify the output path of each project the way I want (as I mentioned I set it to "..\..\bin\"), the ClickOnce publish does not respect that and simply creates a bin folder for every sub project. Is there a way to specify the output path (the bin folder) of the ClickOnce publish procedure? If not, what would be an alternative solution?

yazanpro
  • 4,512
  • 6
  • 44
  • 66

2 Answers2

1

As you said you have multiple projects and one is the root project. So every project should have its own bin folder because it is a project not a sub folder of root project.

If sub project would not have a bin folder how it would know from where to load assemblies which are used in that project.

It is not a bad idea to have bin folder for each sub project.

Mairaj Ahmad
  • 14,434
  • 2
  • 26
  • 40
  • From the link I included in the question. please check this part hopefully that'll make my case clearer. `After you configure the child projects to share a common IIS application root directory, you can share resources between projects in the solution. For example, you can drag a user control from a shared resources project into an .aspx file in another project. Note that you can only do this after you configure the projects to share a common IIS application root. Visual Studio .NET does not allow you to share resources if the projects are still in separate IIS application root directories.` – yazanpro Jan 20 '16 at 05:35
  • So from IIS perspective, I'll have only one project. And technically the child projects would load their assemblies from the root bin folder (I explicitly set the output path of all my child projects to `..\..\bin` which is the root bin folder. – yazanpro Jan 20 '16 at 05:43
1

The answer provided here may address your issue. By adding the following attributes to your .csproj file (modified from linked answer), you can inform ClickOnce to include additional content in the output directory:

<ItemGroup>
    <Content Include="bin\**\*.*" />
</ItemGroup>

Another answer given here provides a way to recursively include additional content into your project's output that is outside your project's folder, which may apply here; from the root project's perspective, the other project's are outside of it's folder. However, I'm not sure if ClickOnce will ignore this or not.

<Content Include="..\..\MyContentFiles\**">
    <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Community
  • 1
  • 1
Chase
  • 934
  • 6
  • 18
  • I haven't got a chance to test your solution yet but I believe it's helpful. I'll mark as answer if worked. Thanks, – yazanpro Jan 27 '16 at 16:32