0



Getting following error when using custom json configuration file.
Severity Code Description Project File Line Suppression State Error The "SlowCheetah.TransformTask" task failed unexpectedly. System.UnauthorizedAccessException: Access to the path 'D:\Data\…\Settings.Release.json' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) at Microsoft.VisualStudio.Jdt.JsonTransformation..ctor(String transformFile, IJsonTransformationLogger logger) at Microsoft.VisualStudio.SlowCheetah.JsonTransformer.Transform(String sourcePath, String transformPath, String destinationPath) at Microsoft.VisualStudio.SlowCheetah.TransformTask.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() OzCruisingHangfireAgent.Program

Best Regards,
Damodar

damodar
  • 3
  • 4

1 Answers1

3

This is a known issue.

The JSON transformer in SlowCheetah v3.1.66 doesn't support the source or transform files being read-only yet.

See the following issues:
https://github.com/Microsoft/slow-cheetah/issues/86
https://github.com/Microsoft/json-document-transforms/issues/16

The merged PR#17 has a fix for Microsoft.VisualStudio.Jdt, but it hasn't been released yet.

Here are a few work arounds:

  1. Make all files writeable when checking out of source control.
  2. Call the Attrib MSBuild task before the transformation to remove the read-only file attribute.

For example:

<Attrib Files="D:\Data\…\Settings.Release.json" Normal="true"/>

  1. Call the Exec MSBuild task before the transformation to remove the read-only file attribute.

For example:

<Exec Command="attrib -R &quot;D:\Data\…\Settings.Release.json&quot;"/>

Rami A.
  • 10,302
  • 4
  • 44
  • 87
  • Hi Rami A., Thanks but it didn't work. Won't be able to do 1. If I do that it's working fine, don't want to check out file when building a project. I did following Attrib Files="$(ProjectDir)Settings.json" Normal="true" ReadOnly="false" Attrib Files="$(ProjectDir)Settings.Debug.json" Normal="true" ReadOnly="false" Exec Command=attrib -R "$(ProjectDir)Settings.json" Exec Command=attrib -R "$(ProjectDir)Settings.Debug.json" Would you be able to check the syntax? – damodar Oct 03 '18 at 05:22
  • The syntax looks fine. You can do either 2 or 3; you don't have to do both because they do the same thing. – Rami A. Oct 03 '18 at 07:48
  • Hi Rami.A, No luck. Tried them both separately. - Damodar – damodar Oct 29 '18 at 04:08
  • @damodar, what output do you get? – Rami A. Oct 29 '18 at 17:09
  • Hi Rami, this is what I get The command "" exited with code 255 – damodar Oct 29 '18 at 21:42
  • @damodar, you need to set more verbosity in the MSBuild build output in `Visual Studio > Tools > Options > Projects and Solutions > Build and Run` and then check the Output window for the detailed error message. – Rami A. Oct 30 '18 at 20:33
  • the build log says The syntax of the command is incorrect. 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1332,5): error MSB3073: The command "" exited with code 255. 2>Done executing task "Exec" -- FAILED. Used tried Settings.Debug.json as well – damodar Oct 30 '18 at 23:15
  • Try removing the `xmlns` attribute on the `Attrib` task. It's not required. – Rami A. Oct 31 '18 at 00:50
  • Also, if your file contains spaces, you'll have to surround the path in quotes like the example using the `Exec` command. – Rami A. Oct 31 '18 at 00:53
  • Does it work inside Visual Studio? You can try to increase the verbosity of the MSBuild log output in `Visual Studio > Tools > Options > Projects and Solutions > Build and Run` and then check the log for more details about the error. – Rami A. Oct 31 '18 at 00:56
  • Hi Rami A, I basically have this in Pre-Build event command line: in the project property. The folder name is long there spaces in the folder structure. – damodar Oct 31 '18 at 01:07
  • A, here's the detailed error: 2>Done executing task "Exec" -- FAILED. (TaskId:22) 2>Done building target "PreBuildEvent" in project "Program.csproj" -- FAILED.: (TargetId:28) 2>Target "_CheckForCompileOutputs: (TargetId:29)" in file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets" from project "D:\Data\..\Program.csproj" (target "_CleanGetCurrentAndPriorFileWrites" depends on it): – damodar Oct 31 '18 at 01:33
  • Which verbosity levels did you set? – Rami A. Oct 31 '18 at 01:55
  • Have selected "Diagnostic" – damodar Oct 31 '18 at 03:05
  • Can you share your project? – Rami A. Oct 31 '18 at 08:36