1

I have a .NET Core 3.1 project referencing a Razor Class Library project in the same VS 2019 solution.

I have Bootstrap, jQuery and several other libraries stored in the Razor Class Library. They need to stay in the class library as there will be several different .NET Core projects referencing this class library.

Is it possible to have VS 2019 Intellisense working for client-side code between these 2 projects?

Note 1: The .Net Core project loads the scripts perfectly fine in run-time.

Note 2: If I copy/paste Bootstrap, jQuery, etc. into the .NET Core project, Intellisense works fine. But this defeats the purpose of my shared class library.

VS 2019 version: 4.8.03752

Graham Meehan
  • 445
  • 5
  • 18

1 Answers1

3

Is it possible to have VS 2019 Intellisense working for client-side code between these 2 projects?

If you want to use JS/CSS intellisense which is from other place into a new project, you can try these steps:

1) Right-click on your current .Net Core project and create a New Item-----a javascript file or a style sheet file which is for css).

2) add this in the javascript file whcih can apply JS Intellisense to the entire project.

/// <reference path="xxxx\RazorClassLibrary1\bootstrap.js" />(the path of the js file from RazorClassLibrary)
/// <reference path=""xxxx\RazorClassLibrary1\jquery.js />
.......

> Reference any JS files you want to use from RazorClassLibrary into here.

Also, add this into the style sheet file.

///<reference path="xxxx\RazorClassLibrary1\xxx.css" />

.......

3) Then you can use Intellisense of them in the whole project as you want.

Hope it could help you.

Mr Qian
  • 21,064
  • 1
  • 31
  • 41
  • Thank you. The JS worked as you explained, however the CSS required import statements. (references are not valid css). All is well now! – Graham Meehan Jan 27 '20 at 20:16
  • Any chance that you can provide the example of what you did to get the CSS IntelliSense working? I have gotten the JavaScript IntelliSense working as outlined above, but am unable to get the CSS working. I have posted a question with an example here: [https://stackoverflow.com/questions/60893508/intellisense-not-working-for-css-files-in-net-core-3-1-razor-class-library-when](https://stackoverflow.com/questions/60893508/intellisense-not-working-for-css-files-in-net-core-3-1-razor-class-library-when) – Shawn Paige Apr 01 '20 at 18:52