The dotnet publish
command for my ASP.NET Core 3.1 project creates a web.config
file in my publish/
directory. I don't want this file to be generated (or copied to that folder, at least) - it is never to be used with IIS at all.
When I took a look at the command output with verbosity increased, I found the following text:
Target "_TransformWebConfig" in file "C:\Program Files\dotnet\sdk\3.1.200\Sdks\Microsoft.NET.Sdk.Publish\targets\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets" from project "C:\repos\reportweb\reportweb\reportweb.csproj" (target "_AspNetCoreProjectSystemPostPublish" depends on it):
Using "TransformWebConfig" task from assembly "C:\Program Files\dotnet\sdk\3.1.200\Sdks\Microsoft.NET.Sdk.Publish\targets\..\tools\netcoreapp2.1\Microsoft.NET.Sdk.Publish.Tasks.dll".
Task "TransformWebConfig"
Configuring the following project for use with IIS: 'C:\repos\reportweb\reportweb\bin\Release\netcoreapp3.1\linux-x64\publish\'
Updating web.config at 'C:\repos\reportweb\reportweb\bin\Release\netcoreapp3.1\linux-x64\publish\web.config'
Configuring project completed successfully
Done executing task "TransformWebConfig".
Done building target "_TransformWebConfig" in project "reportweb.csproj".
Is it somehow possible to configure my project to skip the _TransformWebConfig
Target or TransformWebConfig
Task - or to use another way to skip the generation? I know I could make MSBuild delete the file afterwards, but having this disabled seems less hacky to me.
You can control this with the IsWebConfigTransformDisabled
MSBuild property:
To prevent transformations of the web.config file, set the MSBuild property
$(IsWebConfigTransformDisabled)
:dotnet publish /p:IsWebConfigTransformDisabled=true
Because this is an MSBuild property, you can set it in the .csproj, instead of passing it as a command-line argument:
<PropertyGroup>
<IsWebConfigTransformDisabled>true</IsWebConfigTransformDisabled>
</PropertyGroup>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With