Search code examples
asp.net-corestdoutwebdeploy

how to set "stdout=true" while doing a webdeploy for asp.net core v3.1 app?


I am publishing an asp.net core v3.1 app in visual studio 2019
since core apps do not create a web.config
webdeploy creates it and publishes its own web.config on every publish

while it does that
it sets the stdout=false and i would like to be true -
anyone know how to control this?
i was toying around with trying to configure something in the .csproj
but never found the correct combination

heres what the published web.config looks like:

<aspNetCore processPath="dotnet" arguments=".\myproj.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />

and of course heres what i want it to look like:

<aspNetCore processPath="dotnet" arguments=".\myproj.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />

another post about this same issue here:
https://github.com/MicrosoftDocs/azure-docs/issues/31380


Solution

  • You can add a web.config to your poject by right click the project, add=>newItem=>Web=>Web Configuration File.And then you can set stdoutLogEnabled in it.

    Example(pay attention you need to add hostingModel="inprocess"to web.config):

    <system.webServer>
        <handlers>
          <remove name="aspNetCore"/>
          <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
        </handlers>
        <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="InProcess"/>
      </system.webServer>
    

    And here is the published web.config:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <location path="." inheritInChildApplications="false">
        <system.webServer>
          <handlers>
            <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
          </handlers>
          <aspNetCore processPath="dotnet" arguments=".\case1(5-26).dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
        </system.webServer>
      </location>
    </configuration>