alem0lars
alem0lars

Reputation: 690

ASP.NET MVC 4 IncludeDirectory from a another referenced project

I'm facing out a strange problem while using ASP.NET MVC 4.

I have 2 "Web Site" projects:

I need to include the scripts under MyWebSite into MyWebSite.Support, so i thought to create a bundle in MyWebSite.Support and to reference that directory (MyWebSite/Scripts) inside that bundle by using "IncludeDirectory"

The problem is that i didn't found a way to correctly do that. It simply doesn't work because the starting path for the IncludeDirectory should be "~", which is the project virtual root path.

PS: If you have another solutions they are welcome!. I don't even know if it's a good solution (i usually am not a everything_related_microsoft developer)

Upvotes: 0

Views: 809

Answers (1)

Kenneth
Kenneth

Reputation: 28747

You could add the scripts as a link to the other project. This will assure you that they are copied when you deploy and you can use them in bundles. To do that, right-click on your scripts folder and select "Add existing item". In the dialog box select the files you want to add. Instead of clicking "Add Item", click on the little arrow next to it and select "Add as a link".

This will not actually copy the files, but include them as a linked file.

This has several advantages:

  • Files are shared between projects at Design time
  • You only need to share the files you want, not everything
  • You don't need any IIS configuration
  • You can easily edit the same file from each project (without copying it)

Upvotes: 1

Related Questions