« Visual studio code » : différence entre les versions

De Banane Atomic
Aller à la navigationAller à la recherche
 
(35 versions intermédiaires par le même utilisateur non affichées)
Ligne 13 : Ligne 13 :
| Ctrl + Shift + P || Lancer une commande
| Ctrl + Shift + P || Lancer une commande
|-
|-
| Ctrl + Shift + I || Formater le code
| Shift + Alt + F<br>Ctrl + Shift + I || Formater le code
|-
| Ctrl + K, M || Change Language Mode
|-
|-
| Ctrl + ! || Afficher le terminal
| Ctrl + ! || Afficher le terminal
|-
| Ctrl + Shift + Alt + ↓ || Duplicate current line (Copy Line Down)
|-
| Ctrl + Shift + 7 || Toogle line comment
|}
|}
{{info | To know the action binded to a shortcut, you can search the shortcut: {{boxx|"ctrl+d"}}}}


= Utilisation =
= Utilisation =
Ligne 40 : Ligne 47 :
! Value
! Value
|-
|-
| Side Bar à droite || Side Bar: Location || right
| Side Bar à droite || Workbench → Appearence → Side Bar: Location || right
|-
|-
| Formatter à la sauvegarde || Editor: Format On Save<br>Editor: Format On Paste
| Formatter à la sauvegarde || Editor: Format On Save<br>Editor: Format On Paste
Ligne 53 : Ligne 60 :
|-
|-
| Nb de fichiers dans Open Editors || Explorer - Open Editors: Visible || 0
| Nb de fichiers dans Open Editors || Explorer - Open Editors: Visible || 0
|-
| Affiche les lignes de context lors du scroll || Editor: Sticky Scroll || Enabled
|}
|}


Ligne 64 : Ligne 73 :
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
</kode>
</kode>
== [https://stackoverflow.com/questions/29973619/how-to-make-vs-code-treat-a-file-extensions-as-a-certain-language/51228725#51228725 Associate a file extension to a language] ==
# open the file you want to associate to a language
# {{boxx|Ctrl + K + M}} (Change Language Mode)
# select the language to associate, if it is not listed you can enter the first letter to search it


= [https://code.visualstudio.com/docs/getstarted/themes Color Theme] =
= [https://code.visualstudio.com/docs/getstarted/themes Color Theme] =
Ligne 79 : Ligne 93 :
! Description
! Description
|-
|-
| [https://marketplace.visualstudio.com/items?itemName=vscode-icons-team.vscode-icons vscode-icons] || belles icônes dans l'arborescence de fichiers
| [https://marketplace.visualstudio.com/items?itemName=vscode-icons-team.vscode-icons vscode-icons] || belles icônes dans l'arborescence de fichiers ([https://github.com/vscode-icons/vscode-icons/wiki/ListOfFiles file] [https://github.com/vscode-icons/vscode-icons/wiki/ListOfFolders folder])
|-
|-
| [https://github.com/microsoft/azure-repos-vscode Azure Repos] ||
| [https://github.com/microsoft/azure-repos-vscode Azure Repos] ||
# {{boxx|Ctrl + P}}
# {{boxx|Ctrl + P}}
# {{boxx|> team signin}}
# {{boxx|> team signin}}
|-
| [https://www.gitkraken.com/gitlens/features Git Lens] || suite d'outils Git: Commit Graph, Commit Details, Visual File History (Pro)
|-
|-
| [https://marketplace.visualstudio.com/items?itemName=donjayamanne.githistory Git History] || affiche l'historique des commits
| [https://marketplace.visualstudio.com/items?itemName=donjayamanne.githistory Git History] || affiche l'historique des commits
Ligne 95 : Ligne 111 :
! Description
! Description
|-
|-
| C# Extensions ||  
| [https://marketplace.visualstudio.com/items?itemName=jchannon.csharpextensions jchannon C# Extensions] ||
* clique-droit new C# classe / interface
* context menu explorer side bar New C# Class / Interface
* ajouter des champs / propriétés depuis les arguments du ctor
* generate fields / properties from a constructor
* initialiser un ctor avec les propriétés de la classe
* generate constructor from properties
|-
| [https://marketplace.visualstudio.com/items?itemName=Fudge.auto-using Auto-Using for C#] || automatically add using and references
|-
| [https://marketplace.visualstudio.com/items?itemName=craigthomas.supersharp Super Sharp] ||
* move a class to a new file
* add constructor injected dependencies
|-
|-
| NuGet Gallery || installation / désinstallation de package NuGet
| NuGet Gallery || installation / désinstallation de package NuGet
Ligne 107 : Ligne 129 :
|-
|-
| [https://marketplace.visualstudio.com/items?itemName=icsharpcode.ilspy-vscode ILSpy .NET Decompiler] || décompiler des assemby - {{boxx|Ctrl+Shift+P}} → ilspy
| [https://marketplace.visualstudio.com/items?itemName=icsharpcode.ilspy-vscode ILSpy .NET Decompiler] || décompiler des assemby - {{boxx|Ctrl+Shift+P}} → ilspy
|-
| EditorConfig for VS Code || override user/workspace settings with settings found in {{boxx|.editorconfig}} files
|}
=== [[Tests_unitaires#Installation_pour_VSCode_et_.net_core|.NET Core Test Explorer]] ===
Cette extension recherche dans le dossier courant les fichiers {{boxx|*.csproj}} et {{boxx|*.sln}} pour découvrir les projects de test.
<kode lang='bash'>
# create a folder and a file MySolution/MySolution.sln
dotnet new sln -o MySolution
# add projets to the solution
dotnet sln add ./MyProject/MyProject.csproj
</kode>
== SQL ==
{| class="wikitable wtp"
! Nom de l'extension
! Description
|-
| [https://vscode-sqltools.mteixeira.dev/ SQLTools] || Connection explorer, query runner, intellisense, bookmarks, query history
|-
| [https://marketplace.visualstudio.com/items?itemName=mtxr.sqltools-driver-mssql SQLTools Microsoft SQL Server/Azure] ||
|-
| [https://marketplace.visualstudio.com/items?itemName=mtxr.sqltools-driver-mysql SQLTools MySQL/MariaDB] || SQLTools driver for MySQL and MariaDB
|}
== [https://code.visualstudio.com/docs/languages/python Python] ==
{| class="wikitable wtp"
! Extension
! Description
|-
| [https://marketplace.visualstudio.com/items?itemName=ms-python.python Python] || IntelliSense, linting, debugging, code navigation, code formatting, Jupyter notebook support, refactoring, variable explorer, test explorer
|}
|}


Ligne 216 : Ligne 270 :


= [https://code.visualstudio.com/docs/editor/tasks Tasks] =
= [https://code.visualstudio.com/docs/editor/tasks Tasks] =
{{info | Lister les build tasks: {{boxx|Ctrl + Shift + B}} ou Terminal → Run Build Task}}
{{info |
* Run a task: {{boxx|Ctrl + Shift + P}} → delete teh {{boxx|>}} → {{boxx|task + Space}} → select the task
* Lister les build tasks: {{boxx|Ctrl + Shift + B}} ou Terminal → Run Build Task}}


<filebox fn='.vscode/tasks.json' collapsed>
<filebox fn='.vscode/tasks.json' collapsed>
Ligne 304 : Ligne 360 :
         }
         }
     ]
     ]
}
</filebox>
== [https://code.visualstudio.com/docs/editor/tasks#_defining-a-problem-matcher Problem Matcher] ==
* [https://www.allisonthackston.com/articles/vscode-tasks-problemmatcher.html VSCode Tasks Problem Matchers]
== dotnet tasks ==
<filebox fn='tasks.json' collapsed>
{
    "label": "roslynator",
    "command": "roslynator",
    "type": "shell",
    "args": [
        "analyze",
        "--analyzer-assemblies",
        "~/.vscode/extensions/josefpihrt-vscode.roslynator-4.3.0/roslyn/common",
        "~/.vscode/extensions/josefpihrt-vscode.roslynator-4.3.0/roslyn/analyzers"
    ],
    "problemMatcher": [
        {
            "owner": "roslynator",
            "fileLocation": ["relative", "${workspaceFolder}"], // if it is run for a solution, it missed the project folder
            "pattern": [
                {
                    "regexp": "^(.+?)\\((\\d+),(\\d+)\\): (warning|error) (.+?): (.+?)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "code": 5,
                    "message": 6
                }
            ]
        }
    ]
},
{
    "label": "code style",
    "command": "dotnet",
    "type": "shell",
    "args": [
        "format",
        "--verify-no-changes"
    ],
    "problemMatcher": [
        {
            "owner": "dotnet",
            "fileLocation": "absolute",
            "pattern": [
                {
                    "regexp": "^(.+?)\\((\\d+),(\\d+)\\): (warning|error) (.+?): (.+?) \\[.+\\]$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "code": 5,
                    "message": 6
                }
            ]
        }
    ]
}
</filebox>
= launch =
<filebox fn='.vscode/tasks.json'>
{
    "name": "Service .NET Core Launch (web)",
    "type": "coreclr",
    "request": "launch",
    "preLaunchTask": "build Service",
    "program": "${workspaceFolder}/Service/bin/Debug/netcoreapp3.1/Service.dll",
    "args": [],
    "cwd": "${workspaceFolder}/Service",
    "stopAtEntry": false,
    "serverReadyAction": {
        "action": "openExternally",
        "pattern": "^\\s*Now listening on:\\s+(https?://\\S+)",
        "uriFormat": "%s/swagger"
    },
    "env": {
        "ASPNETCORE_ENVIRONMENT": "Development"
    },
    "logging": {
        "engineLogging": true
    }
}
}
</filebox>
</filebox>
Ligne 333 : Ligne 475 :
# {{boxx|F1}} → {{boxx|MS SQL: Connect}} ou cliquer sur {{boxx|Disconnected}} en bas à droite → Create Connection Profile
# {{boxx|F1}} → {{boxx|MS SQL: Connect}} ou cliquer sur {{boxx|Disconnected}} en bas à droite → Create Connection Profile
# {{boxx|Ctrl + Shift + E}} exécuter du code
# {{boxx|Ctrl + Shift + E}} exécuter du code
= Markdown =
{{boxx|Ctrl + Shift + V}} → preview
= Replace =
== New line ==
To replace by a new line:
* use {{boxx|Ctrl}} + {{boxx|Enter}}
* or check {{boxx|.*}} (RegEx) and use {{boxx|\n}}
== regex ==
<kode lang='bash'>
.* xxx (\w+).*
$1
</kode>


= Erreurs =
= Erreurs =
== [https://github.com/OmniSharp/omnisharp-vscode/issues/4360#issuecomment-801181468 The "Microsoft.AspNetCore.Razor.Tasks.DiscoverDefaultScopedCssItems" task could not be loaded] ==
<pre>
The "Microsoft.AspNetCore.Razor.Tasks.DiscoverDefaultScopedCssItems" task could not be loaded from the assembly /usr/share/dotnet/sdk/5.0.204/Sdks/Microsoft.NET.Sdk.Razor/build/netstandard2.0/../../tasks/net46/Microsoft.NET.Sdk.Razor.Tasks.dll.
Invalid Image Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
</pre>
Create the folder {{boxx|/usr/share/dotnet/sdk/5.0.204/Sdks/Microsoft.NET.Sdk.Razor/tasks/net46}} and copy the following files:
* {{boxx|Microsoft.NET.Sdk.Razor.Tasks}}
* {{boxx|System.Collections.Immutable}}
* {{boxx|System.Reflection.Metadata}}
== Error processing 'handshake' request. Unknown Error: 0x89720010 ==
== Error processing 'handshake' request. Unknown Error: 0x89720010 ==
Debug doesn't start the application.
C# debugging doesn't start the application.<br>
Microsoft .NET Core Debugger only works with Microsoft Visual Studio Code and not with Visual Studio Code OSS ([https://github.com/OmniSharp/omnisharp-vscode/wiki/Microsoft-.NET-Core-Debugger-licensing-and-Microsoft-Visual-Studio-Code link]).


== [https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc Visual Studio Code is unable to watch for file changes in this large workspace] ==
== [https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc Visual Studio Code is unable to watch for file changes in this large workspace] ==

Dernière version du 13 juin 2024 à 14:29

Liens

Raccourcis clavier

Ctrl + Shift + P Lancer une commande
Shift + Alt + F
Ctrl + Shift + I
Formater le code
Ctrl + K, M Change Language Mode
Ctrl + ! Afficher le terminal
Ctrl + Shift + Alt + ↓ Duplicate current line (Copy Line Down)
Ctrl + Shift + 7 Toogle line comment
To know the action binded to a shortcut, you can search the shortcut: "ctrl+d"

Utilisation

Bash.svg
# créé le template "Console Application" (vscode.csproj Program.cs)
dotnet new console

# lister les templates disponibles
dotnet new -l

# lancer VS code dans le répertoire courant
code .
À l'ouverture de vscode, les éléments manquants sont téléchargés automatiquement (OmniSharp, .NET Core Debugger)

Settings

File → Preferences → Settings Ctrl + ,

Règlages Setting Value
Side Bar à droite Workbench → Appearence → Side Bar: Location right
Formatter à la sauvegarde Editor: Format On Save
Editor: Format On Paste
Font Editor: Font Family
Editor: Font Size
'Droid Sans Mono'
16
Word Wrap Editor: Word Wrap on
Cursor Editor: Cursor Blinking phase
Auto Save Files: Auto Save onFocusChange
Nb de fichiers dans Open Editors Explorer - Open Editors: Visible 0
Affiche les lignes de context lors du scroll Editor: Sticky Scroll Enabled

OLD

Json.svg
"window.zoomLevel": 1,

"explorer.enableDragAndDrop": false,

// Git Bash (défaut: powershell )
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",

Associate a file extension to a language

  1. open the file you want to associate to a language
  2. Ctrl + K + M (Change Language Mode)
  3. select the language to associate, if it is not listed you can enter the first letter to search it

Color Theme

File → Preferences → Color Theme
Color theme files are located at /usr/lib/code/extensions/theme-*

Extensions

Dernier élément du menu de gauche ou View → Extensions

  • ~/.vscode/extensions
  • %USERPROFILE%\.vscode\extensions

Communes

Nom de l'extension Description
vscode-icons belles icônes dans l'arborescence de fichiers (file folder)
Azure Repos
  1. Ctrl + P
  2. > team signin
Git Lens suite d'outils Git: Commit Graph, Commit Details, Visual File History (Pro)
Git History affiche l'historique des commits
Create GUID génère un GUID et le copie dans le presse-papier

C#

Nom de l'extension Description
jchannon C# Extensions
  • context menu explorer side bar → New C# Class / Interface
  • generate fields / properties from a constructor
  • generate constructor from properties
Auto-Using for C# automatically add using and references
Super Sharp
  • move a class to a new file
  • add constructor injected dependencies
NuGet Gallery installation / désinstallation de package NuGet
.NET Core Test Explorer tests unitaires
C# XML Documentation Comments commentaires avec ///
ILSpy .NET Decompiler décompiler des assemby - Ctrl+Shift+P → ilspy
EditorConfig for VS Code override user/workspace settings with settings found in .editorconfig files

.NET Core Test Explorer

Cette extension recherche dans le dossier courant les fichiers *.csproj et *.sln pour découvrir les projects de test.

Bash.svg
# create a folder and a file MySolution/MySolution.sln 
dotnet new sln -o MySolution

# add projets to the solution
dotnet sln add ./MyProject/MyProject.csproj

SQL

Nom de l'extension Description
SQLTools Connection explorer, query runner, intellisense, bookmarks, query history
SQLTools Microsoft SQL Server/Azure
SQLTools MySQL/MariaDB SQLTools driver for MySQL and MariaDB

Python

Extension Description
Python IntelliSense, linting, debugging, code navigation, code formatting, Jupyter notebook support, refactoring, variable explorer, test explorer

Angular

Nom de l'extension Description
Angular v6 Snippets
AngularDoc for Visual Studio Code arborescence pour navigation dans le code
Auto Import import auto dans les fichier TS
ESLint vérification du code javascript
markdownlint lint for MD
Markdown All in One format MD document + racourcis-clavier
TSLint vérification du code ts. Rules

Config ClientApp\tslint.json

TypeScript Hero
  • trie des imports, suppression des inutiles
  • ajout des imports
Move TS Move TypeScript files and update relative imports
Auto Close Tag HTML / XML
Auto Rename Tag renomme la balise fermante en même temps que la balise ouvrante

Travailler avec plusieurs projets (multi-root workspaces)

  • Ouvrir un second dossier dans le même VScode: File → Add Folder to Workspace (lien)
  • Référencer un autre projet:
Bash.svg
cd MainProject
dotnet add reference ../LibProject/LibProject.csproj
MainProject.csproj
<ItemGroup>
  <ProjectReference Include="..\LibProject\LibProject.csproj" />
</ItemGroup>

Debug multiple projects

  • Ajouter compounds au fichier .vscode/launch.json du workspace.
  • Dans Debug l'entrée définit dans compounds est disponible.
.vscode/launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "BlazorServerApp",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build BlazorServerApp",
            "program": "${workspaceFolder}/BlazorServerApp/bin/Debug/netcoreapp3.1/BlazorServerApp.dll",
            "args": [],
            "cwd": "${workspaceFolder}/BlazorServerApp",
            "stopAtEntry": false,
            "serverReadyAction": {
                "action": "openExternally",
                "pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
            },
            "env": {
                "ASPNETCORE_ENVIRONMENT": "Development"
            },
            "sourceFileMap": {
                "/Views": "${workspaceFolder}/Views"
            }
        },
        {
            "name": "WebApi",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build WebApi",
            "program": "${workspaceFolder}/WebApi/bin/Debug/netcoreapp3.1/WebApi.dll",
            "args": [],
            "cwd": "${workspaceFolder}/WebApi",
            "stopAtEntry": false,
            "serverReadyAction": {
                "action": "openExternally",
                "pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
            },
            "env": {
                "ASPNETCORE_ENVIRONMENT": "Development"
            },
            "sourceFileMap": {
                "/Views": "${workspaceFolder}/Views"
            }
        }
    ],
    "compounds": [
        {
            "name": "BlazorServerApp / WebApi",
            "configurations": [
                "BlazorServerApp",
                "WebApi"
            ],
            "preLaunchTask": "build all"
        }
    ]
}

Tasks

  • Run a task: Ctrl + Shift + P → delete teh >task + Space → select the task
  • Lister les build tasks: Ctrl + Shift + B ou Terminal → Run Build Task
.vscode/tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/WebApi.csproj",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "problemMatcher": "$msCompile"
        },
        {
            "label": "publish",
            "command": "dotnet",
            "type": "process",
            "args": [
                "publish",
                "${workspaceFolder}/WebApi.csproj",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "problemMatcher": "$msCompile"
        },
        {
            "label": "watch",
            "command": "dotnet",
            "type": "process",
            "args": [
                "watch",
                "run",
                "${workspaceFolder}/WebApi.csproj",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "problemMatcher": "$msCompile"
        }
    ]
}

Appeler d'autres taches

.vscode/tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build all",
            "dependsOn": [
                "build server",
                "build client"
            ],
            "group": "build",
            "problemMatcher": []
        },
        {
            "label": "build server",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/Server/Server.csproj",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "group": "build",
            "problemMatcher": "$msCompile"
        },
        {
            "label": "build client",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/Client/Client.csproj",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "group": "build",
            "problemMatcher": "$msCompile"
        }
    ]
}

Problem Matcher

dotnet tasks

tasks.json
{
    "label": "roslynator",
    "command": "roslynator",
    "type": "shell",
    "args": [
        "analyze",
        "--analyzer-assemblies",
        "~/.vscode/extensions/josefpihrt-vscode.roslynator-4.3.0/roslyn/common",
        "~/.vscode/extensions/josefpihrt-vscode.roslynator-4.3.0/roslyn/analyzers"
    ],
    "problemMatcher": [
        {
            "owner": "roslynator",
            "fileLocation": ["relative", "${workspaceFolder}"], // if it is run for a solution, it missed the project folder
            "pattern": [
                {
                    "regexp": "^(.+?)\\((\\d+),(\\d+)\\): (warning|error) (.+?): (.+?)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "code": 5,
                    "message": 6
                }
            ]
        }
    ]
},
{
    "label": "code style",
    "command": "dotnet",
    "type": "shell",
    "args": [
        "format",
        "--verify-no-changes"
    ],
    "problemMatcher": [
        {
            "owner": "dotnet",
            "fileLocation": "absolute",
            "pattern": [
                {
                    "regexp": "^(.+?)\\((\\d+),(\\d+)\\): (warning|error) (.+?): (.+?) \\[.+\\]$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "code": 5,
                    "message": 6
                }
            ]
        }
    ]
}

launch

.vscode/tasks.json
{
    "name": "Service .NET Core Launch (web)",
    "type": "coreclr",
    "request": "launch",
    "preLaunchTask": "build Service",
    "program": "${workspaceFolder}/Service/bin/Debug/netcoreapp3.1/Service.dll",
    "args": [],
    "cwd": "${workspaceFolder}/Service",
    "stopAtEntry": false,
    "serverReadyAction": {
        "action": "openExternally",
        "pattern": "^\\s*Now listening on:\\s+(https?://\\S+)",
        "uriFormat": "%s/swagger"
    },
    "env": {
        "ASPNETCORE_ENVIRONMENT": "Development"
    },
    "logging": {
        "engineLogging": true
    }
}

launch settings

Quand l’application est lancée avec dotnet run, launchSettings.json est lu s’il est disponible:

  • le premier profil avec "commandName": "Project" est utilisé
  • les paramètres environmentVariables remplacent les variables d’environnement
launchSettings.json
{
  "profiles": {
    "MyApp": {
      "commandName": "Project",
      "launchBrowser": true,
      "applicationUrl": "http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

SQL Server

  1. installer l'extension mssql
  2. nouvelle page → en bas à droite clique sur Plain Text → choisir SQL
  3. ou ouvrir un fichier *.sql
  4. F1MS SQL: Connect ou cliquer sur Disconnected en bas à droite → Create Connection Profile
  5. Ctrl + Shift + E exécuter du code

Markdown

Ctrl + Shift + V → preview

Replace

New line

To replace by a new line:

  • use Ctrl + Enter
  • or check .* (RegEx) and use \n

regex

Bash.svg
.* xxx (\w+).*
$1

Erreurs

The "Microsoft.AspNetCore.Razor.Tasks.DiscoverDefaultScopedCssItems" task could not be loaded

The "Microsoft.AspNetCore.Razor.Tasks.DiscoverDefaultScopedCssItems" task could not be loaded from the assembly /usr/share/dotnet/sdk/5.0.204/Sdks/Microsoft.NET.Sdk.Razor/build/netstandard2.0/../../tasks/net46/Microsoft.NET.Sdk.Razor.Tasks.dll.
Invalid Image Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

Create the folder /usr/share/dotnet/sdk/5.0.204/Sdks/Microsoft.NET.Sdk.Razor/tasks/net46 and copy the following files:

  • Microsoft.NET.Sdk.Razor.Tasks
  • System.Collections.Immutable
  • System.Reflection.Metadata

Error processing 'handshake' request. Unknown Error: 0x89720010

C# debugging doesn't start the application.
Microsoft .NET Core Debugger only works with Microsoft Visual Studio Code and not with Visual Studio Code OSS (link).

Visual Studio Code is unable to watch for file changes in this large workspace

Bash.svg
# Afficher le nombre max de fichiers qui peuvent être surveillés
cat /proc/sys/fs/inotify/max_user_watches

# Modifier temporairement le nombre max de fichiers qui peuvent être surveillés
echo 65536 > /proc/sys/fs/inotify/max_user_watches

# Modifier le nombre max de fichiers qui peuvent être surveillés (Archlinux)
echo fs.inotify.max_user_watches=524288 | sudo tee /etc/sysctl.d/40-max-user-watches.conf && sudo sysctl --system

Microsoft.Common.props was not found

Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "/usr/lib/mono/xbuild/15.0/Microsoft.Common.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.  /opt/dotnet/sdk/2.1.105/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.props

Installer MSBuild

Bash.svg
yaourt msbuild
# aur/msbuild-15-bin 15.5_xamarinxplat.2017.08.16.12.03_0xamarin3_ubuntu1404b1-3

msbuild /ver

The terminfo database is invalid

MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
System.InvalidOperationException: The terminfo database is invalid.
Bash.svg
TERM=xterm dotnet build
TERM=xterm dotnet run

echo $TERM  # xterm-256color

Installation

Visual studio code is a code editor redefined, available on Windows, Linux and OS X, optimized for building web and cloud applications.

Bash.svg
# Visual Studio Code open source distribution: code-oss
pacman -S code

# Microsoft's Visual Studio Code distribution
yay visual-studio-code-bin

Differences between the repository and Visual Studio Code

Extension C#

Installer l'extension C#:

  • Bouton extension: dernier bouton du menu latéral de gauche
  • Rechercher C#
Bash.svg
# installer .NET core sdk pour compiler des applications et ses dépendances
yaourt dotnet-sdk-2.0

OBSOLÈTE - Installing the .NET Core Debugger on Arch Linux

File → Preferences → Settings

Javascript.svg
{
    "csharp.fallbackDebuggerLinuxRuntimeId": "ubuntu.16.10-x64"
}
Bash.svg
# erreur Debug adapter process has terminated unexpectedly
yaourt icu57