bicep icon indicating copy to clipboard operation
bicep copied to clipboard

Handle "file not found" exception

Open jskulavik opened this issue 6 years ago • 1 comments

Bicep version Bicep CLI version 0.1.1-alpha (427d5e7abe)

Describe the bug Following the tutorial instructions on Linux (WSL), the main.bicep file fails to write to the system.

To Reproduce bicep build main.bicep

Unhandled exception. System.IO.FileNotFoundException: Could not find file '/mnt/c/dev/bicep/main.bicep'. File name: '/mnt/c/dev/bicep/main.bicep' at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func2 errorRewriter) at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode) at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize) at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks) at System.IO.File.InternalReadAllText(String path, Encoding encoding) at System.IO.File.ReadAllText(String path) at Bicep.Cli.Program.BuildSingleFile(IDiagnosticLogger logger, String bicepPath, String outputPath) at Bicep.Cli.Program.Build(IDiagnosticLogger logger, BuildArguments arguments) at Bicep.Cli.Program.Run(String[] args) at Bicep.Cli.Program.Main(String[] args) Aborted

Additional context bicep needs to be platform agnostic, based on dotnet core, from the start. Remove the Win32 handle please.

jskulavik avatar Sep 03 '20 07:09 jskulavik

It is based on dotnet core. Microsoft.Win32 is just a namespace in dotnet core that the File class uses on Windows, Linux, and OS X.

It looks like file specified in the bicep build command didn't exist and we didn't handle the exception right. We will fix that.

majastrz avatar Sep 03 '20 08:09 majastrz