29

I'm using Microsoft Visual Studio Community 2017. I have created a project with multiple classes. The primary class I want the application to run first has public static void Main(string[] args) in it.

I've set properties to the following:

  • Target Framework: .NET standard 2.0
  • Output type: Console Application
  • Startup object: Main.Game

The error persists despite all the forums I have visited.

Shawn J. Molloy
  • 2,457
  • 5
  • 41
  • 59
Cole Connelly
  • 333
  • 1
  • 3
  • 7

6 Answers6

39

I was facing this issue in my Visual Studio 2017 15.7.2 version. The cause for this issue in my case was, unknowingly I had changed my Asp.Net Core 2.1 Web API project output type to Class Library. Changing it back to Windows Application fixed my issue.

enter image description here

Shawn J. Molloy
  • 2,457
  • 5
  • 41
  • 59
Sibeesh Venu
  • 18,755
  • 12
  • 103
  • 140
2

Unfortunately, Microsoft has this issue open (https://github.com/dotnet/sdk/issues/833) for a long time, but has provided no answer.

Ricardo Peres
  • 13,724
  • 5
  • 57
  • 74
2

Try changing from netstandard2.0 to netcoreapp2.0 for Target Framework property.

Shawn J. Molloy
  • 2,457
  • 5
  • 41
  • 59
ForcedFakeLaugh
  • 567
  • 1
  • 9
  • 20
2

From here

Try adding the following to you <PropertyGroup>:

<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<RunCommand>$(MSBuildExtensionsPath64)\..\IIS Express\iisexpress</RunCommand>
<RunArguments>/path:&quot;$(MSBuildProjectDirectory)&quot; /port:18082</RunArguments>
KennetsuR
  • 704
  • 8
  • 17
1

My Solution contain more than one projects : Client(Angular) project, Server(API) side project and other project. In solution, "Single startup project", its set to Client(Angular) project, which cause issue.

I have updated and set Server side(API) project as "Single startup project". Rebuild solution and error "RunCommand" property is not defined"resolved.

Select Solution > Property > this setting screen available. enter image description here

Avnish Patel
  • 123
  • 1
  • 3
  • 11
0

It's usual in Visual Studio.

You have to do 3 things to solve this. In some cases one is enough but sometimes three of them is required.

  1. Open proj.csproj file in the root of the project (if you see no files, try to use ctrl+F to search the solution and find it)

    Try to add this <Project Sdk="Microsoft.NET.Sdk.web">

  2. Open your project and right-click on the project main root and go properties then from the right block select application and the from the white box there select output type to class library.

  3. Try to clean and build the entire solution again.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
behza_d
  • 15
  • 3