How to handle "RunCommand property is not defined" issue?

AnonymousKKYY 20 Reputation points
2025-04-21T08:40:14.7033333+00:00

Here I have a .NET 6 ASP.NET project. When run IIS Express, it pops "RunCommand property is not defined".

User's image

User's image

Developer technologies | ASP.NET | ASP.NET API
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 78,086 Reputation points Volunteer Moderator
    2025-04-21T16:07:39.6333333+00:00

    an asp.net core application should be a console app, not a class library. also in the project file it should specify the web sdk:

    <Project Sdk="Microsoft.NET.Sdk.Web">
    
      <PropertyGroup>
        <TargetFramework>net6.0</TargetFramework>
        <Nullable>enable</Nullable>
        <ImplicitUsings>enable</ImplicitUsings>
      </PropertyGroup>
    
    </Project>
    
    0 comments No comments

  2. Jack Dang (WICLOUD CORPORATION) 375 Reputation points Microsoft External Staff
    2025-06-30T07:36:26.7333333+00:00

    Hi @AnonymousKKYY ,

    Based on your image, I think the root cause was that the project was incorrectly set up as a Class Library, rather than a Console Application or Web Application, which is required for ASP.NET Core apps to run properly.

    When you set the Output Type to Class Library, you're telling Visual Studio to build a DLL, not an executable. This has several implications:

    • Class Libraries cannot be executed directly—they are meant to be referenced by other projects.
    • ASP.NET Core applications require an entry point (like Program.cs with a Main method) to start the web server.
    • The RunCommand property is used by Visual Studio and IIS Express to determine how to launch the application. Since Class Libraries don’t have a RunCommand, the system throws an error.

    To resolve the issue:

    1. Change the Output Type to Console Application:

    In Solution Explorer, right-click on the project name > Properties > Application tab.

    Set Output type to Console Application.

    1. Ensure the correct SDK is used in your .csproj file:

    In Solution Explorer, right-click on the project name > Select "Edit Project File". > This opens the .csproj file directly in the editor.

    <Project Sdk="Microsoft.NET.Sdk.Web">
      <PropertyGroup>
        <TargetFramework>net6.0</TargetFramework>
        <Nullable>enable</Nullable>
        <ImplicitUsings>enable</ImplicitUsings>
      </PropertyGroup>
    </Project>
    

    Hope my solution would solve your issue.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.