2

I want to share my validation javascript in my framework project with my normal website.

I have a project folder called framework, this is where I define core functionality and validation in a form of attributes.

The problem is this framework project also includes javascript files for client side validation. I want to reference these files in my main project. How would I go about the correct way of doing this?

I know about setting the build action to set the file in the bin folder and reference file within the bin. But I read this is the incorrect way of going about it. I am using visual studio 2012 with an mvc 4.5 project.

3
  • how about this support.microsoft.com/kb/306234 Commented Mar 14, 2014 at 10:26
  • Ok thats great. But the article does not say how I can reference the file in my view. Commented Mar 14, 2014 at 11:13
  • you can do a folder with set of links in the project(where you have the view), after that just reference to scripts from that folder. Commented Mar 14, 2014 at 11:19

1 Answer 1

1

I share common resources (css/javascript etc) among projects by using nuget packages.

These are the steps I take.

Create nuget package

First create a nuget package that contains the javascript files.

I used Scott Hanselman's blog here to do that here:

http://www.hanselman.com/blog/CreatingANuGetPackageIn7EasyStepsPlusUsingNuGetToIntegrateASPNETMVC3IntoExistingWebFormsApplications.aspx

Store the new package on a network share

Drop the nuget package onto a network share which can be used as a package source repository.

Add to Visual Studio

Then add the package source repository into visual studio that points to your network share (Tools > Library Package Manager > Package Manager Settings > Package Sources > Add)

Add/Update in other projects

In each project you wish to use it you can just run the Install-Package to install and Update-Package to update.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.