[英]How do I access .env variables in tasks.json within vscode?
[英]VSCode tasks.json and launch.json for WinExe dependent on dll
我正在嘗試-為了學習-編寫tasks.json & launch.json for VSCode 來構建這個項目: ExportableDataGrid
有兩個.csproj - 一個構建一個“庫”,另一個構建一個依賴於庫的“WinExe”。
構建成功,但 Debugger 不啟動 .exe 並出現以下錯誤:
Error processing 'configurationDone' request. Unknown Error: 0x80131c30
使用此 cli:
dotnet build Mm.ExportableDataGrid\Mm.ExportableDataGrid.csproj
dotnet build Mm.ExportableDataGrid.Wpf\Mm.ExportableDataGrid.Wpf.csproj
我收到這些錯誤:
CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [C:\Users\userid\C-Sharp Projects\ExportableDataGrid\mm.exportabledatagrid.wpf\mm.exportabledatagrid.wpf.csf.csproj]
C:\Users\userid\C-Sharp Projects\ExportableDataGrid\mm.exportabledatagrid.wpf\MainWindow.xaml.cs(13,13): error CS0103: The name 'InitializeComponent' does not exist in the current context [C:\Users\userid\C-Sharp Projects\ExportableDataGrid\mm.exportabledatagrid.wpf\mm.exportabledatagrid.wpf.csproj]
C:\Users\userid\C-Sharp Projects\ExportableDataGrid\mm.exportabledatagrid.wpf\MainWindow.xaml.cs(52,13): error CS0103: The name 'dataGrid' does not exist in the current context [C:\Users\userid\C-Sharp Prp Projects\ExportableDataGrid\mm.exportabledatagrid.wpf\mm.exportabledatagrid.wpf.csproj]
launch.json 和 tasks.json 都位於包含 github 存檔中的兩個文件夾的根文件夾中。
發射.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Custom .NET Launcher",
"type": "clr",
"request": "launch",
"preLaunchTask": "buildExe",
"program": "${workspaceFolder}/Mm.ExportableDataGrid.Wpf/bin/Debug/Mm.ExportableDataGrid.Wpf.exe",
"args": [],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": false
}
]
}
任務.json
{
"version": "2.0.0",
"tasks": [
{
"label":"buildDll",
"type":"shell",
"command":"C:/\"Program Files (x86)/\"Microsoft Visual Studio\"/2019/BuildTools/MSBuild/Current/Bin/MSBuild.exe",
"presentation":{
"clear":true
},
"args":[
"Mm.ExportableDataGrid\\Mm.ExportableDataGrid.csproj",
"/t:Build",
"/p:Configuration=Debug",
"/p:Platform=\"AnyCPU\""
]
},
{
"label":"buildExe",
"type":"shell",
"command":"C:/\"Program Files (x86)/\"Microsoft Visual Studio\"/2019/BuildTools/MSBuild/Current/Bin/MSBuild.exe",
"presentation":{
"clear":true
},
"dependsOn":"buildDll",
"args":[
"Mm.ExportableDataGrid.Wpf\\Mm.ExportableDataGrid.Wpf.csproj",
"/t:Build",
"/p:Configuration=Debug",
"/p:Platform=\"AnyCPU\""
]
}
]
}
盡管閱讀很多,但我無法弄清楚這里發生了什么。
另外 - 我能夠在沒有調試的情況下運行,沒有問題。 似乎是附加調試器的問題。
在遇到問題數周后,我才發現了這個問題。
解決方法是創建一個指定“x64”的“My_Project.runsettings”文件並在 settings.json 中使用“omnisharp.testRunSettings”:“Path_To_My_File\My_Project.runsettings”來引用它
詳細解釋請看我在github上的回答: https://github.com/OmniSharp/omnisharp-vscode/issues/4361#issuecomment-858540496
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.