How to configure bower in Asp.net project using Visual Studio Code - visual-studio-code

I create an empty project using Visual Studio Code's terminal. Then I add bower.json and bower_config.bowerrc files then using terminal run the bower update command. The files contains next code:
bower.json
{
"name": "asp.net",
"private": true,
"directory": "wwwroot/lib",
"dependencies": {
"bootstrap": "4.0.0-alpha.6"
}
}
bower_config.bowerrc
{
"directory": "wwwroot/lib"
}
But even I configured it to download files into wwwrooot/lib folder it still install into bower_comoponents folder. How can I resolve that?
P.S. I need to use Visual Studio Code not Visual Studio.

Your bower configuration file should be named .bowerrc (no bower_config prefix).

Related

Azure bicep Failed to install .NET runtime v5.0. in visual studio code

I am running into the error Failed to install .NET runtime v5.0. when using bicep in visual studio code on a windows machine.
I'm not sure why it's not able to find it automatically, but manually specifying the dotnet path in settings.json resolved the problem.
"dotnetAcquisitionExtension.existingDotnetPath": [
{
"extensionId": "ms-azuretools.vscode-bicep",
"path": "C:\\Program Files\\dotnet\\dotnet.exe"
}
]

#types/vscode ^x.xx greater than engines.vscode ^x.xx

When I run vsce
vsce publish
I get the following error:
#types/vscode ^1.62.0 greater than engines.vscode ^1.48.0
Consider upgrade engines.vscode or use an older #types/vscode version
I have the following dependencies in my package.json:
"devDependencies": {
"#types/vscode": "^1.62.0",
"vsce": "^2.5.0"
}
How do I update engines.vscode?
Related: How do I update my vscode extension's engine requirement
According to publishing docs section on Visual Studio Code compatibility
When authoring an extension, you will need to describe what is the extension's compatibility to Visual Studio Code itself. This can be done via the engines.vscode field inside package.json:
{
"engines": {
"vscode": "^1.62.0"
}
}

How do I specify a specific prettier version in a VSCode .devcontainer?

Background
In a repo, we have a pre-commit configuration that requires version 2.2.1 of prettier:
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.2.1"
hooks:
- id: prettier
And in my .devcontainer I specify use of prettier, so that my code gets formatted on save:
{
// ...
"settings": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
// ...
}
}
Prettier is installed by the vscode extension, not globally, so doing:
npm list -g | grep prettier
in my dev container doesn't list anything installed.
The problem
A different version of prettier is being used, and I get a conflict in how it formats arrays in json files. Every time I open up a particular json file, it gets reformatted by my editor.
Also, if I rebuild my devcontainer, I'm then liable to unknowingly switch the version of code formatter I use, leading to git hell.
The question
How can I specify that my devcontainer use an exact prettier version so I can enforce the same behaviour in my dev environment as in our code quality tools?
I have already tried this:
You can set up the prettier extension to use a resolved version of prettier, according to the instructions under "Prettier Resolution" here.
So I added to the Dockerfile:
# Ensure prettier is installed globally so the esbenp.prettier-vscode can find a specific version
# as discussed here:
# https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
# NB You can remove the -g flag if you have a node project. I install globally because I use prettier on all projects, whether they have a node_modules folder or not.
RUN npm install prettier#2.2.1 -g -D --save-exact
And in the .devcontainer.json settings, told the extension to resolve the prettier module instead of using its own:
{
// ...
"settings": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"prettier.resolveGlobalModules": true,
// ...
}
}
That didn't work so I also tried adding:
"prettier.prettierPath": "$(npm root -g)/prettier",
Which also didn't work; the prettier extension is still using it's own version.
You can set the version in the .devcontainer like this:
"extensions": ["esbenp.prettier-vscode#8.0.1"],
The trick is you also have to turn off extension automatic updates:
"settings": {
"extensions.autoCheckUpdates": false,
"extensions.autoUpdate": false
},
Note: This turns off automatic updates for all extensions.
Also, RUN npm install prettier#2.2.1 -g -D --save-exact in the Dockerfile adds the prettier CLI to the environment, not the VS Code extension.

arduino settings for Visual Studio Code

This is driving me crazy! I see solutions all over the web and I still can't get this to work. Here is my settings.json file:
{
"C_Cpp.updateChannel": "Insiders",
"workbench.editorAssociations": {
"*.ipynb": "jupyter.notebook.ipynb"
},
"arduino.additionalUrls": "",
"arduino.path": "C:\\Program Files (x86)\\Arduino",
"arduino.commandPath": "arduino.exe",
"files.autoSave": "onWindowChange",
}
I am running on Windows 10 and Arduino is installed in:
C:\Program Files (x86)\Arduino
I have four executables there:
arduino.exe
arduino_debug.exe (I downloaded this for good measure!)
arduino-cli.exe
uninstall.exe
When I click "Select Programmer" in VSC, I get"
"Cannot find Arduino IDE. Please specify the "arduino.path" in the User Settings. Requires a restart after change.
I have restarted the IDE and still get the same problem.
I have rebooted the laptop.
I have tried uninstalling both VSC and Arduino.
The Arduino IDE works fine stand-alone.
Wow! I finally stumbled on these installation instructions:
https://nortronics.com.au/setting-up-visual-studio-code-for-arduino-programming/
This is what my .vscode/settings.json (you can find it in the left pane under .vscode in your project folder) now looks like:
{
"arduino.path": "C:\\Program Files (x86)\\Arduino",
"C_Cpp.intelliSenseEngineFallback": "Disabled",
"C_Cpp.intelliSenseEngine": "Tag Parser",
"arduino.enableUSBDetection": true,
}

Getting ModuleNotFoundError in python, package exists in virtual environment though

I am new to python and writing my first python file using Visual Studio Code. Till yesterday the code was working fine. But today it is starting to give ModuleNotFoundError. I double-checked the package and the package is there under lib folder of the virtual environment. Moreover, IntelliSense is also working fine, whenever I write import it shows the requests module in the available list. I am facing problems with IntelliSense also, as sometimes it stops working for no reason.
The major change that I did before executing the code is the integration of GitLab with my project.
Python Version: 3.6.2
Operating System: Windows
Git Version: 2.23.0
Pylint Version: 2.3.1
pip Version: 19.2.2
Requests Version: 2.22.0
Pytest Version: 5.1.1
Enabled Extensions:
Npm
Npm Intellisense
Ayu
Code Runner
AYU
Markdownlint
Predawn Themekit
Python by Microsoft
Can anyone have gone through with the same problem? Please help me to resolve this issue.
Attachments
Issue resolved I was running it using Ctrl+Alt+N (code-runner shortcut to run a project)which was creating this issue. But running the file in terminal using Run Python File in Terminal (option in the context menu when we do right-click in source .py file) giving me the expected result without any error.
Then I googled for how to alter this behavior so that I can get the same results by using Ctrl+Alt+N as well.
I found that; I need to add the following script under user's settings.json.
"code-runner.executorMap": {
"python": "h:\\practice\\virtualenv\\Scripts\\activate.bat && python -u"
}
Here is my complete user's settings.json
{
"workbench.colorTheme": "Predawn",
"workbench.iconTheme": "ayu",
"window.zoomLevel": 0,
"code-runner.executorMap": {
"python": "h:\\practice\\virtualenv\\Scripts\\activate.bat && python -u"
}
}