2

I am adding any script file in disk (by Add Existing item > Add as link), to standard mvc3project/scripts folder the file has not seen in compiled version. When i change the referenced js file's properties, Copy to output always or change build action to content or compile the result is the same. How can i add a js file to asp.net mvc project as linked file.

Step by Step

  1. In asp.net mvc3 project there is folder named "Scripts"
  2. And i want to add a jscript file to this folder.
  3. But i dont want to add file as physically.
  4. I right click on the scripts folder. Add new item. Select the js file. And click the add as linked file.
  5. the file appears on the script folder. But when i run the site. The file could not be found by the web application.
Codo
  • 75,595
  • 17
  • 168
  • 206
jack-london
  • 1,599
  • 3
  • 21
  • 42
  • Even after reading your question several times, I don't understand what you're asking. Could you try to reformulate your question to make it clearer? And when you refer to text in UI, it's probably best to use put them in italics or quotes. – Codo Jul 18 '11 at 11:56
  • Ok. I will try to explain by steps. 1. In asp.net mvc3 project there is folder named "Scripts" 2. And i want to add a jscript file to this folder. 3. But i dont want to add file as physically. 4. I right click on the scripts folder. Add new item. Select the js file. And click the add as linked file. 5. the file appears on the script folder. But when i run the site. The file could not be found by the web application. – jack-london Jul 18 '11 at 12:03
  • Thanks. That's a good description of what you're trying to achieve and what doesn't work as expected. I've added it to the question. – Codo Jul 18 '11 at 12:10

1 Answers1

4

Unfortunately, Visual Studio doesn't copy linked Javascript files. The best solution I've seen so far is the use of a post-build action as proposed in this answer.

Community
  • 1
  • 1
Codo
  • 75,595
  • 17
  • 168
  • 206