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
ASP.NET Core
Visual Studio
Visual Studio Debugging
-
Takahito Iwasa 4,841 Reputation points • MVP
2022-07-04T21:45:07.417+00:00 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?
-
twoelfer@hotmail.com 136 Reputation points
2022-07-05T07:12:11.69+00:00 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 -
ajkuma 22,516 Reputation points • Microsoft Employee
2022-07-05T13:58:36.713+00:00 @twoelfer@hotmail.com , 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 correctprocessPath
andarguments
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 correctprocessPath
andarguments
to configure the ASP.NET Core Module and moved to published output. The transformation doesn't modify IIS configuration settings in the fileKindly check this doc and Web.config transformations versus Web Deploy parameters.
--I have also added additional tags to receive insights from targetted SMEs.
-
twoelfer@hotmail.com 136 Reputation points
2022-07-05T14:07:38.217+00:00 @ajkuma , 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.)
-
twoelfer@hotmail.com 136 Reputation points
2022-07-05T15:54:18.103+00:00 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
-
ajkuma 22,516 Reputation points • Microsoft Employee
2022-07-06T18:24:58.45+00:00 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
-
ajkuma 22,516 Reputation points • Microsoft Employee
2022-07-06T18:27:41.617+00:00 twoelfer, Apologies you'd experienced issue with the Q&A platform. We have noted this and will relay the feedback internally to the respective team.
Thanks for sharing the screencast.
-
twoelfer@hotmail.com 136 Reputation points
2022-07-06T19:25:23.197+00:00 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 -
ajkuma 22,516 Reputation points • Microsoft Employee
2022-07-07T18:05:24.317+00:00 Thanks for the additional clarity. Yes, that sounds like a potential cause. I'll have
vs-debugging
SMEs to comment.
Sign in to comment