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

Throw DirectoryNotFoundException when !Directory.Exists() #459

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public CloudPackageCreateCommand(
protected override async ValueTask ExecuteCommand()
{
ProjectPath ??= AppDomain.CurrentDomain.BaseDirectory;
ProjectPath = Path.GetFullPath(ProjectPath);
if (!Directory.Exists(ProjectPath))
{
throw new DirectoryNotFoundException($"Directory not found '{ProjectPath}'. Check path to project file.");
}

// build
Logger?.LogInformation($"Building {Configuration} version of application...");
Expand Down
7 changes: 5 additions & 2 deletions Source/v2/Meadow.Package/PackageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
using Meadow.Software;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text.Json;
using YamlDotNet.Serialization;
Expand Down Expand Up @@ -227,7 +229,8 @@ private void CreateEntry(ZipArchive archive, string fromFile, string entryPath)

public static FileInfo[] GetAvailableBuiltConfigurations(string rootFolder, string appName = "App.dll")
{
if (!Directory.Exists(rootFolder)) { throw new FileNotFoundException(); }
rootFolder = Path.GetFullPath(rootFolder);
if (!Directory.Exists(rootFolder)) { throw new DirectoryNotFoundException($"Directory not found '{rootFolder}'. Check path to project file."); }

//see if this is a fully qualified path to the app.dll
if (File.Exists(Path.Combine(rootFolder, appName)))
Expand All @@ -237,7 +240,7 @@ public static FileInfo[] GetAvailableBuiltConfigurations(string rootFolder, stri

// look for a 'bin' folder
var path = Path.Combine(rootFolder, "bin");
if (!Directory.Exists(path)) throw new FileNotFoundException($"No 'bin' directory found under {rootFolder}. Have you compiled?");
if (!Directory.Exists(path)) throw new DirectoryNotFoundException($"No 'bin' directory found under '{rootFolder}'. Have you compiled?");

var files = new List<FileInfo>();
FindApp(path, files);
Expand Down
Loading