Cant run "build" task because "The preLaunchTask 'build' terminated with exit code -2."
I've narrowed it down to the following The terminal shell path "dotnet" is a directory. Changing the build task to have a direct path to the dotnet executable works.
Before (Error)
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/ProcessedSaleWatcherService.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
After (Works)
{
"label": "build",
"command": "/home/ethanpreker/.dotnet/dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/ProcessedSaleWatcherService.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
Install dotnet sdk 3.0 on linux using dotnet-install.sh script.
./dotnet-install.sh -Channel Current
Add path to .bashrc or .zshrc
export PATH=$PATH:/home/ethanpreker/.dotnet
Run build task in vscode (ctrl + shift + B)
The project will build correctly
> Executing task: dotnet build /home/ethanpreker/Repos/ProcessedSaleWatcherService/ProcessedSaleWatcherService.csproj /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary <
The terminal shell path "dotnet" is a directory
Terminal will be reused by tasks, press any key to close it.
Starting OmniSharp server at 10/15/2019, 9:22:25 AM
Target: /home/ethanpreker/Repos/ProcessedSaleWatcherService
OmniSharp server started with Mono 6.0.0.
Path: /home/ethanpreker/.vscode/extensions/ms-vscode.csharp-1.21.4/.omnisharp/1.34.4/omnisharp/OmniSharp.exe
PID: 6056
Starting OmniSharp on manjaro 0.0 (x64)
DotNetPath set to dotnet
It looks like you have Mono 5.2.0 or greater installed but MSBuild could not be found.
Try installing MSBuild into Mono (e.g. 'sudo apt-get install msbuild') to enable better MSBuild support.
Located 1 MSBuild instance(s)
1: StandAlone 16.0 - "/home/ethanpreker/.vscode/extensions/ms-vscode.csharp-1.21.4/.omnisharp/1.34.4/omnisharp/.msbuild/Current/Bin"
MSBUILD_EXE_PATH environment variable set to '/home/ethanpreker/.vscode/extensions/ms-vscode.csharp-1.21.4/.omnisharp/1.34.4/omnisharp/.msbuild/Current/Bin/MSBuild.dll'
Registered MSBuild instance: StandAlone 16.0 - "/home/ethanpreker/.vscode/extensions/ms-vscode.csharp-1.21.4/.omnisharp/1.34.4/omnisharp/.msbuild/Current/Bin"
CscToolExe = csc.exe
TargetFrameworkRootPath = /usr/lib/mono/xbuild-frameworks
MSBuildToolsPath = /home/ethanpreker/.vscode/extensions/ms-vscode.csharp-1.21.4/.omnisharp/1.34.4/omnisharp/.msbuild/Current/Bin
CscToolPath = /home/ethanpreker/.vscode/extensions/ms-vscode.csharp-1.21.4/.omnisharp/1.34.4/omnisharp/.msbuild/Current/Bin/Roslyn
BypassFrameworkInstallChecks = true
MSBuildExtensionsPath = /usr/lib/mono/xbuild
Detecting Cake files in '/home/ethanpreker/Repos/ProcessedSaleWatcherService'.
Could not find any Cake files
No solution files found in '/home/ethanpreker/Repos/ProcessedSaleWatcherService'
Queue project update for '/home/ethanpreker/Repos/ProcessedSaleWatcherService/ProcessedSaleWatcherService.csproj'
Detecting CSX files in '/home/ethanpreker/Repos/ProcessedSaleWatcherService'.
Could not find any CSX files
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.EditorConfigWorkspaceOptionsProvider, Order: 200
Configuration finished.
Omnisharp server running using Stdio at location '/home/ethanpreker/Repos/ProcessedSaleWatcherService' on host 5630.
Loading project: /home/ethanpreker/Repos/ProcessedSaleWatcherService/ProcessedSaleWatcherService.csproj
Successfully loaded project file '/home/ethanpreker/Repos/ProcessedSaleWatcherService/ProcessedSaleWatcherService.csproj'.
Adding project '/home/ethanpreker/Repos/ProcessedSaleWatcherService/ProcessedSaleWatcherService.csproj'
Update project: ProcessedSaleWatcherService
Queue project update for '/home/ethanpreker/Repos/ProcessedSaleWatcherService/ProcessedSaleWatcherService.csproj'
Queue project update for '/home/ethanpreker/Repos/ProcessedSaleWatcherService/ProcessedSaleWatcherService.csproj'
Queue project update for '/home/ethanpreker/Repos/ProcessedSaleWatcherService/ProcessedSaleWatcherService.csproj'
Queue project update for '/home/ethanpreker/Repos/ProcessedSaleWatcherService/ProcessedSaleWatcherService.csproj'
Loading project: /home/ethanpreker/Repos/ProcessedSaleWatcherService/ProcessedSaleWatcherService.csproj
Package 'System.Net.Http.Formatting.Extension 5.2.3' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.0'. This package may not be fully compatible with your project.
Successfully loaded project file '/home/ethanpreker/Repos/ProcessedSaleWatcherService/ProcessedSaleWatcherService.csproj'.
/home/ethanpreker/Repos/ProcessedSaleWatcherService/ProcessedSaleWatcherService.csproj
/home/ethanpreker/Repos/ProcessedSaleWatcherService/ProcessedSaleWatcherService.csproj(0,0): Error: Package 'System.Net.Http.Formatting.Extension 5.2.3' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.0'. This package may not be fully compatible with your project.
Update project: ProcessedSaleWatcherService
VSCode version: 1.38.1
C# Extension: 1.21.4
Mono Information
OmniSharp using global mono :6.0.0
Dotnet Information
.NET Core SDK (reflecting any global.json):
Version: 3.0.100
Commit: 04339c3a26
Runtime Environment:
OS Name: manjaro
OS Version:
OS Platform: Linux
RID: linux-x64
Base Path: /home/ethanpreker/.dotnet/sdk/3.0.100/
Host (useful for support):
Version: 3.0.0
Commit: 7d57652f33
.NET Core SDKs installed:
2.2.108 [/home/ethanpreker/.dotnet/sdk]
3.0.100 [/home/ethanpreker/.dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.6 [/home/ethanpreker/.dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.6 [/home/ethanpreker/.dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0 [/home/ethanpreker/.dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.6 [/home/ethanpreker/.dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0 [/home/ethanpreker/.dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
Visual Studio Code Extensions
|Extension|Author|Version|
|---|---|---|
|Angular-BeastCode|Mikael|8.0.10|
|Angular2|johnpapa|8.1.1|
|angular2-inline|natewallace|0.0.17|
|angular2-switcher|infinity1207|0.2.0|
|auto-close-tag|formulahendry|0.5.6|
|autoimport|steoates|1.5.3|
|azure-account|ms-vscode|0.8.4|
|azure-pipelines|ms-azure-devops|1.157.4|
|Bookmarks|alefragnani|10.5.0|
|bracket-pair-colorizer|CoenraadS|1.0.61|
|bracket-pair-colorizer-2|CoenraadS|0.0.28|
|code-d|webfreak|0.20.2|
|code-gnu-global|austin|0.2.2|
|code-settings-sync|Shan|3.4.3|
|cpptools|ms-vscode|0.25.1|
|csharp|ms-vscode|1.21.4|
|csharp2ts|rafaelsalguero|0.0.22|
|csharpextensions|jchannon|1.3.0|
|dark-plus-material|vangware|2.1.0|
|debug|webfreak|0.23.1|
|debugger-for-chrome|msjsdiag|4.12.0|
|deepdark-material|Nimda|3.2.0|
|dlang-bundle|webfreak|0.4.0|
|dotenv|mikestead|1.0.1|
|EditorConfig|EditorConfig|0.13.0|
|electron|kuscamara|0.2.5|
|gc-excelviewer|GrapeCity|2.1.32|
|gitblame|waderyan|3.0.1|
|gitlab-workflow|fatihacet|2.1.1|
|gitlens|eamodio|10.0.1|
|html-css-class-completion|Zignd|1.19.0|
|html-snippets|abusaidm|0.2.1|
|JavaScriptSnippets|xabikos|1.7.2|
|Kotlin|mathiasfrohlich|1.7.0|
|latex-workshop|James-Yu|8.1.1|
|material-icon-theme|PKief|3.9.0|
|material-palenight-theme|whizkydee|1.9.6|
|mssql|ms-mssql|1.6.0|
|npm-intellisense|christian-kohler|1.3.0|
|nsis|idleberg|3.19.0|
|path-intellisense|christian-kohler|1.4.2|
|pdf|tomoki1207|0.5.1|
|plastic|will-stone|2.4.0|
|powershell|ms-vscode|2019.9.0|
|prettier-vscode|esbenp|2.2.2|
|printcode|nobuhito|3.0.0|
|propertylist|zhouronghui|0.0.2|
|python|ms-python|2019.9.34911|
|quicktype|quicktype|12.0.46|
|quokka-vscode|WallabyJs|1.0.253|
|scala|scala-lang|0.3.8|
|shell-launcher|Tyriar|0.3.0|
|stardog-rdf-grammars|stardog-union|0.1.2|
|theme-dracula|dracula-theme|2.18.0|
|theme-material-theme|jprestidge|1.0.1|
|theme-onedark|azemoh|0.5.2|
|typescript-hero|rbbit|3.0.0|
|vetur|octref|0.22.3|
|vsc-material-theme|Equinusocio|30.0.0|
|vscode-azureappservice|ms-azuretools|0.15.0|
|vscode-csharp-snippets|jorgeserrano|0.3.1|
|vscode-docker|ms-azuretools|0.8.1|
|vscode-eslint|dbaeumer|1.9.1|
|vscode-exec-node|miramac|0.5.1|
|vscode-firefox-debug|firefox-devtools|2.3.1|
|vscode-html-css|ecmel|0.2.3|
|vscode-icons|vscode-icons-team|9.4.0|
|vscode-import-cost|wix|2.12.0|
|vscode-npm-script|eg2|0.3.9|
|vscode-scss|mrmlnc|0.6.2|
|vscode-simple-icons|LaurentTreguier|1.11.10|
|vscode-test-explorer|hbenl|2.14.6|
|vscode-theme-onedark|akamud|2.1.0|
|vscode-typescript-tslint-plugin|ms-vscode|1.2.2|
|vscode-versionlens|pflannery|0.24.0|
|vscode-wakatime|WakaTime|2.2.0|
|vsliveshare|ms-vsliveshare|1.0.869|
|vue-snippets|hollowtree|0.1.11|
|Vue2|ducksoupdev|0.1.3|
|xml|DotJoshJohnson|2.5.0|;
Hi @abaga129,
Sorry you ran into this. It seems you were able to fix this by making sure dotnet was on your path, which is what we expect.
-Joey
It's not exactly fixed. I have to change my tasks to have a hardcoded path to the dotnet binary e.g. "command": "/home/ethanpreker/.dotnet/dotnet". This would be okay except that when someone else pulls my code and tries to run it, they wont have dotnet at the same path. Is there some way I make it work with "command": "dotnet",?
Thanks for your time
I agree, this is _not_ fixed and should not be closed! Every time I create a project, I have to go in and hardcode the path to the dotnet executable.
Further, if I use F5 to build the project, I get this error message, but if I open a terminal and use
dotnet build
it works fine.
The true error is that the tasks.json file is being built with "type": "process" rather than "type": "shell" https://github.com/microsoft/vscode/issues/79346 gets this wrong, too, but I can't comment on that. Thanks to https://stackoverflow.com/a/58486984/334719
Thanks @auspex! That did the trick for me as well! I guess now this issue can be closed sarcasm
The true error is that the
tasks.jsonfile is being built with"type": "process"rather than"type": "shell"microsoft/vscode#79346 gets this wrong, too, but I can't comment on that. Thanks to https://stackoverflow.com/a/58486984/334719
Just wanted to mention that in my case changing process to shell actually made it work error-free. I didn't have to change anything else in the tasks.json file.
Most helpful comment
The true error is that the
tasks.jsonfile is being built with"type": "process"rather than"type": "shell"https://github.com/microsoft/vscode/issues/79346 gets this wrong, too, but I can't comment on that. Thanks to https://stackoverflow.com/a/58486984/334719