Running dotnet run from terminal Mac M1 .net SDK - c#

I am running Visual Studio 2019 on a MacBook Air M1 and I have installed and downloaded the .NET Core SDK. When I am trying to run an asp.net solution from the terminal with the 'dotnet run' command I get the following message:
Failed to load /opt/homebrew/Cellar/dotnet/6.0.103/libexec/host/fxr/6.0.3/libhostfxr.dylib, error: dlopen(/opt/homebrew/Cellar/dotnet/6.0.103/libexec/host/fxr/6.0.3/libhostfxr.dylib, 0x0001): tried: '/opt/homebrew/Cellar/dotnet/6.0.103/libexec/host/fxr/6.0.3/libhostfxr.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
The library libhostfxr.dylib was found, but loading it from /opt/homebrew/Cellar/dotnet/6.0.103/libexec/host/fxr/6.0.3/libhostfxr.dylib failed
Installing .NET prerequisites might help resolve this problem.
I have installed and downloaded both the .net SDK for 3.1, 5.0 and 6.0. The solution runs fine from the play button in Visual Studio, but it will not work with the command.
I am just wondering if anyone knows if there is a workaround on this?
Thanks in advance!

Related

Debug is not working in ASPNET 7.0.100-preview7 when dotnet 6 is installed

I can run dotnet watch and I can Run my ASP.NET core application, but if I try debugging, I get the error message below. I have .NET 7 sdk installed (otherwise dotnet watch and Run in my app wouldn't work either)
/home/timmy/Repos/myaspnetapp/src/Application/bin/Debug/net7.0/Application
You must install or update .NET to run this application.
App: /home/timmy/Repos/myaspnetapp/src/Application/bin/Debug/net7.0/BlazorDebugProxy/BrowserDebugHost.dll
Architecture: x64
Framework: 'Microsoft.AspNetCore.App', version '7.0.0-preview.5.22303.8' (x64)
.NET location: /usr/lib/dotnet/dotnet6-6.0.108/
The following frameworks were found:
6.0.8 at [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.AspNetCore.App]
Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed
More info
I am running this on Ubuntu 22.04 and Rider 2022.2.1, but it seems VS Code has the same issue so I think it's a dotnet issue.
I have dotnet6 installed in /usr/lib/dotnet, subfolder dotnet6-6.0.108
I've had dotnet7 in multiple different folders to see if that would make any difference
In Rider the Toolset and Build path for .NET CLI executable path is /usr/lib/dotnet/dotnet7-7.0.100/dotnet and the MSBuild path is that same folder but sdk subdirectory
It's worth noting that debugging a .NET 7 console project works fine, but not ASP.NET core.
I may uninstall .NET 6 to see if that would help but my hopes are a bit low after wasting hours trying to get this to work. Any help would be appreciated.

Cannot build .NET Framework web app targeting 4.7.2 with VS 2022 installed on a docker container

I can't successfully build basic ASP.NET web app targeting framework 4.7.2.
I built a docker image with a base image for Windows Server Core 2019. On this image I installed VS 2022 Enterprise and took Azure development, .NET desktop development, ASP.NET and web development modules, including recommended ones.
For dotnet core solutions everything works fine, but for dotnet framework I am getting such errors:
packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props(31,5): Error MSB3758: An error has occurred during compilation. error CS0014: Required file 'alink.dll' could not be found
packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props(31,5): Error MSB4175: The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Microsoft.Build.Tasks.Core.dll". The task factory must return a value for the "TaskType" property.
I additionally installed .NET Frameworks: 4.5, 4.6, 4.6.1, 4.7.1, 4.8, but it didn't help.
Locally, I am able to build it without any problems. I checked the image if VS 2022 was installed without any issues and it looks fine as well. All environment variables are also in place. I thought the issue was related with some missing .NET Frameworks with SDKs, but it still persists.
Installing Redistributable C++ 2012-2022 didn't help as well. I am using MSBuild 17.
What I still might be missing?
I want to create an agent for Azure DevOps and as a reference I use the Dockerfile from Microsoft documentation. One difference is that before the start script, I run my custom script to silently install the VS 2022 with the modules I specified earlier.
I use Azure DevOps pipelines to build the solution, and the VSBuild#1 task.
I was finally able to solve the problem I had. It turned out that the base windows server core image didn't contain all of the needed prerequisites nor Visual Studio. Solution was to use extended windows server core image with sdk 4.8. This is strange, because Visual Studio already delivers everything for sdk 4.8. I think the extended image must have had something else that didn't come with the VS installation.

Dotnet commands not working even after installing .NET core SDK

I am trying to setup visual studio code for c# on Manjaro Linux
I have installed VSC and .NET core 5.0 SDK through the package manager.
The c# add-on is installed in VSC
With all of these installed correctly, why can't I use the dotnet command in the terminal?
Every time I try I get this error; sh: dotnet: command not found
By default, dotnet is installed to usr/share/dotnet. Check if this path is added to the env var $PATH.
If you can't find it there, you could run on a terminal:
whereis dotnet
If no dotnet is found, the tool wasn't properly installed.
Also, did you close and reopen the terminal window after installing the SDK, as the instructions stated?

Issues "getting started" with Blazor

I'm trying to "get started" with Blazorfollowing Microsoft's guidelines,
I've installed the .NET Core 3.0 Preview SDK as indicated,
but then I try to run the command
dotnet new -i Microsoft.AspNetCore.Blazor.Templates::3.0.0-preview5-19227-01
respectively from terminal and powershell both as admin and not,
getting this error:
Did you mean to run dotnet SDK commands? Please install dotnet SDK from:...
I proceeded anyway installing Visual Studio Preview (with Blazor Extension)
to be able to run the command form the Visual studio terminal,
but I'm simply getting this error:
Command "dotnet" is not valid.
Looks like doesn't recognize the installed SDK (3.0 or previous),
any idea how can I solve the issue? thanks in advance
I imagine if you've got multiple of the same executable in your path then it can't resolve which one you're trying to call.
Try manually using the full path to the .NET Core 3.0 SDK dotnet.exe in a command line e.g.
"C:\Program Files\dotnet\dotnet.exe" new -i Microsoft.AspNetCore.Blazor.Templates::3.0.0-preview5-19227-01 (you can use dotnet --version to find the version of the exe if you're unsure which is which)

Build missing SDK

I'm using Teamcity to run a build, getting the following error:
"Could not find "LC.exe"
Make sure the Microsoft Windows SDK is installed
(Registry key:..\Microsoft SDKs\NETFXSDK\4.6\WinSDK-NetFx40Tools-x86")"
Tried installing SDK from: https://www.microsoft.com/en-us/download/details.aspx?id=34860, didnt work.
Teamcity Version: 9.1.1,
Windows server 2012
I have .net 4.6.1 installed on the server. I do not want to install VS2010 as it is build agent. Please suggest.
Thanks.

Categories

Resources