aspnet / Tooling

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

ASPNETCORE_HOSTINGSTARTUPASSEMBLIES environment variable is set incorrectly #1053

Closed halter73 closed 7 years ago

halter73 commented 7 years ago

Given the launchSettings.json and Program.cs below, it seems that the ASPNETCORE_HOSTINGSTARTUPASSEMBLIES environment variable is set incorrectly when launching both the "IIS Express" or "WebApplication1" profiles from VS 2017 26730.0.d15rel and dotnet sdk 2.0.0-preview3-006889.

Expected output for "IIS Express" profile launched from VS:

ASPNETCORE_HOSTINGSTARTUPASSEMBLIES: 'HostingStartup1;Microsoft.AspNetCore.Server.IISIntegration;Microsoft.AspNetCore.ApplicationInsights.HostingStartup'

Actual output for "IIS Express" profile launched from VS (App Insights is missing):

ASPNETCORE_HOSTINGSTARTUPASSEMBLIES: 'HostingStartup1;Microsoft.AspNetCore.Server.IISIntegration'

Expected output for "WebApplication1" profile launched from VS:

ASPNETCORE_HOSTINGSTARTUPASSEMBLIES: 'HostingStartup1;Microsoft.AspNetCore.ApplicationInsights.HostingStartup'

Actual output for "WebApplication1" profile launched from VS (HostingStartup1 is missing):

ASPNETCORE_HOSTINGSTARTUPASSEMBLIES: 'Microsoft.AspNetCore.ApplicationInsights.HostingStartup'

Actual output for "WebApplication1" profile launched using "dotnet run" (Behaves as expected)

ASPNETCORE_HOSTINGSTARTUPASSEMBLIES: 'HostingStartup1'

launchSettings.json

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

Program.cs

using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using System;

namespace WebApplication1
{
    public class Program
    {
        public static void Main(string[] args)
        {
            BuildWebHost(args).Run();
        }

        public static IWebHost BuildWebHost(string[] args)
        {
            Console.WriteLine("ASPNETCORE_HOSTINGSTARTUPASSEMBLIES: '{0}'", Environment.GetEnvironmentVariable("ASPNETCORE_HOSTINGSTARTUPASSEMBLIES"));

            return WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>()
                .Build();
        }
    }
}
barrytang commented 7 years ago

To report new issues, use the Report a Problem tool. The GitHub Issue Tracker for the aspnet/Tooling repo is now deprecated in favor of the Report a Problem tool.

If you encounter a problem with Visual Studio, we want to know about it so that we can diagnose and fix it. By using the Report a Problem tool, you can collect detailed information about the problem, and send it to Microsoft with just a few button clicks. See here for more details.

abpiskunov commented 7 years ago

I opened TFS 473884 just in case, since it seems to be valid issue and we might want to consider it sooner.

BillHiebert commented 7 years ago

This has been fixed in an upcoming update of Visual Studio

scott-lin commented 6 years ago

@BillHiebert, what version of Visual Studio has the fix? I'm on VS 2017 v15.5.7 and can still repro this behavior.

@abpiskunov, can you provide a link for "TFS 473884", so I can view the details? Assuming it's a public bug repo.

abpiskunov commented 6 years ago

It is internal bug. It was fixed on 8/15/2017.