Reputation: 871
We are having multiple .NET MVC projects linked each other but some script and css files are same for all. Folder structure is as below
- Root folder
- Assets
- Js
- CSS
- Project 1
- Project 2
- Project 3
All common js and are inside Assets/js and Assers/Css folder which is lying outside project folders. Can we bundle Assets folder into Project 1,2 and 3?
Thank you for any hint/guidance in advance.
Upvotes: 2
Views: 3963
Reputation:
Yes you can. You just need to add some codes in tjhe App_Start\BundleConfig.cs
file of each project.
Like this, you add in the method RegisterBundles
:
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("Root/Assets/js").Include(
"Root/Assets/Js/*.js")); //You put your path where there is the Root
bundles.Add(new StyleBundle("Root/Assets/css").Include(
"Root/Assets/CSS/*.css")); //You put your path where there is the Root
// Code removed for clarity.
}
And then you you can put these lines inside each Layout.cshtml
@Styles.Render("Root/Assets/css")
@Scripts.Render("Root/Assets/js")
To call your Js
library and CSS
files.
I hope it will help
Upvotes: 2
Reputation: 9725
Yes you can, create a web setup project...
New Project > Other Project Types > Setup and Deployment > Visual Studio Installer > Web Setup Project
Then right mouse click on the setup project and select
View > File System
From there you can add custom folders / files that will be included in the setup file that is deployable.
Upvotes: 0