1,210 questions
MsBuild ignore TransformWebConfigEnabled parameter
Ouellet Francis
1
Reputation point
For some reason MsBuild tag my obj\web.config as ReadOnly. I trying several time to find a workaround but without success.
ServiceApi failed with 1 error(s) (6.9s) → output\
C:\Program Files\dotnet\sdk\9.0.203\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 'D:\Projets\output\Web.config' is denied. at System.IO.FileSystem.CopyFile(String sourceFullPath, String destFullPath, Boolean overwrite)
at Microsoft.NET.Sdk.Publish.Tasks.TransformWebConfig.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(TaskExecutionHost taskExecutionHost, TaskLogging
Context taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
At first it seem, after I track the file with Process Monitor, that is MsSense is locking the file. I add some exclusions to prevent MsSense to lock the file but without success.
After I try to avoid the task TransformWebConfig by:
- Set the parameter TransformWebConfigEnabled to False (in project file, also with a /p:). MsBuild ignore the parameter
- I deleted all my Web.Release.config. Nothing TransformWebConfig it still triggered
It seem this error only happened with the SDK version of my projects. Old school project dont have this issue.
Developer technologies | Visual Studio | Setup
Sign in to answer