Is VSC not compatible with .net core 2 projects? - asp.net-core

Environment: Ubuntu 16.04, .NET Core SDK Preview 2.0.0 (006497), VSC 1.14.2
Things used to work fine under .net core 1. Now, I have upgraded my system to .net core 2.
From the command line, I created a new project and ran it:
$ dotnet new mvc
$ dotnet run
The webpage works as expected.
Now, I open the folder in VSC and tried to debug the app. First time, VCS helps create launch.json and tasks.json. Here is my tasks.json contents:
"version": "2.0.0",
"tasks": [
{
"taskName": "build",
"command": "dotnet",
"type": "shell",
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
}
]
}
In the terminal view, I see that VCS tries to run the build command as dotnet <. This throws an error that preLaunchTask "build" exited with error code 129.
I tried to fix this by adding args: ["build"] to the task. This seems to fix the build but I now get another error about launch.json not being configured properly.
Wondering if there is some step that I simply missed. Regards.

The answer was provided by mvermef in his comment. I am just adding a new post here so I can mark it as an answer.
The problems with VSC are explained at https://github.com/dotnet/core/blob/master/release-notes/2.0/2.0.0-preview2-known-issues.md. The most important thing is that you remove your existing C# extension and replace it with the latest beta version. Now, if you create a new project from the command line and load it in VSC, you should be able to debug it.

Related

VScode: Kotlin plugin autocomplete not working

Today I first started programming with Kotlin in VScode. I installed the Kotlin plugin (which as I understood this plugin should provide autocomplete feature), but strangely when I start writing code, the autocompletion doesn't work.
This is in continuation of another problem I faced today with the above plugin that presented an error described here, that after taking the steps suggested here the error disappeared and it seems to be resolved.
But still when I write code I don't get autocompletion.
I also saw on the plugin page (in the Debugging §Setup section) the following instruction:
Open the launch.json file in your project and invoke code completion to create a new launch configuration (or select Add Configuration... in the debug tab)
I don't know if this is what should solve my problem, anyway, this is my launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch kotlin script",
"type": "kotlin",
"projectRoot": "${workspaceFolder}",
"mainClass": "${workspaceFolder}/MainKt.main",
"request": "launch",
}
]
}
If there is a special configuration that needs to be set in launch.json, then I don't know what exactly needs to be there for it to work.

Lauching dotnet fails ("dotnet" is not a file of a symlink)

The default vscode configuration for debugging ASP.NET core contains the following:
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
...
The preLaunchTask fails for me with the following error:
The terminal process failed to launch: Path to shell executable "dotnet" is not a file of a symlink.
I have had this problem before, not on the preLaunchTask but on the main program execution. That I could work around by doing a replace all "dotnet" -> "/usr/bin/dotnet" in ~/.vscode/extensions/ms-dotnettools.csharp-1.**.*/dist/extensions.js + a vscode restart. However, this workaround doesn't work for the preLaunchTask. (And having to do this for every update of that extension in annoying).
Given that I'm a linux noob, it's probably not omnisharp/vscode related but could be something I did wrong in Ubuntu 18.04.
Does anybody know what the error means, and how to fix it? Or even how to debug this problem?
I've already reinstalled vscode, .net5, and my global $PATH env does contain /home/<username>/.dotnet/tools:/usr/bin/dotnet. Other than that I don't know what to do.
in tasks.json file change from
"type": "process" to "type": "shell"

error: no browser selected to run against, but i mentioned it in .testcafe.json

I have created .testcaferc.json, I mentioned the browser and src in it. so I should be able to run tests without putting this in the command line.
But it does not seem to be reading my config file from the project folder.
{
"src": "c:/Testcafe/Login.js",
"browsers": "firefox",
"reporter": {
"name": "html",
"output": "reports/report.html"
},
"takeScreenshotsOnFails": true,
"screenshotPath": "/screenshots/"
}
Actual:
Using locally installed version of TestCafe.
ERROR No browser selected to test against.
Type "testcafe -h" for help.
Expected:
I should not ask for browser and test file parameter as both are provided in config file.
The configuration file is a feature added in v1.0.0. If you upgrade from 0.20.5 to 1.0.0 or later, you will be able to use the configuration file for your tests.
Release Notes:
https://github.com/DevExpress/testcafe/releases/tag/v1.0.0

Aurelia CLI Run Command in ASP.NET Core Project Producing Only CannotGET

I have created a new ASP.NET Core Web API project and then run the au new --here command selecting option 2 (ASP.NET Core Project) to create a starting point for a web application.
Next I updated the Startup.cs file to serve static files.
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseFileServer();
Finally I updated the aurelia.json file to build into the wwwroot folder.
"platform": {
"id": "aspnetcore",
"displayName": "ASP.NET Core",
"output": "wwwroot/scripts",
"index": "wwwroot/index.html",
"baseUrl": "scripts"
},
"build": {
"targets": [
{
"id": "aspnetcore",
"displayName": "ASP.NET Core",
"output": "wwwroot/scripts",
"index": "wwwroot/index.html",
"baseUrl": "scripts"
}
],
The Aurelia CLI will run the build option (au build) and the run option (au run) fine and it will serve up the site on http://localhost:9000. But I get only the following HTML served up:
<html><head></head><body>CannotGET /</body></html>
or if trying to reference http://localhost:9000/index.html
<html><head></head><body>CannotGET /index.html</body></html>
If I run the application through Visual Studio and IIS Express it works fine.
What am I missing to get au run to work?
I have the same result with ASP.NET Core 1.0, 1.1 and in Visual Studio 2015 and Visual Studio 2017. If I use au new without the --here and no ASP.NET Core integration au run will work just fine.
I found the answer buried in an issue on GitHub: https://github.com/aurelia/cli/issues/405
The run.js file need to also have the path updated.
baseDir: ['./wwwroot'],

Can't create a migration with EF Core 1.1

I've spent two whole days trying to create an initial migration for the database of my project. This is so fustrating. Each preview version of the docs points towards different directions, and there're a lot of unclosed issues flying arround for a while.
My project is an AspNetCore application running on the full framework (net462) although I think I've tryed every combination of preview versions, even the workarounds proposed on this issue: EF Tools 1.1.0-preview4 Unrecognized option '--config' or in this one: https://github.com/aspnet/EntityFramework/issues/7083 but neither work.
This is an abstract of my project.json with the relevant parts:
{
"version": "1.0.0-*",
"buildOptions": {
"platform": "x86",
"debugType": "full",
"preserveCompilationContext": true,
"emitEntryPoint": true
},
"dependencies": {
....
"Microsoft.EntityFrameworkCore": "1.1.0",
"Microsoft.EntityFrameworkCore.Design": "1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0",
....
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final"
},
"frameworks": {
"net462": {
}
},
...
}
In my case the proposed workarounds don't work, neither using the nightly builds nor downgrading the tools to 1.0.0-preview3.
If I use the 1.1.0-preview4-final version of the tools I hit this error:
Unrecognized option --config
If I use the nightly builds I get this one, wich is somehow absurd, as my app has only one project and is not a dll (it has also emitEntryPoint:true set)
Could not load assembly 'Sales'. Ensure it is referenced by the startup project 'Sales'
But this is my favourite one, when I downgrade to the 1.0.0-preview3-final of the tools I get this surrealistic one:
error: Package Microsoft.EntityFrameworkCore.Tools.DotNet 1.0.0-preview3-final is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Microsoft.EntityFrameworkCore.Tools.DotNet 1.0.0-preview3-final supports: netcoreapp1.0 (.NETCoreApp,Version=v1.0)
I had to read it five times to get sure that in the second sentence was telling just the opposite of the first one... It seems a joke!
Furthermore, commands are not working on the PMC anymore, no matter wich version of the tools I install, no matter if I restore the packages and if I restart the computer...
I'm getting crazy with so many versions of everything and I only want to create a migration, it doesn't matter wich version of the tools I have to use... Is there a valid configuration nowadays or am I trying something imposible?
Has anybody been able to create migrations within an asp.net core application targeting the full .net framework (net462) with ANY version of the ef tooling?
If so, HOW?
EDIT:
After targeting the project to .netcoreapp1.0 and removing the incompatible references now I hit this error:
A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App\1.0.1'
What's happening here??? I'm really tired of .net Core, and it's still in it's first version. I've suffered a lot of issues like this while it was in beta, but now things are supposed to be stable... They have changed twenty times everything that can be changed, APIs, assembly names, namespaces, package names, conventions... Now let's wait for the preview5, 6 or 25 of the tooling and maybe by the year 2035 EF Core will have appropiate tools and procedures, meanwhile I damn a million time my decission of betting for this technology!
EDIT 2:
As per comments global.json may be relevant:
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-1-003177"
}
}
and to add that the 1.0.0-preview2-1-003177 folder exists and is the only one in C:\Program Files (x86)\dotnet\sdk\ and C:\Program Files\dotnet\sdk\
I hate to answer my own question, but I suppose that not too much people will go into this alley... So for those who are struggling with a similar problem I'll tell that mine came from this configuration on project.json:
...
"buildOptions": {
"platform": "x86", <- THIS!!!
"debugType": "portable",
"preserveCompilationContext": true,
"emitEntryPoint": true
},
after removing the "platform" key, migrations started to work again...
I'm not really sure when did I introduced that setting, since I didn't try to create migrations before upgrading to the version 1.1 of the .NET Core SDK. Maybe it was copied from one of the examples on internet, maybe it was from a previous version, I don't know, but that has turned me crazy for days, I hope it helps somebody outthere.