aspnet / Tooling

Issue tracker and info on Visual Studio tooling for ASP.NET
Other
256 stars 123 forks source link

Project configured to run with IIS instead runs with dotnet.exe #815

Open shaunluttin opened 7 years ago

shaunluttin commented 7 years ago

I have two xprojs in the same solution. When I run one, it runs with IIS Express as expected. When I run the other, it runs from the command line, which is unexpected. I've checked the launchSettings.json, and it seems to be the same for both.

This is the one that works as expected.

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:5909/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "WebApplication1": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

This is the one that does not work as expected.

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:5909/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "WebApplication1": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}
davidfowl commented 7 years ago

When you look at the "play" button in visual studio, what does it say for the project that runs dotnet.exe?

shaunluttin commented 7 years ago

I'm afraid I lack such a button. In which toolbar does it exist?

When I start debugging, though, I see this:

Process: [2880] dotnet.exe
kellypleahy commented 7 years ago

I think he means the "Start" button.

image

shaunluttin commented 7 years ago

It was in the aptly named "Standard" toolbar. Now that solves it. When choosing IIS Express, the message is.

The project doesn't know how to run the profile IIS Expres.

capture

shaunluttin commented 7 years ago

Answer: http://stackoverflow.com/questions/37569112/visual-studio-2015-cant-start-iis-express

It might be a problem with how Visual Studio creates an xproj when first opening an existing .NET Core project. On opening in Visual Studio 2015, we get this xrproj.

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0.25420" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25420</VisualStudioVersion>
    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
  </PropertyGroup>
  <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
  <PropertyGroup Label="Globals">
    <ProjectGuid>1b2fc342-5f98-4193-bea1-141a9bc557d9</ProjectGuid>
    <RootNamespace>2016-101DP-TreeGame-Auth</RootNamespace>
    <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
    <OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
  </PropertyGroup>

  <PropertyGroup>
    <SchemaVersion>2.0</SchemaVersion>
  </PropertyGroup>
  <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

This is the modification that worked.

-  <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
+  <Import Project="$(VSToolsPath)\DotNet.Web\Microsoft.DotNet.Web.targets" Condition="'$(VSToolsPath)' != ''" />