How to Include the files which are not the part of web project in Nuget Package

Hi Support Team,

We are in the process of implementing Octopus deployment for one of our legacy asp.net web application.

The way it is deployed in IIS 7 is, we have a main website and under that we have different applications (individual functions/ components of the full business application). And each of these applications have its own app pool, bin, web.config. The main web site has a master .config file, as well as folders for styles, image, and script. The applications all share these folders under the main website. The individual website web.config file app settings is pointing to the master .config file under the main web site.

The way it is structured in Visual Studio is, we have a single Visual Studio solution corresponding to the main web site, and this single solution has multiple web projects, each corresponding to one application in IIS. The master .config file and common folders like styles, image, script are added to Visual Studio Solution. Since, the master .config file and common folders are not the part of any of the web project, it is not getting included in the nuget package for octopus. We use TFS MS build to create the nuget package by passing “/p:RunOctoPack=true” as MSBuild Arguments, as well as a bunch of other Octo args.

Could you please let us know how we can include the master .config file and common folders like styles, image, script to the nuget package of octopus? Or should we restructure in Visual Studio?

Hi,

Thanks for reaching out. You can follow the same approach described on the below doc, but for your folders/files instead of the BuildEvents file.

Hope that helps,
Dalmiro

Hi Dalmiro,

Thanks a lot for your response. This solution is really good for copying the file which are not the part of web project. But our issue is little different. We wanted to get master.config file copied to the parent directory.
Ex:
Let’s say may main website folder is MainWebsite, under that we have child webapp1 folder and child webapp2 folder . The master.config file is there in MainWebsite folder. And when I create the nuget package for webapp2, the nuget package should have master.config file and webapp2 folder. And in this case when I deploy webapp2 from octopus, it will replace master.config file and webapp2 folder

Could you please let me know how can I achieve this?

Hi Lijo,

You should be able to achieve this by using the above technique with a Nuspec file that tells nuget to fetch a file/folder from a previous directory ( master.config one dir above webapp2 folder)and then include it in the package. The link below shows how to add files and folders to your package using the Nuspec file:

That said, I would personally avoid using Nuspec files for this, and simply restructure things in Visual Studio so WebApp1 and WebApp2 always have all they need in their folders without having to fetch files from someplace else at build/pack time.

Regards,
Dalmiro

Thank you for this approach. I agree we can restructure and copy all shared elements and config points in to each application folder. It’s just
that we saw this as increasing maintenance risk, as we will now keep multiple copies is VS of a large number of repeated elements and config points. Eg someone could make a mistake on a config point, but it’s only in one of the folders. So the application as a whole works – most of the time. Unless we always ensure full regression testing we would miss such things and decrease application reliability.

As you say, we want to follow best practice for Octopus, so I don’t mind terribly if we go the way you propose – I just was hoping to stay best practice with software copy/ paste proliferation as well.

Thanks again for your help; any further thoughts appreciated.

Hi Dalmiro,

One more question. As i said we have multiple web projects in the solution. I have created separate build definition for each web project. But when Octopus creates the nuget package, it is picking only first web project and including in the nuget package. Even if i queue the second project build, it is picking only first project. So is there any way that i can solve this issue?

Hi there,

Was the Octopack Nuget package installed in that 2nd project as well? If you go to “Manage Nuget packages for solution”, then check for the installed ones and then Octopack, do you see it installed in all the needed projects or only in the first one?

If it IS installed, try unistalling it and re-installing it back for all the needed projects.

Thanks,
Dalmiro

Hi Dalmiro,

I have added the Octopack to all the web projects. But some how it is creating the nuget package only for the last project now. I am not sure what i am missing now?

Hi Lijo,

Can you please send:

  • Your build log where its only packaging a single project.
  • The csproj file of the single project that’s being packages
  • the csproj file of a project that is not being packaged in that same solution.

Thanks,
Dalmiro

Hi Dalmiro,

It is not allowing me to attach the file requested. Please find the screenshot attached.

Could you try uploading your files here: Share URL
https://file.ac/ZyW_SOg9pXk/

Hi Dalmiro,

I have uploaded all requested files to the above link.

Hi,

I’m helping Dalmiro out with this issue. Thanks for sending the files as that helps greatly! :slight_smile: That said, I think I have found the issue. The problem appears to be that all three web apps are using the same nuspec file. Octopack will generate a default nuspec file for you if one doesn’t exist and it appears that the other web apps are reusing the one that is automatically generated.

The next step is to determine why this is occurring. I’m guessing that Octopack might be getting confused based on your solution/project structure but I’m not entirely sure as it’s a bit tricky to decipher csproj files. :wink: To troubleshoot this issue, I would suggest trying to add explicit nuspec files for each web application as per the following page. http://docs.octopusdeploy.com/display/OD/Using+OctoPack#UsingOctoPack-AddingaNuSpec If you specify a couple of files that are unique to each web app, you should be able to see if it’s picking up the appropriate files and building independent nupkg files. If this works, then you could update the nuspec files to include all the relevant files or experiment with your solution/project structure to remove the need for them.

A minor tip to test this quickly is to build your solution locally at the command line. For example, I generally execute msbuild SolutionName.sln /t:Build /p:RunOctoPack=true at the command line on my local computer. Then you can confirm if the appropriate nupkg files were generated.

Let me know how you go!

Rob