When I perform dotnet publish -c Release
then this web.config
file is being added to my publish folder:
<?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=".\aaa.xxxx.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" />
</system.webServer>
</location>
</configuration>
But I have different configuration on the server and I'd want to override it with my own config but, I have no idea how to do it.
I tried creating web.config
file and setting it to Copy always
.
But I receive:
error MSB4018: The "TransformWebConfig" task failed unexpectedly.
error MSB4018: System.UnauthorizedAccessException: Access to the path 'bin\Release\netcoreapp3.1\publish\web.config
Even when I run dotnet publish -c Release
as admin.
For now, the workaround that I use is:
rmdir bin /s /q
rmdir obj /s /q
rmdir output /s /q
dotnet publish -c Release -o output
del /f "output\web.config"
xcopy "prod_web.config" "output\web.config*"
pause