简体   繁体   中英

Publish Web Application with Multiple Projects

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?

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 .

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM