-
Notifications
You must be signed in to change notification settings - Fork 5
Additional logging around packages.config paths during project inspection #25
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
base: master
Are you sure you want to change the base?
Changes from all commits
16a4123
2b2cac7
341969a
a91fdf1
1a7b599
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,6 +158,13 @@ public Container GetContainer() | |
|
||
|
||
bool packagesConfigExists = !String.IsNullOrWhiteSpace(Options.PackagesConfigPath) && File.Exists(Options.PackagesConfigPath); | ||
// File.exists is a safe method that will not throw exceptions and simply return false | ||
if (!packagesConfigExists) | ||
{ | ||
Console.WriteLine($"Unable to find packages config file: {Options.PackagesConfigPath}. Checking if file permissions were denied..."); | ||
CheckFilePermissions(Options.PackagesConfigPath); | ||
} | ||
|
||
bool projectJsonExists = !String.IsNullOrWhiteSpace(Options.ProjectJsonPath) && File.Exists(Options.ProjectJsonPath); | ||
bool projectJsonLockExists = !String.IsNullOrWhiteSpace(Options.ProjectJsonLockPath) && File.Exists(Options.ProjectJsonLockPath); | ||
bool projectAssetsJsonExists = !String.IsNullOrWhiteSpace(Options.ProjectAssetsJsonPath) && File.Exists(Options.ProjectAssetsJsonPath); | ||
|
@@ -265,6 +272,24 @@ public Container GetContainer() | |
} | ||
|
||
|
||
public static void CheckFilePermissions(String path) | ||
{ | ||
try | ||
{ | ||
// Attempt to read file, will throw UnauthorizedAccessException if denied | ||
using (File.OpenRead(path)) { } | ||
Console.WriteLine("File permissions confirmed."); | ||
} | ||
catch (UnauthorizedAccessException ex) | ||
{ | ||
Console.WriteLine("UnauthorizedAccessException when trying to open file. \n" + ex.Message); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine("Some other exception when trying to open file: " + ex.Message); | ||
} | ||
} | ||
|
||
public List<String> FindOutputPaths() | ||
{ | ||
//TODO: Move to a new class (OutputPathResolver?) | ||
|
@@ -292,7 +317,8 @@ public List<String> FindOutputPaths() | |
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine("Skipping configuration output paths."); | ||
Console.WriteLine("Skipping configuration output paths because a problem occurred (likely during project evaluation at target path)."); | ||
Console.WriteLine("Exception was: " + e.Message); | ||
return new List<string>() { }; | ||
} | ||
} | ||
|
@@ -364,6 +390,7 @@ public bool IsExcluded() | |
|
||
private string CreateProjectPackageConfigPath(string projectDirectory) | ||
{ | ||
Console.WriteLine($"Creating packages.config path from project directory: {projectDirectory}"); | ||
return PathUtil.Combine(projectDirectory, "packages.config"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This addition is to check/highlight the theory that the file path origin could be the issue. |
||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,11 +116,16 @@ public Container GetContainer() | |
.Where(group => group.Count() > 1) | ||
.Select(group => group.Key); | ||
|
||
Console.WriteLine("Processing project files found in solution file."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suspect the problem has to do with the project paths given in their solution file, added further logging in this area to check that (included in exe attached to ticket on Feb 20) |
||
foreach (ProjectFile project in projectFiles) | ||
{ | ||
try | ||
{ | ||
string projectRelativePath = project.Path; | ||
Console.WriteLine("Project file relative path: '{0}'", projectRelativePath); | ||
Console.WriteLine("Contains null character? " + projectRelativePath.Contains('\0')); | ||
Console.WriteLine("Contains space character? " + projectRelativePath.Contains(' ')); | ||
|
||
string projectPath = null; | ||
Boolean directoryPackagesExists = false; | ||
if (projectRelativePath.Contains("Directory.Packages.props")) | ||
|
@@ -137,7 +142,13 @@ public Container GetContainer() | |
} | ||
parentPath = | ||
parentPath.Substring(0, OperatingSystem.IsWindows() ? parentPath.LastIndexOf("\\") : parentPath.LastIndexOf("/")); | ||
Console.WriteLine("Parent path is: '{0}'", parentPath); | ||
directoryPackagesExists = File.Exists(checkFile); | ||
if (!directoryPackagesExists) | ||
{ | ||
Console.WriteLine($"Unable to find project file: {checkFile}. Checking if file permissions were denied..."); | ||
ProjectInspector.CheckFilePermissions(checkFile); | ||
} | ||
fileNotFound = !directoryPackagesExists; | ||
projectPath = checkFile; | ||
} | ||
|
@@ -157,10 +168,21 @@ public Container GetContainer() | |
try | ||
{ | ||
projectFileExists = File.Exists(projectPath); | ||
if (!projectFileExists) | ||
{ | ||
Console.WriteLine($"Unable to find project file: {projectPath}. Checking if file permissions were denied..."); | ||
if (projectPath != null) | ||
{ ProjectInspector.CheckFilePermissions(projectPath);} | ||
} | ||
if (!projectFileExists && !directoryPackagesExists) | ||
{ | ||
projectPath = PathUtil.Combine(projectPath, "Directory.Packages.props"); | ||
directoryPackagesExists = File.Exists(projectPath); | ||
if (!directoryPackagesExists) | ||
{ | ||
Console.WriteLine($"Unable to find project file: {projectPath}. Checking if file permissions were denied..."); | ||
ProjectInspector.CheckFilePermissions(projectPath); | ||
} | ||
} | ||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This addition is to check the theory that file permissions could be an issue.