简体   繁体   中英

Publishing ASP.NET Core app from Visual Studio 2022 to Azure does not work without checking out web.config

When I try to publish my ASP.NET Core app from VS 2022 (latest version) to Azure, the publishing fails in case the projects web.config file is not checked out.

After manually checking out this file, publishing works.

How can I make publishing work without the manual step? (I can not switch to github and I can not use continuous publishing)

I see that you have mentioned this issue elsewhere and provided the details below.

"C:\Program Files\dotnet\sdk\6.0.202\Sdks\Microsoft.NET.Sdk.Publish\targets\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(50,5): Error MSB4018: The "TransformWebConfig" task failed unexpectedly. System.UnauthorizedAccessException: Access to the path 'C:\workspaces\websites.core\websites\www.die.de\obj\Release\net6.0\PubTmp\Out\web.config' is denied."

While publishing the app, a transformation task was running on web.config file. According to the error message, I think the problem is related to permissions.

Suggestion

1. Restart Visual Studio and running it as Administrator, then publish it.

2. I see that your project is on the C drive, check if you have enough permissions to access it, and check if the current web.config file is set to read-only.

3. Also I see a practice, you can try it. You can prevent the generation of web.config files at compile and publish time. Then you can copy and paste the web.config file to wwwroot path manually. Remember not to enable Delete all existing files prior to publish .

<PropertyGroup>
    <IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
</PropertyGroup>

Related Link:

The "TransformWebConfig" task failed unexpectedly

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM