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

Generation fails for read-only controllers #154

Open
IanKemp opened this issue Jul 30, 2020 · 0 comments
Open

Generation fails for read-only controllers #154

IanKemp opened this issue Jul 30, 2020 · 0 comments

Comments

@IanKemp
Copy link

IanKemp commented Jul 30, 2020

PS C:\Users\<removed>\.nuget\packages\r4mvc.tools\1.0.0-ci-00377\tools> .\R4Mvc.Tools.exe generate -p "<path\to\removed>.csproj"
  R4Mvc Generator Tool v1.0.0-ci-00377

Using: Visual Studio Enterprise 2019 - 16.6.30320.27
Project: <path\to\removed>.csproj

Creating Workspace ...
Loading project ...
Compiling project ...
Detected MVC version: 3.1.0.0

Processing controller ControllerName

Unhandled Exception: System.UnauthorizedAccessException: Access to the path '<path\to\ControllerName>.cs' 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, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode)
   at R4Mvc.Tools.Services.FilePersistService.WriteFile(SyntaxNode fileTree, String filePath)
   at R4Mvc.Tools.Services.ControllerRewriterService.RewriteControllers(CSharpCompilation compiler)
   at R4Mvc.Tools.Commands.GenerateCommand.Runner.<Run>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at R4Mvc.Tools.Program.<Main>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at R4Mvc.Tools.Program.<Main>(String[] args)

It seems like the tool is trying to write to my controller's .cs file to mark it as partial, which fails because said file is read-only (we are sadly using TFS for version control, it checks out all files as read-only). FilePersistService should probably be updated to handle this read-only case.

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

1 participant