Search code examples
c#visual-studio-mac

Visual Studio 2017 for Mac failing simple new project. How to fix?


Using the botnet command:

dotnet new console -o myApp

cd myApp

then,

donet run

I get:

 Hello World!

as I should! However, When I open Visual Studio 2017 Community Edition for Mac and add the myApp project and click 'Run Item', I get: Console output from Visual Studio Build

The other projects in the solution work fine and they are also console apps. Here is the project file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>

</Project>

I have recreated the project in Visual Studio and get the same behavior. The various things I've read online are very obscure. None of the words in the warning and error mean anything and the "make sure the same settings..." without telling what is meant is meaningless. I've looked at the dotnet-runtime... and again, meaningless. It's talking about deploying applications. Why would creating a new project for Hello World behave like this? What to do to solve the problem?


Solution

  • try adding this

    <PropertyGroup>
        <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
    </PropertyGroup>
    

    If this does not works, then

     <PropertyGroup>
       <RuntimeFrameworkVersion>2.2.0</RuntimeFrameworkVersion>
       <PlatformTarget>AnyCPU</PlatformTarget>
       <RuntimeIdentifier>osx-x64</RuntimeIdentifier>
     </PropertyGroup>