Skip to content

Commit

Permalink
Update packages and prepare for v0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorkstromm committed Sep 24, 2020
1 parent 0c39d5d commit 17b0e70
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 25 deletions.
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"sdk": {
"version": "3.0.100",
"rollForward": "latestMinor",
"version": "3.1.402",
"rollForward": "latestPatch",
"allowPrerelease": false
}
}
11 changes: 8 additions & 3 deletions src/Depends.Core/DependencyAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ namespace Depends.Core
{
public class DependencyAnalyzer
{
static DependencyAnalyzer()
{
_ = typeof(NuGet.Common.LogLevel);
}

private ILogger _logger;
private ILoggerFactory _loggerFactory;

Expand Down Expand Up @@ -169,7 +174,7 @@ public DependencyGraph AnalyzeSolution(string solution, string framework = null)
{
builder = CreateBuilder(project.Value, project.Key, builder, framework);
}

return builder.Build();
}

Expand All @@ -194,7 +199,7 @@ public DependencyGraph Analyze(string projectPath, string framework = null)
return CreateBuilder(projectAnalyzer, projectPath, null, framework).Build();
}

private DependencyGraph.Builder CreateBuilder(ProjectAnalyzer projectAnalyzer, string projectPath, DependencyGraph.Builder builder = null, string framework = null)
private DependencyGraph.Builder CreateBuilder(IProjectAnalyzer projectAnalyzer, string projectPath, DependencyGraph.Builder builder = null, string framework = null)
{
var analyzeResults = string.IsNullOrEmpty(framework) ?
projectAnalyzer.Build() : projectAnalyzer.Build(framework);
Expand Down Expand Up @@ -227,7 +232,7 @@ private DependencyGraph.Builder CreateBuilder(ProjectAnalyzer projectAnalyzer,
// a new project doesn't have an asset file
throw new InvalidOperationException($"{projectAssetsFilePath} not found. Please run 'dotnet restore'");
}

// Old csproj

var oldStylePackageReferences = analyzerResult.GetItems("Reference").Where(x => x.ItemSpec.Contains("Version"));
Expand Down
13 changes: 7 additions & 6 deletions src/Depends.Core/Depends.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>0.4.0</Version>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>0.5.0</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="buildalyzer" Version="2.3.0" />
<PackageReference Include="NuGet.ProjectModel" Version="5.3.0" />
<PackageReference Include="Buildalyzer" Version="3.0.1" />
<PackageReference Include="NuGet.ProjectModel" Version="5.7.0" />

<!-- The below is only to not run into incompatibilites with the NuGet version loaded by MSBuild -->
<PackageReference Include="NuGet.Build.Tasks" Version="5.3.0" />
<PackageReference Include="NuGet.Resolver" Version="5.3.0" />
<PackageReference Include="NuGet.Build.Tasks" Version="5.7.0" />
<PackageReference Include="NuGet.Resolver" Version="5.7.0" />
<PackageReference Include="NuGet.Common" Version="5.7.0" />
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions src/Depends.Core/Extensions/AnalyzerResultExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ namespace Depends.Core.Extensions
{
internal static class AnalyzerResultExtensions
{
public static NuGetFramework GetTargetFramework(this AnalyzerResult result) =>
public static NuGetFramework GetTargetFramework(this IAnalyzerResult result) =>
NuGetFramework.Parse(result.TargetFramework, DefaultFrameworkNameProvider.Instance);

public static bool IsNetSdkProject(this AnalyzerResult result) =>
public static bool IsNetSdkProject(this IAnalyzerResult result) =>
string.Equals(bool.TrueString, result.GetProperty("UsingMicrosoftNETSdk"),
StringComparison.InvariantCultureIgnoreCase);

public static string GetProjectAssetsFilePath(this AnalyzerResult result) =>
public static string GetProjectAssetsFilePath(this IAnalyzerResult result) =>
result.GetProperty("ProjectAssetsFile");

public static string GetRuntimeIdentifier(this AnalyzerResult result) =>
public static string GetRuntimeIdentifier(this IAnalyzerResult result) =>
result.GetProperty("RuntimeIdentifier");

public static IEnumerable<ProjectItem> GetItems(this AnalyzerResult result, string name) =>
public static IEnumerable<ProjectItem> GetItems(this IAnalyzerResult result, string name) =>
result.Items.TryGetValue(name, out var items) ? items : Enumerable.Empty<ProjectItem>();
}
}
8 changes: 4 additions & 4 deletions src/Depends/Depends.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ToolCommandName>dotnet-depends</ToolCommandName>
<PackAsTool>True</PackAsTool>
<OutputType>Exe</OutputType>
<Version>0.4.0</Version>
<Version>0.5.0</Version>
<PackageId>dotnet-depends</PackageId>
<Title>dotnet-depends</Title>
<Authors>mholo65</Authors>
Expand All @@ -16,8 +16,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.0.0" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.4.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.8" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="3.0.0" />
<PackageReference Include="Terminal.Gui" Version="0.81.0" />
</ItemGroup>

Expand Down
10 changes: 5 additions & 5 deletions src/Depends/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private ValidationResult OnValidate()
}

var fileAttributes = File.GetAttributes(Project);

// If a directory was passed in, search for a .sln or .proj file
if (fileAttributes.HasFlag(FileAttributes.Directory))
{
Expand All @@ -76,12 +76,12 @@ private ValidationResult OnValidate()
Project = Path.GetFullPath(solutionFiles[0]);
return ValidationResult.Success;
}

if (solutionFiles.Length > 1)
{
return new ValidationResult($"More than one solution file found in working directory.");
}

// We did not find any solutions, so try and find individual projects
var projectFiles = Directory.GetFiles(Project, "*.*proj").ToArray();

Expand All @@ -90,7 +90,7 @@ private ValidationResult OnValidate()
Project = Path.GetFullPath(projectFiles[0]);
return ValidationResult.Success;
}

if (projectFiles.Length > 1)
{
return new ValidationResult($"More than one project file found in working directory.");
Expand All @@ -110,8 +110,8 @@ private void OnExecute()
var loggerFactory = LoggerFactory.Create(builder => builder
.SetMinimumLevel(Verbosity)
.AddConsole());
var analyzer = new DependencyAnalyzer(loggerFactory);

var analyzer = new DependencyAnalyzer(loggerFactory);
DependencyGraph graph;
if (!string.IsNullOrEmpty(Package))
{
Expand Down

0 comments on commit 17b0e70

Please sign in to comment.