标签: visual-studio-code

在Visual Studio Code中还原依赖关系使用了错误的源/提要

我不确定如何将Visual Studio Code中的.net核心项目的默认nuget提要设置为https://api.nuget.org/v3/index.json

当我尝试添加程序包(并随后恢复依赖关系)时,出现以下错误...

C:\Program Files\dotnet\sdk\2.1.403\NuGet.targets(114,5): error : Unable to load the service index for source https://smartassessor.pkgs.visualstudio.com/_packaging/SANuget/nuget/v3/index.json. [c:\Users\Matthew.OConnor\Desktop\Important Documents\Programming\DatingApp\DatingApp.API\DatingApp.API.csproj]
C:\Program Files\dotnet\sdk\2.1.403\NuGet.targets(114,5): error :   Response status code does not indicate success: 401 (Unauthorized). [c:\Users\Matthew.OConnor\Desktop\Important Documents\Programming\DatingApp\DatingApp.API\DatingApp.API.csproj]
Run Code Online (Sandbox Code Playgroud)

此源https://smartassessor.pkgs.visualstudio.com/_packaging/SANuget/nuget/v3/index.json与我当前的项目无关,但是它用于通常使用完整Visual Studio运行的其他项目。这些项目保存在与该项目完全不同的位置。

我只希望能够在.net核心项目中从nuget.org添加nuget包。如何在VS代码中执行此操作?

我目前在这个项目中没有nuget.config文件。

错误中提到的程序包源似乎来自我在使用Visual Studio时设置的程序包源

在此处输入图片说明

这是我的csproj文件...

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <Folder Include="wwwroot\"/>
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App"/>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4"/>
    <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="4.0.1"/>
    <PackageReference Include="CloudinaryDotNet" Version="1.3.1"/>
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.1.0-preview1-final"/>
  </ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)

CloudinaryDotNet 是产生上述错误的软件包。

c# nuget-package-restore visual-studio-code asp.net-core

1
推荐指数
1
解决办法
2317
查看次数

角度如果组件中的条件不起作用

我正在尝试根据id属性设置角度模型值.如果"id"具有从服务获取数据的值,则设置默认值

ngOnInit() {
    // tslint:disable-next-line:radix
    let id = parseInt(this.route.snapshot.paramMap.get('id'));
    this.departmentId = id;

    if (id === NaN) {
       // tslint:disable-next-line:max-line-length
       this.departmentModel = new Department(1, 0, '', 'admin', new Date(2018, 11, 11), 'localhost', 'admin', new Date(2018, 11, 11), 'localhost');
    } else {
       this.departmentService.getDepartment(this.departmentId).subscribe(data => this.departmentModel = data);        
    }
}
Run Code Online (Sandbox Code Playgroud)

但它始终属于其他部分,即使"id"具有值.我该如何解决这个问题.任何帮助都会受到高度关注.

visual-studio-code angular angular6

1
推荐指数
1
解决办法
53
查看次数

VS代码如何将未使用的变量显示为红色

我的编辑器设置为未使用的导入和变量启用了变灰: "editor.showUnused": true

但是,如何更改它,使该行具有红色背景而不是变灰呢?

这是一个Javascript文件。

vscode中未使用的变量导入

visual-studio-code vscode-settings

1
推荐指数
3
解决办法
1838
查看次数

使用Visual Studio Code逐步调试Python中的导入模块

import pandas as pd
data = pd.read_csv(some_data)
Run Code Online (Sandbox Code Playgroud)

我在此代码的第二行中添加了一个断点,Visual Studio代码在此断点处停止。但是,当我尝试进入“ read_csv”函数时,vscode显然执行了“跳过”。我还尝试在“ read_csv”函数中设置断点,但结果相同。

那么,如何进入提到的功能呢?

python debugging python-import visual-studio-code

1
推荐指数
2
解决办法
1089
查看次数

VSCode运行C ++代码时没有这样的文件或目录

当我尝试跑步时 我的代码 我收到此错误:

main.cpp:1:18:致命错误:temp.h:没有此类文件或目录#include“ temp.h”编译终止。

但是,Intellisense会检测到此标头存在。
Ctrl +左键单击main.cpp中的#include“ temp.h”成功将我带到该文件,并且该代码行在其下面没有任何弯曲的行。

我为.cpp文件和头文件有两个单独的文件夹,并在c_cpp_properties.json中配置了includePath,如下所示: c_cpp_properties屏幕截图

我的工作区文件夹是temp,“ $ {workspaceFolder} / **”行应递归地检查子文件夹中的标题。我将绝对路径添加到头文件没有成功。

c++ intellisense file include visual-studio-code

1
推荐指数
1
解决办法
3833
查看次数

Dart语法突出显示未突出显示Dart代码

我已经安装了dart(仅语法突出显示)扩展名,但没有突出显示我的dart代码。安装扩展名后,我已经重新启动了VS代码几次,但无法正常工作。有人请让我知道这个问题,我该如何解决。

以下是我的VS代码屏幕截图:

与

谢谢

dart visual-studio-code

1
推荐指数
1
解决办法
675
查看次数

如何避免VsCode Prettier中断换行功能?

我正在使用VSCode,Prettier和TSLint。

当我确实有多个函数调用时,例如

let m = moment().startOf("day").subtract(30, "days");
Run Code Online (Sandbox Code Playgroud)

更漂亮的闯入

let m = moment()
    .startOf("day")
    .subtract(30, "days")
Run Code Online (Sandbox Code Playgroud)

我已经设置了TSLint规则

{
  "defaultSeverity": "warning",
  "extends": ["tslint:recommended"],
  "linterOptions": {
    "exclude": ["node_modules/**"]
  },
  "rules": {
    // ...
    "newline-per-chained-call": false
  }
}
Run Code Online (Sandbox Code Playgroud)

和休闲的设置

"prettier.tslintIntegration": true
Run Code Online (Sandbox Code Playgroud)

但是链接的功能仍在不断发展。

如何避免断线但仍使用TSLint?

tslint visual-studio-code prettier

1
推荐指数
2
解决办法
1649
查看次数

属性“程序”不存在-VS代码中的错误

因此,我创建了一个名为“ Node Projects”的新文件夹,并将其添加到VS Code的“ Workspace”中。然后,我创建了两个示例文件,分别称为“ test.js”和“ test2.js”。在这些文件中,我仅具有一个log命令即可确定正在运行的命令。

当我运行test.js时,出现错误消息“属性'程序'不存在(C:\ Users \ MyName \ Documents \ NodeProjects / Node Projects / test.js',所以我单击“打开launch.json”按钮,然后看到以下内容:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceFolder}/Node Projects\\test.js"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

根据我在此处关于stackoverflow的搜索,我认为问题出在“程序”行,因此我将其更改为

"program": "${workspaceFolder}\\test.js"

所以现在,当我执行F5时,调试器将运行test.js,这很棒。但是因为test.js值是硬编码的,所以即使我在编辑器上打开test2.js并执行F5,它也会再次运行test.js!因此,我尝试从launch.json中删除文件名(即test.js)。但是现在当我尝试运行文件时,出现了“无法启动程序”错误。哦,删除launch.json还是没有帮助(它只是重新创建了初始的launch.json文件,我回到了第一个)。

node.js visual-studio-code

1
推荐指数
1
解决办法
2269
查看次数

如何在git / macbook中将VScode设置为核心编辑器

我无法将Visual Studio Code设置为git的核心编辑器。当我尝试执行git commit时,我只会看到有关编辑器存在问题的信息。

MacBook-Air-Agata:~ agataskrzypczyk$ git config --global core.editor "/Applications/Visual Studio Code.app" --wait

MacBook-Air-Agata:~ agataskrzypczyk$ git config --global core.editor
/Applications/Visual Studio Code.app

MacBook-Air-Agata:~ agataskrzypczyk$ cd nowy

MacBook-Air-Agata:nowy agataskrzypczyk$ git commit

hint: Waiting for your editor to close the file... /Applications/Visual Studio Code.app: /Applications/Visual: No such file or directory
error: There was a problem with the editor '/Applications/Visual Studio Code.app'.
Please supply the message using either -m or -F option.
MacBook-Air-Agata:nowy agataskrzypczyk$
Run Code Online (Sandbox Code Playgroud)

git visual-studio-code

1
推荐指数
2
解决办法
986
查看次数

Pylint未按预期在VScode中运行

当我通过shell运行时pylint:

$ pylint decorator.py 
No config file found, using default configuration
************* Module decorator
C:  7, 0: Unnecessary parens after 'print' keyword (superfluous-parens)
C: 15, 0: Unnecessary parens after 'print' keyword (superfluous-parens)
C:  1, 0: Missing module docstring (missing-docstring)
C:  4, 0: Missing function docstring (missing-docstring)
C:  6, 4: Missing function docstring (missing-docstring)
C: 14, 0: Missing function docstring (missing-docstring)
Run Code Online (Sandbox Code Playgroud)

但是,如下所示,这些警告不会在VSCode中出现

在此处输入图片说明

...尽管实际上已经执行了一些基本检查,如下图所示,但我删除了空白行:

在此处输入图片说明

python lint visual-studio-code

1
推荐指数
2
解决办法
1676
查看次数