Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access to the path appsettings.Debug.json is denied #86

Closed
deastr opened this issue Sep 29, 2017 · 6 comments
Closed

Access to the path appsettings.Debug.json is denied #86

deastr opened this issue Sep 29, 2017 · 6 comments

Comments

@deastr
Copy link

deastr commented Sep 29, 2017

My appsettings.json and appsettings.*.json files are under source control and are checked-in, so readonly. I'm getting this error when I try to build the project:

MSB4018	The "SlowCheetah.TransformTask" task failed unexpectedly.
System.UnauthorizedAccessException: Access to the path 'D:\MyProject\appsettings.Debug.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 source, String transform, String destination)
   at Microsoft.VisualStudio.SlowCheetah.TransformTask.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()	Identity.Authentication.Web.UI	C:\Users\user\.nuget\packages\microsoft.visualstudio.slowcheetah\3.0.61\build\Microsoft.VisualStudio.SlowCheetah.targets	83	

Checking out the file get rids of the error but I rather not to do this every time I open the project. Is there a workaround?

@deastr
Copy link
Author

deastr commented Oct 4, 2017

Also same happens with Preview. Can't preview without checking the file out.

@Saniok88
Copy link

Saniok88 commented Mar 6, 2018

in general cases, files can also be locked, when they are very deep in folder structure, so the path length is longer, than 256 symbols.

@davilimap
Copy link
Member

Seems to be microsoft/json-document-transforms#16. You can reopen the issue if it is not the problem.

@Damodark
Copy link

Damodark commented Aug 21, 2018

Hi,

I am getting similar issue.
I have latest of VS 2017 and latest of slowcheetah 3.1.66 installed. I am trying to use transformation for setting.json. Have created .Debug.json and .Release.json. When ever I build the project I get following error.

The "SlowCheetah.TransformTask" task failed unexpectedly.
System.UnauthorizedAccessException: Access to the path 'D:\Dev\TFS\dev\VS 2017\DevAgent\DevAgent.Program\Settings.Debug.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()

What is the resolution?

When I checkout the setting.debug.json file it's able to build the project otherwise it will give the previous error.

Best Regards,
Damodar

@icnocop
Copy link
Contributor

icnocop commented Sep 21, 2018

@Damodark I've posted a few work-around here.

  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"/>

  3. 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;"/>

@abdurezakMussa
Copy link

$ dotnet run
Unhandled exception. System.UnauthorizedAccessException: Access to the path 'C:\Users\Coding\Desktop\hobnobReact\appsettings.json' is denied.
at System.IO.FileStream.SeekCore(SafeFileHandle fileHandle, Int64 offset, SeekOrigin origin, Boolean closeInvalidHandle)
at System.IO.FileStream.ReadNativeAsync(Memory1 destination, Int32 numBufferedBytesRead, CancellationToken cancellationToken) at System.IO.FileStream.ReadAsyncInternal(Memory1 destination, CancellationToken cancellationToken, Int32& synchronousResult)
at System.IO.FileStream.ReadAsyncTask(Byte[] array, Int32 offset, Int32 count, CancellationToken cancellationToken)
at System.IO.FileStream.Read(Byte[] array, Int32 offset, Int32 count)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadToEnd()
at Microsoft.Extensions.Configuration.Json.JsonConfigurationFileParser.ParseStream(Stream input)
at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load(Stream stream)
at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.Extensions.Configuration.FileConfigurationProvider.HandleException(ExceptionDispatchInfo info)
at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload)
at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load()
at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers)
at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
at Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at hobnobReact.Program.Main(String[] args) in C:\Users\Coding\Desktop\hobnobReact\Program.cs:line 16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants