1

I'm trying to use some script files between different projects. I have one solution with four projects. In the project "A" I have some scripts like Jquery, Javascript Plugins, etc, and i want to use them on the project "B", by adding a scriptmanager, or anything that works. What can i do this?

I'm using Visual Studio 2010.

Here is a printscreen with my environment.

enter image description here

[EDIT]

Hello, after doing what @CStick says, a have now the scripts in my other project, so a can't add them to a ScriptManager. The problem is path not found on Asp.net code. It cant find the script cause they're placed in the other project. What can i do to solve it?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Diego Oliveira
  • 63
  • 1
  • 3
  • 8
  • simple way is use them on both of projects, simple way is the best way, for this problem **paint** is better than **photoshop**.. – mehdi Dec 10 '13 at 22:50
  • 2
    If you decide to add the files to both projects. You could save yourself the trouble of having to sync changes between the files by adding the files as links from the other project. Choose "Add Existing Files", navigate to the missing files in the other project and select them, however instead of choosing "Add" which will make a copy of the files, you can choose "Add as Link". – cstick Dec 10 '13 at 23:54
  • Hey guys, when i tried to add a scriptmanager and set the path such as Scripts/Jquery.js the Asp.net tells that the path is not found, but i can see the file in solution explorer, with an arrow icon. Any solution to this problem @CStick? – Diego Oliveira Dec 11 '13 at 11:16
  • I apologize, my advice was not good. For content, for websites in particular, linking files does not work very well. It is better suited for files that are compiled (such as VB files). Reason being that the content files do not actually exist within the website during debugging and such. – cstick Dec 11 '13 at 15:41
  • 1
    Hello Friends, i Solved the problem doing this: I've created an instance on my IIS server that hosts all script files that i need, and than, modified the scriptmanager path to scripts like: http://myiishostserver:port/Scripts/xxx.js Thanks to all. As @mehdi says, "...simple way is the best way..." – Diego Oliveira Dec 11 '13 at 17:02

1 Answers1

2

I know this is old, but for future reader i post an answer.

You will have to use "Link project file" for this.

  1. From the target project, right click on the folder you what the file to be
  2. Select add -> Existing file
  3. Browse to the file you need then click on the arrow at the right of the add button and select add as a link

After this you can modify the file in booth project, but the fille will be only in the source physical location until you publish the project. This can cause problem for client side file, like script file, on debug because you cant view the file because it's not physically in the target project. You can use MsBuild to copy the source file on the target directory on build. (See this answer)

In short, you will create a .targets file then add a reference in your project file.

Community
  • 1
  • 1
Benoit
  • 1,109
  • 14
  • 29