1

I use ASP.NET Core 1.1.
When I publish my application the IHostingEnvironment always return the environment as "Production".
I made some attempts via the web.config as follows:

 <system.webServer>
  <handlers>
   <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
 </handlers>
 <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false">
  <environmentVariables>
    <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
  </environmentVariables>
 </aspNetCore>
</system.webServer>

Unfortunately it doesn't has any effect.
I also get a warning about that the aspNetCore is invalid child of system.webServer...
I have seen at the project.json the scripts entry that runs dotnet publish-iis command but couldn't find any environment parameter.
I have tried to pass the publish command --iis-command (As described in this post) but it doesn't identify this parameter.
I will highly appreciate your thoughts about it...

Yaron
  • 2,209
  • 3
  • 18
  • 33
  • Have you installed **.NET Core Windows Server Hosting** bundle on the server? – Sanket Dec 07 '16 at 16:38
  • I'm not deploying to a server, I deploy to Pivotal cloud foundry. The publish is done to a local FileSystem and from there into Pivotal using cf push command. I see that the publish ignores the environment variable. It generates "appsettings.Production.json" file. I assume that if the environment variable has been read correctly is was "appsettings.Development.json". The application does run on the target but it claims to run on production. – Yaron Dec 07 '16 at 16:50

0 Answers0