question

twoelfer avatar image
0 Votes"
twoelfer asked ajkuma-MSFT edited

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)

WM_THXADVANCE

vs-generaldotnet-aspnet-core-generalvs-debuggingdotnet-aspnet-core-webapi
· 9
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, @twoelfer

First, I want to sort out your situation.

You have integrated VSS etc. into Visual Studio, and you can not edit Web.config unless you do the checkout operation first, so you can not publish to Azure.

Is my guess correct?

Next, what does "continuous publishing" mean? Do you have any deployment pipeline?

0 Votes 0 ·

Hi.

First of all, please forget about the info in parenthesis. I just provided that, because this is the answer to the first question that came up on stack overflow.

u can not edit Web.config unless you do the checkout operation first, so you can not publish to Azure

No, you misunderstood.

I can not publish to azure before checking out web.config. I do not want to edit web.config. I want to publish. However, if web.config is checked in, publishing fails.

WM_THX
-thomas

0 Votes 0 ·

@twoelfer, to better assist you, are you deploying your app to Azure App Service WebApp or some other Azure service? When you mention, " the publishing fails in case the projects web.config file is not checked out." what exactly happens/do you receive any error messages? Could you please share more details about this specific requirement ( do not want to edit/checkout web..config)?

Just to highlight -

In order to set up the ASP.NET Core Module correctly, the web.config file must be present at the content root path (typically the app base path) of the deployed app.

If a web.config file isn't present in the project, the file is created with the correct processPath and arguments to configure the ASP.NET Core Module and moved to published output.

If a web.config file is present in the project, the file is transformed with the correct processPath and arguments to configure the ASP.NET Core Module and moved to published output. The transformation doesn't modify IIS configuration settings in the file

Kindly check this doc and Web.config transformations versus Web Deploy parameters.


--I have also added additional tags to receive insights from targetted SMEs.

0 Votes 0 ·

Please see my answer to your questions below. (for some reason, i did not have a "Reply" button last time i looked, thus a new comment.).

Also, i do have a video that i can share: s!AtrVe2ZfnPolk-sRZUbzcD9w6GZdAA


0 Votes 0 ·
Show more comments

@ajkuma-MSFT , i am deploying to Azure App Service (on windows). The message is

"An error has occured" with these details: "Publish has encountered an error.
Build failed. Check the Output window for more details.

A diagnostic log has been written to the following location:
"C:\Users\tw\AppData\Local\Temp\tmpE90F.tmp""

When looing at the message in the output window, i see this: "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."

So, basically, the deploying is copying my web.config file to the out directory and is than attemting to put the "default" settings into the file. The file, however, is read only, as it is copied from my projects directory without any modification. The file beeing under source control in tfs means, it has the r/o bit set. Thus the file cannot be opened for writing. Thus the error. (And thus, if i check out the file and remove it's r/o bit by doing so, the deployment works.)


0 Votes 0 ·

twoelfer, Thanks for the follow-up and additional insights.

From App Service perspective, the access denied seems to be due to Sandbox ( see more details on it below). I'll have this open for other SMEs from Asp.net and VS team to share insights from the respective service standpoint.

Just to highlights, All Azure Web Apps run in a secure environment called a sandbox.
Every Azure Web App has a home directory stored/backed by Azure Storage. This network share is where applications store their content. This directory is available for the sandbox with read/write access.
As a convenience for our customers, the sandbox implements a dynamic symbolic link in kernel mode which maps d:\home to the customer home directory.

Applications can read the system drive as controlled by ACLs on the drive. Applications cannot write to any location on the system drive, as implemented in the sandbox (i.e. even if ACLs allowed writing to a location on system drive, the sandbox would restrict it).

See Azure Web App sandbox | File System Restrictions/Considerations

Operating system functionality on Azure App Service


0 Votes 0 ·

Yes, thank you. However, this has nothing to do with r/w access to the sandbox, because no files ever leave the developer machine in this case. The problem is (i think this is obvious) that vs is not removing the r/o bit from the web.config file after it has been copied to the local out directory and before it starts to begin transforms.

WM_THX
-thomas woelfer

0 Votes 0 ·
Show more comments

0 Answers