Difference between building/running a .Net Core app using Visual Studio and CLI/VS Code - visual-studio

I'm trying to figure out the differences between running/building a .Net core project using Visual Studio and the CLI, i.e. what process does Visual Studio follow when running the project?
I spent half a day yesterday debugging an issue where a static web resource could not be found (404) when I ran the project (both F5 and Ctrl+F5) using Visual Studio - both Debug and Release configs using both IIS Express and Project launch options - only to discover that the problem does not occur when I run the exact same project using VS Code's debugger (F5 or Ctrl+F5) or the CLI (dotnet run) directly. And today I wasted yet another 3 hours when I received a new build error message when building using VS, but the same project built and ran 100% using the CLI and VS Code...
I have a clean development environment with only one SDK that was installed along with VS, so they are both using the same SDK.
Given, I am playing around with .net5.0, so I'm using the latest preview build of VS (Version 16.8.0 Preview 2.0), but as far as I'm concerned, there should not be ANY differences when running a project using VS and the CLI. Unfortunately I cannot replicate the same issue using the stable build since both the problems are related to .net5.0 features (Scoped Styles and Blazor WASM).
Could someone please enlighten me on the steps that VS takes when running a .Net Core Web project? I KNOW it is not simpy using dotnet run as one would expect, so I would like to get as much info before I log yet another tooling issue with the dotnet people...
Any reply would be appreciated.

Related

Visual Studio 2019 - Unable to debug Azure functions - (Desktop CLR (.NETFramework) versus Managed (CoreCLR)' debugger

I have installed the Visual Studio 2019 community version 16.4.4 on a brand new laptop
OS:- Windows 10 Home Single Language
The following are the .NET Core SDKS installed in my laptop
The command dotnet --info gave me the following details
I created a Azure function with V3 template
The project settings are given below
When I try to debug , i get the following error
A fatal error has occurred and debugging needs to be terminated. The debugger was configured to use the Desktop CLR (.NETFramework) Managed debugger, but the target process loaded the CoreCLR (.Net Core) runtime. To debug this project, configure it to use the 'Managed (CoreCLR)' debugger."
Tried several options like the one mentioned in the link below
https://social.msdn.microsoft.com/Forums/en-US/59f880f7-ed60-4842-bc55-a9400971c58b/problem-debugging-net-core?forum=vsdebug
EDIT: This has been fixed in the latest release of Visual Studio v16.4.5
The problem seems to be a mismatch in the version of the Azure Functions CLI. As a workaround, you can do this:
Install the latest Azure Functions CLI, from the command line run:
npm i -g azure-functions-core-tools#3 --unsafe-perm true
or if you are using Chocolatey:
choco install azure-functions-core-tools
Restart Visual Studio.
I still have this issue after reinstalling my VS2019, downloading the latest sdk and downloading the core tools multiple times. Seems like the only way for now is to run without using the debugger (Ctrl + F5). Sometimes I downgrade the function to v2.1 for this only happens on v3 functions.
Edit: I got this fixed when I updated my VS to 16.5.1
It looks like one similar issue which has been reported to DC forum. However it works well in my side with same 16.4.4 version. Since I didn't reproduce same issue, I can't provide a direct answer.
Here're some possible workarounds which may help:
Repair VS and go Tools=>Import and Export Settings=>Reset all settings=>No,just reset, overwrite... (Since my same version works well)
Hint from this one, you may backup the launchsettings.json in project and then delete it, rebuild and debug(F5) it again.
And if the issue persists, you can try installing .net core 3.0 sdk and recreate a new project to check if it helps.(I have both .net core 3.0 and 3.1 installed, but by default it picks .net core 3.0 when I create the project, not sure if it makes any difference.)
Hope it helps :)
Update:
Sorry for not noticing that the solution will not work for you. Since the solution doesn't work, you can choose another way. As the error says, you need to
configure it to use the 'Managed (CoreCLR)' debugger."
So, try to configure on hand, Select 'Debug' above the VS 2019 tab, then
Original Answer:
I faced exactly the same error before and solved it with below solution, it works well.
Solution:
Just enable the native code debuging.
Right click your project > properties > Debug. Tick ​​'enable the native code debugging' like this:
I have the same issue, I have upgraded visual studio 2019 to 16.4.4 and it resolved my issue. that was the bug by visual studio 2019 in 16.3 versions. please upgrade visual studio. it will definitely resolve your issue.
Issue was resolved with the next upgrade of Visual Studio 2019
Trying Install the v3.x Core Tools package from the command line run npm install -g azure-functions-core-tools#3.
Reference: Use npm to install Core Tools on Windows

.net core console application throws System.ExecutionEngineException

I have absolutely no idea what's going on. I create a new project of type .net core console application, hit run and get that exception:
System.ExecutionEngineException
Your app has entered a break state, but no code is currently executing
that is supported by the selected debug engine (e.g. only native
runtime code is executing).
It's quite a while ago when I last ran a .net core project on this machine.
More Information:
It happens only in visual studio. If I run the console via cmd everything works fine. Any idea how to find out what is causing this? I suspect maybe a visual studio extension like Roslynator is causing this exception.
After repairing Visual Studio everything works again.
I was using .net core 2.2 on visual studio 2017 when i had this error.
So I tried .net core 3.0 on visual studio 2019 preview.....
voila, it worked... can't explain it, i guess .net core is constantly improving to support legacy code

Develop an Azure Service Fabric Application with Visual Studio 2017 for Mac

my team is creating an Azure Service Fabric application using ASP.NET/Dotnet Core. Whenever I try to import the project into my Visual Studio 2017 for Mac I get the error
Error while trying to load the project '.../Project.sfproj: Unknown solution item type'
The solution contains several projects, some with a csproj (which I can open just fine), and some with a sfproj, that cause the problems. I can't even browse them in VS2017:
I can run msbuild from the shell (get some Compiler errors, but that's fine), but cannot manage to load the project into my IDE. I guess I'm missing the Service Fabric SDK, but that is not available for mac afaik. I managed to pull some jars from the vagrant image, as described here but that doesn't help me in a ASP.NET/Dotnet Core application.
Unfortunately, this feature is currently not available. If anyone wants it, vote for it on the visual studio user voice page.

Visual Studio Cordova App, can't run debugger - Could not locate the appxrecipe file

If I create a brand new Cordova project (JavaScript or TypeScript) and try to debug on Ripple or on the local machine I get an error during build that says "Could not locate the appxrecipe file."
I googled it and nothing comes up. What is this file and how does it get generated? Shouldn't it be generated when I create the project?
I've already lost an entire day to this, running repairs on visual studio and trying things that had no effect. Frustrating!
This took a while to figure out but it seems that the version of node.js that would get installed with Visual Studio was too old (0.10.x). When I installed the x64 version of node.js from the node website, it installed a 64 bit version which also wouldn't work with Cordova in Visual Studio.
The answer was to install the 32bit version of node.js (node-v5.1.0-x86.msi) available from their website. Now everything compiles correctly!
I was also stucked with the issue but my problem was little bit different. I wanted to build a project for Windows 10 Mobile platform.
It was really weird because everytime when I tried to build a project from CLI with ionic build windows, the build was successul. But it had been throwing the error about appxrecipe file while building with Visual Studio again and again.
Then I noticed that everytime I open a project in Visual Studio (2015, Community Edition) there is one change when you open your confix.xml file in Visual Studio editor - the change was that Windows Target Version was set to 8.1 again. I tried to change it to Windows 10 again, save it and build but the error was still there.
I have solved it with installation of Microsoft Emulator for Windows 10 Mobile and it works like a charm now. Maybe this information could be helpful for somebody...

VS 2010 Setup Project Requires .NET 4.0, but it is already installed

I have a VS 10 project using .Net 4.0 and I use lots of stuff that do require 4.0. I created a VS Setup project added the primary output from my project and built it. I then installed it and everything worked fine. A few days later I am ready to do a new build so I rebuild my project and then the setup project. Now when I run the msi it tells me that .Net Framework 4.0 is required.... I figured I screwed it up so I just create a new setup project, and that works fine. But again a few days later (restarted VS in there probably and maybe even the computer) I rebuild and get the error telling me that .Net 4.0 is required. I did it a few times just to verify and it consistently happens and I cannot figure out why.
The project I am building and installing has a windows service that is set as the startup project. I will switch that to a console app object for local testing purposes and build and test the project (not the setup project). This is the only thing I can think of that may be impacting the build, but again, I cannot figure out why.
Any help is appreciated.
This error message is thrown when the Launch Conditions in the Setup Project aren't met.
Go to View > Editor > Launch Conditions
Change the .Net Framework version value to
match the version your setup project
is compiled into. By default, the 2010 setup and deployment project condition is set to .NET 4.0 Client Profile.

Resources