FloatingKiwi
FloatingKiwi

Reputation: 4506

asp.net core exclude files from the build

I'm trying to add Protractor to my asp.net-core application.

I added it via npm and it installs the selenium-webdriver which contains a file Page.aspx.cs. This is causing a build error but my project doesn't even need to compile it.

So I'm trying to exclude node_modules using project.json

"buildOptions": {
  "emitEntryPoint": true,
  "preserveCompilationContext": true,
  "compile": {
    "excludeFiles": "node_modules"
  }
},

Gives Illegal characters in path as does:

 "excludeFiles": ["node_modules"]

This seems to be related to the _ character but I can't work out why that would be an issue.

Thanks

Upvotes: 3

Views: 2692

Answers (3)

Abhishek Chokra
Abhishek Chokra

Reputation: 1381

Solution - In the Solution Explorer, right click on the node_modules folder and click "Exclude From Project"

Reason - If you are working on a client side app that includes npm and node_module folders with large amount of dependencies while using website project in Visual Studio, which is a terrible solution.It results in very slow load times and/or file load errors.

If you have a node_modules folder in your project it will affect the files in the project as well as for publishing. Finally, using a node_modules massive folder in your project there is no way to limit files or folders and end up giving errors.

Upvotes: 0

FloatingKiwi
FloatingKiwi

Reputation: 4506

I managed to get this working using exclude instead of excludeFiles

"buildOptions": {
  "emitEntryPoint": true,
  "preserveCompilationContext": true,
  "compile": {
    "exclude": ["node_modules"]
  }
},

Upvotes: 6

Joe Audette
Joe Audette

Reputation: 36696

did you try with specific file names instead of folder names?

"excludeFiles": ["node_modules/path/to/Page.aspx.cs"]

Upvotes: 0

Related Questions