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

Split NugetHelper code into separate classes #560

Merged
merged 11 commits into from
Aug 30, 2023
2 changes: 2 additions & 0 deletions src/GlobalShared.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=discoverability/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Nupkg/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=nuspec/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=prerelease/@EntryIndexedValue">True</s:Boolean>
</wpf:ResourceDictionary>
12 changes: 6 additions & 6 deletions src/NuGetForUnity.Cli/Fakes/UnityPreImportedLibraryResolver.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#nullable enable

using System.Collections.Generic;

namespace NugetForUnity
{
/// <summary>
Expand All @@ -10,13 +8,15 @@ namespace NugetForUnity
internal static class UnityPreImportedLibraryResolver
{
/// <summary>
/// Gets all libraries that are already imported by unity so we shouldn't / don't need to install them as NuGet packages.
/// Check if a package is already imported in the Unity project e.g. is a part of Unity.
/// </summary>
/// <returns>A set of all names of libraries that are already imported by unity.</returns>
internal static HashSet<string> GetAlreadyImportedLibs()
/// <param name="package">The package of witch the identifier is checked.</param>
/// <param name="log">Whether to log a message with the result of the check.</param>
/// <returns>If it is included in Unity.</returns>
public static bool IsAlreadyImportedInEngine(INugetPackageIdentifier package, bool log = true)
{
// the CLI is running outside of Unity so we can't easily detect what libraries are imported by the Unity Engine.
return new HashSet<string>();
return false;
}
}
}
6 changes: 6 additions & 0 deletions src/NuGetForUnity.Cli/NuGetForUnity.Cli.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=1D5FC5A9A430BE4E8B4B103E47C6F342/RelativePath/@EntryValue">..\..\GlobalShared.DotSettings</s:String>
<s:Boolean x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=1D5FC5A9A430BE4E8B4B103E47C6F342/@KeyIndexDefined">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/InjectedLayers/InjectedLayerCustomization/=File1D5FC5A9A430BE4E8B4B103E47C6F342/@KeyIndexDefined">True</s:Boolean>
<s:Double x:Key="/Default/Environment/InjectedLayers/InjectedLayerCustomization/=File1D5FC5A9A430BE4E8B4B103E47C6F342/RelativePriority/@EntryValue">1</s:Double>
</wpf:ResourceDictionary>
14 changes: 11 additions & 3 deletions src/NuGetForUnity.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@

namespace NuGetForUnity.Cli
{
/// <summary>
/// Simple command line interface to restore NuGet packages for Unity projects.
/// </summary>
public static class Program
{
private static readonly string[] HelpOptions = { "-?", "-h", "--help" };

private static string DefaultProjectPath => Directory.GetCurrentDirectory();

/// <summary>
/// Starting point of the application.
/// </summary>
/// <param name="args">The command line arguments.</param>
/// <returns>The application exit code.</returns>
public static int Main(string[] args)
{
var availableArguments = args.ToList();
Expand Down Expand Up @@ -52,7 +60,7 @@ public static int Main(string[] args)
Application.SetUnityProjectPath(projectPath);

// need to disable dependency installation as UnityPreImportedLibraryResolver.GetAlreadyImportedLibs is not working outside Unity.
NugetHelper.Restore(false);
NugetPackageRestorer.Restore(false);
FixRoslynAnalyzerImportSettings();
return Debug.HasError ? 1 : 0;
}
Expand All @@ -72,13 +80,13 @@ private static void FixRoslynAnalyzerImportSettings()
return;
}

if (NugetHelper.NugetConfigFile == null || !Directory.Exists(NugetHelper.NugetConfigFile.RepositoryPath))
if (!Directory.Exists(ConfigurationManager.NugetConfigFile.RepositoryPath))
{
return;
}

UTF8Encoding? utf8NoBom = null;
foreach (var packageDirectoryPath in Directory.EnumerateDirectories(NugetHelper.NugetConfigFile.RepositoryPath))
foreach (var packageDirectoryPath in Directory.EnumerateDirectories(ConfigurationManager.NugetConfigFile.RepositoryPath))
{
var analyzersDirectoryPath = Path.Combine(packageDirectoryPath, "analyzers");
if (!Directory.Exists(analyzersDirectoryPath))
Expand Down
Loading
Loading