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. Jack Dang (WICLOUD CORPORATION) 7,110 Reputation points Microsoft External Staff Moderator
    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.

    1 person found this answer helpful.

  2. Bruce (SqlWork.com) 82,311 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

Your answer

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