I'm currently working with an ASP.NET Core application and setting up a CI/CD pipeline using Azure DevOps. As part of my deployment strategy, I'm trying to generate a web.config file with the correct handlers added during the publish process, but without actually zipping the published output. I need to do this because I want to frequently update just the web.config file in my deployment, without requiring a full redeployment of the application.
I have created a separate publish profile with the WebPublishMethod set to FileSystem, as I do not want to deploy the entire solution, just the web.config file. Here's the portion of my publish profile:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<!-- Rest of config -->
</PropertyGroup>
</Project>
And here is a portion of my pipeline setup:
- task: DotNetCoreCLI@2
displayName: DotNet Build
inputs:
command: 'publish'
publishWebProjects: false
zipAfterPublish : false
projects: '${{parameters.project}}'
arguments: '-c Release -o $(Build.ArtifactStagingDirectory)/output
/p:PublishProfile=${{parameters.publishProfile}}'
In this setup, I noticed that the handlers are not added to the web.config file. However, if I change zipAfterPublish to true, the handlers are correctly added. Here's the pipeline setup with zipAfterPublish set to true:
- task: DotNetCoreCLI@2
displayName: DotNet Build
inputs:
command: 'publish'
publishWebProjects: false
zipAfterPublish : true
projects: '${{parameters.project}}'
arguments: '-c Release -o $(Build.ArtifactStagingDirectory)/output
/p:PublishProfile=${{parameters.publishProfile}}'
My goal is to have the correct web.config file generated without zipping the output, because my application's deployment strategy involves frequently updating the web.config file, without requiring a full redeployment of the application. For speed and efficiency, I'd like to keep the output unzipped so that I can easily replace the web.config file.
When the zipAfterPublish is set to true and I unzip the build output I can see the headers in the web.config
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\some_site.Website.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
But when its set to false they are not present in the web.config
Does anyone have insights on why the handlers are not added when zipAfterPublish is set to false? Any advice on how these handlers are set and where they come from would be really nice.