From 35a5aa78c13242ed36c07db171b721d5ddc1c3ea Mon Sep 17 00:00:00 2001
From: JoC0de <53140583+JoC0de@users.noreply.github.com>
Date: Mon, 9 Dec 2024 18:07:27 +0100
Subject: [PATCH 1/3] support reading package-source-credentials from system or
user nuget.config file
---
.config/dotnet-tools.json | 2 +-
.pre-commit-config.yaml | 2 +-
.../Configuration/ConfigurationManager.cs | 45 +++++++-
.../Editor/Configuration/NugetConfigFile.cs | 105 ++++++++++++------
.../Helper/NugetPackageTextureHelper.cs | 7 +-
.../PackageSource/INugetPackageSource.cs | 6 +
.../NugetPackageSourceCombined.cs | 11 ++
.../PackageSource/NugetPackageSourceLocal.cs | 11 ++
.../PackageSource/NugetPackageSourceV2.cs | 4 +
.../PackageSource/NugetPackageSourceV3.cs | 4 +
.../Editor/Ui/NugetPreferences.cs | 46 ++++----
11 files changed, 178 insertions(+), 65 deletions(-)
diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
index e0795de7..3f19b0fa 100644
--- a/.config/dotnet-tools.json
+++ b/.config/dotnet-tools.json
@@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"jetbrains.resharper.globaltools": {
- "version": "2024.2.4",
+ "version": "2024.3.0",
"commands": ["jb"],
"rollForward": false
}
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 7560abea..c3b8ba6f 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -30,7 +30,7 @@ repos:
files: \.cs$
pass_filenames: true
require_serial: true
- stages: [commit, merge-commit]
+ stages: [pre-commit, pre-merge-commit]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
diff --git a/src/NuGetForUnity/Editor/Configuration/ConfigurationManager.cs b/src/NuGetForUnity/Editor/Configuration/ConfigurationManager.cs
index 4b55a4b2..f51bba77 100644
--- a/src/NuGetForUnity/Editor/Configuration/ConfigurationManager.cs
+++ b/src/NuGetForUnity/Editor/Configuration/ConfigurationManager.cs
@@ -149,6 +149,7 @@ public static void LoadNugetConfigFile()
if (File.Exists(NugetConfigFilePath))
{
nugetConfigFile = NugetConfigFile.Load(NugetConfigFilePath);
+ InjectSettingsFromGlobalNugetConfigFile();
}
else
{
@@ -210,7 +211,7 @@ public static void LoadNugetConfigFile()
/// This allows searching for partial IDs or even the empty string (the default) to list ALL packages.
///
/// The search term to use to filter packages. Defaults to the empty string.
- /// True to include prerelease packages (alpha, beta, etc).
+ /// True to include pre-release packages (alpha, beta, etc).
/// The number of packages to fetch.
/// The number of packages to skip before fetching.
/// Token that can be used to cancel the asynchronous task.
@@ -228,10 +229,10 @@ public static Task> SearchAsync(
}
///
- /// Queries all active nuget package source's with the given list of installed packages to get any updates that are available.
+ /// Queries all active NuGet package source's with the given list of installed packages to get any updates that are available.
///
- /// The list of currently installed packages for which updates are searched.
- /// True to include prerelease packages (alpha, beta, etc).
+ /// The list of currently installed packages for witch updates are searched.
+ /// True to include pre-release packages (alpha, beta, etc).
/// The specific frameworks to target?.
/// The version constraints?.
/// A list of all updates available.
@@ -275,5 +276,41 @@ internal static void MoveConfig(PackageInstallLocation newInstallLocation)
NugetConfigFilePath = newConfigFilePath;
NugetConfigFileDirectoryPath = newConfigsPath;
}
+
+ ///
+ /// Add package source credentials from a "external" package config file if the file exists.
+ /// The location of global config is the same as the one used by NuGet CLI
+ /// .
+ ///
+ private static void InjectSettingsFromGlobalNugetConfigFile()
+ {
+ var userSettingsFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NuGet", "NuGet.Config");
+
+ nugetConfigFile.FillMissingPackageCredentialsFromExternalFile(userSettingsFilePath);
+
+ string machineWideBaseDir;
+ var configEnvirnonmentVariable = Environment.GetEnvironmentVariable("NUGET_COMMON_APPLICATION_DATA");
+ if (!string.IsNullOrEmpty(configEnvirnonmentVariable))
+ {
+ machineWideBaseDir = configEnvirnonmentVariable;
+ }
+ else if (Application.platform == RuntimePlatform.WindowsEditor)
+ {
+ machineWideBaseDir = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
+ if (string.IsNullOrEmpty(machineWideBaseDir))
+ {
+ // On 32-bit Windows
+ machineWideBaseDir = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
+ }
+ }
+ else
+ {
+ machineWideBaseDir = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
+ }
+
+ machineWideBaseDir = Path.Combine(machineWideBaseDir, "NuGet");
+ var machineWideConfigFilePath = Path.Combine(machineWideBaseDir, "Config", "NuGet.Config");
+ nugetConfigFile.FillMissingPackageCredentialsFromExternalFile(machineWideConfigFilePath);
+ }
}
}
diff --git a/src/NuGetForUnity/Editor/Configuration/NugetConfigFile.cs b/src/NuGetForUnity/Editor/Configuration/NugetConfigFile.cs
index 1d4a3cf7..5da0f0a2 100644
--- a/src/NuGetForUnity/Editor/Configuration/NugetConfigFile.cs
+++ b/src/NuGetForUnity/Editor/Configuration/NugetConfigFile.cs
@@ -301,42 +301,7 @@ public static NugetConfigFile Load([NotNull] string filePath)
}
// set all listed passwords for package source credentials
- var packageSourceCredentials = file.Root?.Element("packageSourceCredentials");
- if (packageSourceCredentials != null)
- {
- foreach (var sourceElement in packageSourceCredentials.Elements())
- {
- var name = XmlConvert.DecodeName(sourceElement.Name.LocalName);
- var source = configFile.PackageSources.Find(p => p.Name == name);
- if (source == null)
- {
- continue;
- }
-
- var adds = sourceElement.Elements("add");
- foreach (var add in adds)
- {
- var keyName = add.Attribute("key")?.Value;
- if (string.Equals(keyName, "userName", StringComparison.OrdinalIgnoreCase))
- {
- var userName = add.Attribute("value")?.Value;
- source.UserName = userName;
- }
- else if (string.Equals(keyName, "clearTextPassword", StringComparison.OrdinalIgnoreCase))
- {
- var password = add.Attribute("value")?.Value;
- source.SavedPassword = password;
- source.SavedPasswordIsEncrypted = false;
- }
- else if (string.Equals(keyName, PasswordAttributeName, StringComparison.OrdinalIgnoreCase))
- {
- var encryptedPassword = add.Attribute("value")?.Value;
- source.SavedPassword = encryptedPassword;
- source.SavedPasswordIsEncrypted = true;
- }
- }
- }
- }
+ configFile.FillPackageSourceCredentialsFromConfig(file, false);
// read the configuration data
var config = file.Root?.Element("config");
@@ -483,7 +448,7 @@ public void Save([NotNull] string filePath)
disabledPackageSources.Add(addElement);
}
- if (source.HasPassword)
+ if (source.HasPassword && !source.CredentialsStoredInExternalFile)
{
var sourceElement = new XElement(XmlConvert.EncodeName(source.Name) ?? string.Empty);
packageSourceCredentials.Add(sourceElement);
@@ -644,5 +609,71 @@ internal void ChangeInstallLocation(PackageInstallLocation newInstallLocation)
File.Move(configMeta, newConfigPath + ".meta");
}
}
+
+ ///
+ /// Add package source credentials from a "external" package config file if the file exists and contains credentials
+ /// for package-sources defined in the main NuGet.config file from NuGetForUnity.
+ ///
+ /// The file to try loading missing package-source-credentials from.
+ internal void FillMissingPackageCredentialsFromExternalFile([NotNull] string filePath)
+ {
+ if (!File.Exists(filePath))
+ {
+ return;
+ }
+
+ try
+ {
+ var file = XDocument.Load(filePath);
+ FillPackageSourceCredentialsFromConfig(file, true);
+ }
+ catch (Exception exception)
+ {
+ Debug.LogError($"Error while loading file: '{filePath}'. Error: {exception}");
+ }
+ }
+
+ private void FillPackageSourceCredentialsFromConfig(XDocument file, bool overwriteMissingFromExternal)
+ {
+ var packageSourceCredentials = file.Root?.Element("packageSourceCredentials");
+ if (packageSourceCredentials == null)
+ {
+ return;
+ }
+
+ foreach (var sourceElement in packageSourceCredentials.Elements())
+ {
+ var name = XmlConvert.DecodeName(sourceElement.Name.LocalName);
+ var source = PackageSources.Find(p => p.Name == name);
+ if (source == null || (overwriteMissingFromExternal && !string.IsNullOrEmpty(source.SavedPassword)))
+ {
+ continue;
+ }
+
+ source.CredentialsStoredInExternalFile = overwriteMissingFromExternal;
+ var adds = sourceElement.Elements("add");
+ foreach (var add in adds)
+ {
+ var keyName = add.Attribute("key")?.Value;
+ if (string.Equals(keyName, "userName", StringComparison.OrdinalIgnoreCase))
+ {
+ var userName = add.Attribute("value")?.Value;
+ source.UserName = userName;
+ }
+ else if (string.Equals(keyName, "clearTextPassword", StringComparison.OrdinalIgnoreCase))
+ {
+ var password = add.Attribute("value")?.Value;
+ source.SavedPassword = password;
+ source.SavedPasswordIsEncrypted = false;
+ }
+ else if (string.Equals(keyName, PasswordAttributeName, StringComparison.OrdinalIgnoreCase))
+ {
+ var encryptedPassword = add.Attribute("value")?.Value;
+ source.SavedPassword = encryptedPassword;
+ source.SavedPasswordIsEncrypted = true;
+ }
+ }
+ }
+ }
}
}
diff --git a/src/NuGetForUnity/Editor/Helper/NugetPackageTextureHelper.cs b/src/NuGetForUnity/Editor/Helper/NugetPackageTextureHelper.cs
index 58de7198..5ed23982 100644
--- a/src/NuGetForUnity/Editor/Helper/NugetPackageTextureHelper.cs
+++ b/src/NuGetForUnity/Editor/Helper/NugetPackageTextureHelper.cs
@@ -1,5 +1,9 @@
#pragma warning disable SA1512,SA1124 // Single-line comments should not be followed by blank line
+#if UNITY_2022_1_OR_NEWER
+using UnityEditor;
+#endif
+
using System;
using System.IO;
using System.Security.Cryptography;
@@ -8,9 +12,6 @@
using JetBrains.Annotations;
using UnityEngine;
using UnityEngine.Networking;
-#if UNITY_2022_1_OR_NEWER
-using UnityEditor;
-#endif
#region No ReShaper
diff --git a/src/NuGetForUnity/Editor/PackageSource/INugetPackageSource.cs b/src/NuGetForUnity/Editor/PackageSource/INugetPackageSource.cs
index bc1ae07e..fa32a0ee 100644
--- a/src/NuGetForUnity/Editor/PackageSource/INugetPackageSource.cs
+++ b/src/NuGetForUnity/Editor/PackageSource/INugetPackageSource.cs
@@ -58,6 +58,12 @@ public interface INugetPackageSource : IDisposable
///
bool HasPassword { get; set; }
+ ///
+ /// Gets or sets a value indicating whether the and are
+ /// injected from a external file so it should not be stored in the NugetForUnity own configuration.
+ ///
+ bool CredentialsStoredInExternalFile { get; set; }
+
///
/// Download the .nupkg file and store it inside a file at .
///
diff --git a/src/NuGetForUnity/Editor/PackageSource/NugetPackageSourceCombined.cs b/src/NuGetForUnity/Editor/PackageSource/NugetPackageSourceCombined.cs
index 27b6eb60..de06f262 100644
--- a/src/NuGetForUnity/Editor/PackageSource/NugetPackageSourceCombined.cs
+++ b/src/NuGetForUnity/Editor/PackageSource/NugetPackageSourceCombined.cs
@@ -107,6 +107,17 @@ public bool HasPassword
}
}
+ ///
+ public bool CredentialsStoredInExternalFile
+ {
+ get => false;
+
+ set
+ {
+ // multiple sources can't have passwords
+ }
+ }
+
///
public List FindPackagesById(INugetPackageIdentifier package)
{
diff --git a/src/NuGetForUnity/Editor/PackageSource/NugetPackageSourceLocal.cs b/src/NuGetForUnity/Editor/PackageSource/NugetPackageSourceLocal.cs
index 41ff6435..e03fbfa1 100644
--- a/src/NuGetForUnity/Editor/PackageSource/NugetPackageSourceLocal.cs
+++ b/src/NuGetForUnity/Editor/PackageSource/NugetPackageSourceLocal.cs
@@ -96,6 +96,17 @@ public bool HasPassword
}
}
+ ///
+ public bool CredentialsStoredInExternalFile
+ {
+ get => false;
+
+ set
+ {
+ // local sources don't have credentials
+ }
+ }
+
///
/// Gets path, with the values of environment variables expanded.
///
diff --git a/src/NuGetForUnity/Editor/PackageSource/NugetPackageSourceV2.cs b/src/NuGetForUnity/Editor/PackageSource/NugetPackageSourceV2.cs
index ff786fc9..730225b5 100644
--- a/src/NuGetForUnity/Editor/PackageSource/NugetPackageSourceV2.cs
+++ b/src/NuGetForUnity/Editor/PackageSource/NugetPackageSourceV2.cs
@@ -87,6 +87,10 @@ public string ExpandedPath
[field: SerializeField]
public string SavedPassword { get; set; }
+ ///
+ [field: SerializeField]
+ public bool CredentialsStoredInExternalFile { get; set; }
+
///
/// Gets password, with the values of environment variables expanded.
///
diff --git a/src/NuGetForUnity/Editor/PackageSource/NugetPackageSourceV3.cs b/src/NuGetForUnity/Editor/PackageSource/NugetPackageSourceV3.cs
index ed82bb84..dbe1473c 100644
--- a/src/NuGetForUnity/Editor/PackageSource/NugetPackageSourceV3.cs
+++ b/src/NuGetForUnity/Editor/PackageSource/NugetPackageSourceV3.cs
@@ -124,6 +124,10 @@ public string PackageDownloadUrlTemplateOverwrite
[field: SerializeField]
public string SavedPassword { get; set; }
+ ///
+ [field: SerializeField]
+ public bool CredentialsStoredInExternalFile { get; set; }
+
///
[field: SerializeField]
public bool IsEnabled { get; set; }
diff --git a/src/NuGetForUnity/Editor/Ui/NugetPreferences.cs b/src/NuGetForUnity/Editor/Ui/NugetPreferences.cs
index 13cc3eba..3a56f05c 100644
--- a/src/NuGetForUnity/Editor/Ui/NugetPreferences.cs
+++ b/src/NuGetForUnity/Editor/Ui/NugetPreferences.cs
@@ -12,6 +12,7 @@
using NugetForUnity.PluginSupport;
using UnityEditor;
using UnityEngine;
+using static UnityEditor.EditorGUI;
#region No ReShaper
@@ -433,32 +434,39 @@ public override void OnGUI([CanBeNull] string searchContext)
}
}
- var hasPassword = EditorGUILayout.Toggle("Credentials", source.HasPassword);
- if (hasPassword != source.HasPassword)
+ using (new DisabledGroupScope(source.CredentialsStoredInExternalFile))
{
- preferencesChangedThisFrame = true;
- source.HasPassword = hasPassword;
- }
-
- if (source.HasPassword)
- {
- var userName = EditorGUILayout.TextField("User Name", source.UserName);
- if (userName != source.UserName)
+ var hasPassword = EditorGUILayout.Toggle(
+ new GUIContent(
+ "Credentials",
+ source.CredentialsStoredInExternalFile ? "Imported from system NuGet.config file" : string.Empty),
+ source.HasPassword);
+ if (hasPassword != source.HasPassword)
{
preferencesChangedThisFrame = true;
- source.UserName = userName;
+ source.HasPassword = hasPassword;
}
- var savedPassword = EditorGUILayout.PasswordField("Password", source.SavedPassword);
- if (savedPassword != source.SavedPassword)
+ if (source.HasPassword)
{
- preferencesChangedThisFrame = true;
- source.SavedPassword = savedPassword;
+ var userName = EditorGUILayout.TextField("User Name", source.UserName);
+ if (userName != source.UserName)
+ {
+ preferencesChangedThisFrame = true;
+ source.UserName = userName;
+ }
+
+ var savedPassword = EditorGUILayout.PasswordField("Password", source.SavedPassword);
+ if (savedPassword != source.SavedPassword)
+ {
+ preferencesChangedThisFrame = true;
+ source.SavedPassword = savedPassword;
+ }
+ }
+ else
+ {
+ source.UserName = null;
}
- }
- else
- {
- source.UserName = null;
}
EditorGUIUtility.labelWidth = 0;
From d5839480b8a8a9995873d2003161aafa9b3342aa Mon Sep 17 00:00:00 2001
From: JoC0de <53140583+JoC0de@users.noreply.github.com>
Date: Mon, 9 Dec 2024 23:24:05 +0100
Subject: [PATCH 2/3] add documentation for new feature
---
.github/issue_template.md | 8 +-
.pre-commit-config.yaml | 8 +-
CONTRIBUTING.md | 82 +++++++++----------
README.md | 12 ++-
plugin-dev-readme.md | 20 ++---
.../Assets/Tests/Resources/NuGet.config | 4 +-
.../Assets/packages.config | 4 +-
7 files changed, 71 insertions(+), 67 deletions(-)
diff --git a/.github/issue_template.md b/.github/issue_template.md
index 175e3489..5b20116d 100644
--- a/.github/issue_template.md
+++ b/.github/issue_template.md
@@ -2,7 +2,7 @@
[Describe the issue you have. If applicable provide logs produced by enabling verbose logging in the NuGetForUnity settings.]
-- **NuGet Package:** [What is the name and version of the NuGet package you are installing?]
-- **NuGetForUnity Version:** [What version of NuGetForUnity are you running?]
-- **Unity Version:** [What version of Unity are you using?]
-- **Operating System:** [What OS are you on?]
+- **NuGet Package:** [What is the name and version of the NuGet package you are installing?]
+- **NuGetForUnity Version:** [What version of NuGetForUnity are you running?]
+- **Unity Version:** [What version of Unity are you using?]
+- **Operating System:** [What OS are you on?]
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index c3b8ba6f..144f8cbd 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -3,13 +3,13 @@
exclude: "^.git$"
repos:
- repo: https://github.com/JoC0de/pre-commit-prettier
- rev: "a6a5f3906583670deecd1c24ffd0db574dbd9a06"
+ rev: "v3.4.2"
hooks:
- id: prettier
additional_dependencies:
- - prettier@3.3.3
+ - prettier@3.4.2
- "@prettier/plugin-xml@3.4.1"
- - "prettier-plugin-ini@1.2.0"
+ - "prettier-plugin-ini@1.3.0"
args:
- --plugin=prettier-plugin-ini
files: Directory\.Build\.props$|(\.(json|xml|html|config|csproj|xlf|DotSettings|yaml|yml|js|md|xrml|xaml|css|editorconfig)$)
@@ -32,7 +32,7 @@ repos:
require_serial: true
stages: [pre-commit, pre-merge-commit]
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v4.6.0
+ rev: v5.0.0
hooks:
- id: trailing-whitespace
exclude: \.(pdf|meta|prefab|shader|controller|asset|cginc|mat|unity|anim|shadergraph)$
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index f56fdb87..af33db8f 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -8,24 +8,24 @@ All types of contributions are encouraged and valued. See the [Table of Contents
> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about:
>
-> - Star the project
-> - Tweet about it
-> - Refer this project in your project's readme
-> - Mention the project at local meetups and tell your friends/colleagues
+> - Star the project
+> - Tweet about it
+> - Refer this project in your project's readme
+> - Mention the project at local meetups and tell your friends/colleagues
## Table of Contents
-- [I Have a Question](#i-have-a-question)
-- [I Want To Contribute](#i-want-to-contribute)
-- [Reporting Bugs](#reporting-bugs)
-- [Suggesting Enhancements](#suggesting-enhancements)
-- [Pull Requests](#pull-requests)
-- [Development Environment Setup](#development-environment-setup)
-- [Running Unit Tests](#running-unit-tests)
-- [Code Style](#code-style)
-- [Auto Formatter](#auto-formatter)
+- [I Have a Question](#i-have-a-question)
+- [I Want To Contribute](#i-want-to-contribute)
+- [Reporting Bugs](#reporting-bugs)
+- [Suggesting Enhancements](#suggesting-enhancements)
+- [Pull Requests](#pull-requests)
+- [Development Environment Setup](#development-environment-setup)
+- [Running Unit Tests](#running-unit-tests)
+- [Code Style](#code-style)
+- [Auto Formatter](#auto-formatter)
## I Have a Question
@@ -35,9 +35,9 @@ Before you ask a question, it is best to search for existing [Issues](https://gi
If you then still feel the need to ask a question and need clarification, we recommend the following:
-- Open an [Issue](https://github.com/GlitchEnzo/NuGetForUnity/issues/new).
-- Provide as much context as you can about what you're running into.
-- Provide project, Unity and package versions.
+- Open an [Issue](https://github.com/GlitchEnzo/NuGetForUnity/issues/new).
+- Provide as much context as you can about what you're running into.
+- Provide project, Unity and package versions.
We will then take care of the issue as soon as possible.
@@ -55,13 +55,13 @@ We will then take care of the issue as soon as possible.
A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible.
-- Make sure that you are using the latest version.
-- Determine if your bug is related to on of the issues mentioned under [Common issues when installing NuGet packages](https://github.com/GlitchEnzo/NuGetForUnity#common-issues-when-installing-nuget-packages).
-- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [Issues](https://github.com/GlitchEnzo/NuGetForUnity/issues).
-- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue.
-- Collect information about the bug:
-- Get logs produced by enabling verbose logging in the [NuGetForUnity settings](docs/screenshots/preferences.png)
-- Can you reliably reproduce the issue? And can you also reproduce it with older versions?
+- Make sure that you are using the latest version.
+- Determine if your bug is related to on of the issues mentioned under [Common issues when installing NuGet packages](https://github.com/GlitchEnzo/NuGetForUnity#common-issues-when-installing-nuget-packages).
+- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [Issues](https://github.com/GlitchEnzo/NuGetForUnity/issues).
+- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue.
+- Collect information about the bug:
+- Get logs produced by enabling verbose logging in the [NuGetForUnity settings](docs/screenshots/preferences.png)
+- Can you reliably reproduce the issue? And can you also reproduce it with older versions?
@@ -69,10 +69,10 @@ A good bug report shouldn't leave others needing to chase you up for more inform
We use GitHub issues to track bugs and errors. If you run into an issue with the project:
-- Open an [Issue](https://github.com/GlitchEnzo/NuGetForUnity/issues/new).
-- Explain the behavior you would expect and the actual behavior.
-- Please provide as much context as possible and describe the _reproduction steps_ that someone else can follow to recreate the issue on their own.
-- Provide the information you collected in the previous section.
+- Open an [Issue](https://github.com/GlitchEnzo/NuGetForUnity/issues/new).
+- Explain the behavior you would expect and the actual behavior.
+- Please provide as much context as possible and describe the _reproduction steps_ that someone else can follow to recreate the issue on their own.
+- Provide the information you collected in the previous section.
We will then take care of the issue as soon as possible.
@@ -84,10 +84,10 @@ This section guides you through submitting an enhancement suggestion for NuGetFo
#### Before Submitting an Enhancement
-- Make sure that you are using the latest version.
-- Read the [Documentation (README.md)](https://github.com/GlitchEnzo/NuGetForUnity#readme) carefully and find out if the functionality is already covered, maybe by an individual configuration.
-- Perform a [search](https://github.com/GlitchEnzo/NuGetForUnity/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
-- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature.
+- Make sure that you are using the latest version.
+- Read the [Documentation (README.md)](https://github.com/GlitchEnzo/NuGetForUnity#readme) carefully and find out if the functionality is already covered, maybe by an individual configuration.
+- Perform a [search](https://github.com/GlitchEnzo/NuGetForUnity/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
+- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature.
@@ -95,21 +95,21 @@ This section guides you through submitting an enhancement suggestion for NuGetFo
Enhancement suggestions are tracked as [GitHub issues](https://github.com/GlitchEnzo/NuGetForUnity/issues).
-- Use a **clear and descriptive title** for the issue to identify the suggestion.
-- Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
-- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you.
-- **Explain why this enhancement would be useful** to most NuGetForUnity users. You may also want to point out the other projects that solved it better and which could serve as inspiration.
+- Use a **clear and descriptive title** for the issue to identify the suggestion.
+- Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
+- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you.
+- **Explain why this enhancement would be useful** to most NuGetForUnity users. You may also want to point out the other projects that solved it better and which could serve as inspiration.
### Pull Requests
We are using pull requests to add new features, no direct commits to master. To develop a new feature:
-- First create a branch on your own fork.
-- When you finish the development create a [Pull Request](https://github.com/GlitchEnzo/NuGetForUnity/pulls).
-- We will then review the changes.
-- The [GitHub Action](.github/workflows/main.yml) will enure everything builds, the unit tests are running successfully and some [test projects](src/TestProjects) that include NuGet packages imported using NuGetForUnity build successfully.
-- The [GitHub Action](.github/workflows/main.yml) also creates a pre-release `.unitypackage` from the build to be able to import it in any Unity project without needing to wait for a new official release.
-- If everything is working and fits our [Code Style](#code-style) we will merge the pull request. When merging please use the `Squash and merge` merge strategy to keep the commit history clean.
+- First create a branch on your own fork.
+- When you finish the development create a [Pull Request](https://github.com/GlitchEnzo/NuGetForUnity/pulls).
+- We will then review the changes.
+- The [GitHub Action](.github/workflows/main.yml) will enure everything builds, the unit tests are running successfully and some [test projects](src/TestProjects) that include NuGet packages imported using NuGetForUnity build successfully.
+- The [GitHub Action](.github/workflows/main.yml) also creates a pre-release `.unitypackage` from the build to be able to import it in any Unity project without needing to wait for a new official release.
+- If everything is working and fits our [Code Style](#code-style) we will merge the pull request. When merging please use the `Squash and merge` merge strategy to keep the commit history clean.
### Development Environment Setup
diff --git a/README.md b/README.md
index 1c102f38..8e94a674 100644
--- a/README.md
+++ b/README.md
@@ -212,6 +212,10 @@ Requires `protocolVersion` set to `3` the other required settings like `packageD
```
+### Storing credentials outside of the project `NuGet.config` file
+
+When using a custom NuGet server that requires a `UserName` and a `Password` you probably wouldn't store it in the `NuGet.config` file that is stored in the Unity Project as it will be committed to source control. So we support loading the `packageSourceCredentials` section from the system or user-specific `nuget.config` file. The storage location of the system or user-specific `nuget.config` file is documented at [Microsoft's NuGet Configuration](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior) (e.g. on Windows `%appdata%\NuGet\NuGet.Config`).
+
## Disable automatic referencing of assemblies
To disable the automatic referencing of assemblies of a NuGet package you can set the `autoReferenced` attribute of a package inside the `packages.config` to `false`. _Currently this setting is not available from UI._
@@ -249,8 +253,8 @@ You can use [NuGet.Server](http://nugetserver.net/), [NuGet Gallery](https://git
Alternatively, you can use a "local feed" which is just a folder on your hard-drive or a network share. [Local NuGet feeds](https://learn.microsoft.com/en-us/nuget/hosting-packages/local-feeds) can have two different structures:
-- flat: <local feed path>/<package id>.<package version>.nupkg
-- hierarchical: <local feed path>/<package id>/<package version>/<package id>.<package version>.nupkg
+- flat: <local feed path>/<package id>.<package version>.nupkg
+- hierarchical: <local feed path>/<package id>/<package version>/<package id>.<package version>.nupkg
Be sure to set the proper URL/path in the _NuGet.config_ file and you should be good to go!
@@ -262,8 +266,8 @@ For those with projects using automated build solutions like [continuous integra
## Installation
-- System-wide as a global tool using: `dotnet tool install --global NuGetForUnity.Cli`.
-- Project / folder wide as a local tool using: A tool manifest (local tool installation context) can be created with: `dotnet new tool-manifest`. Than install NuGetForUnity.Cli using: `dotnet tool install NuGetForUnity.Cli`. Than add the tool manifest `.config/dotnet-tools.json` to your version control system.
+- System-wide as a global tool using: `dotnet tool install --global NuGetForUnity.Cli`.
+- Project / folder wide as a local tool using: A tool manifest (local tool installation context) can be created with: `dotnet new tool-manifest`. Than install NuGetForUnity.Cli using: `dotnet tool install NuGetForUnity.Cli`. Than add the tool manifest `.config/dotnet-tools.json` to your version control system.
For more information see [.Net Tool Documentation](https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools).
diff --git a/plugin-dev-readme.md b/plugin-dev-readme.md
index baa80bfe..9eb8dc9b 100644
--- a/plugin-dev-readme.md
+++ b/plugin-dev-readme.md
@@ -14,10 +14,10 @@ In order to develop a NuGetForUnity Plugin you need to start with these steps:
Note that `INugetPluginRegistry` provides you a few things you can use in your plugin:
-- `IsRunningInUnity` property will be true if the plugin is being run from Unity and false if it is run from command line.
-- `PluginService` property that you can pass to your custom handlers if they need to use any of these:
- - `ProjectAssetsDir` property that gives you the absolute path to the project's Assets directory.
- - `LogError`, `LogErrorFormat` and `LogVerbose` methods that you can use for logging. You should not use `UnityEngine.Debug.Log` methods since they will not work if plugin is used from command line.
+- `IsRunningInUnity` property will be true if the plugin is being run from Unity and false if it is run from command line.
+- `PluginService` property that you can pass to your custom handlers if they need to use any of these:
+ - `ProjectAssetsDir` property that gives you the absolute path to the project's Assets directory.
+ - `LogError`, `LogErrorFormat` and `LogVerbose` methods that you can use for logging. You should not use `UnityEngine.Debug.Log` methods since they will not work if plugin is used from command line.
## Extension points
@@ -66,10 +66,10 @@ void HandleUninstalledAll();
The first method is called for each package that is being uninstalled. The `uninstallReason` can be:
-- `IndividualUninstall` when individual package uninstall has be requested by the user.
-- `UninstallAll` when user requested all packages from the project to be uninstalled.
-- `IndividualUpdate` when user requested a package to be updated so we are uninstalling the current version.
-- `UpdateAll` when user requested all packages to be updated so we are uninstalling old versions.
+- `IndividualUninstall` when individual package uninstall has be requested by the user.
+- `UninstallAll` when user requested all packages from the project to be uninstalled.
+- `IndividualUpdate` when user requested a package to be updated so we are uninstalling the current version.
+- `UpdateAll` when user requested all packages to be updated so we are uninstalling old versions.
The second method, `HandleUninstalledAll()` will only be called if user requested all packages to be uninstalled after all the default uninstall processing has been done. If you don't need to do anything special in this case you can leave this method empty.
@@ -87,8 +87,8 @@ PluginAPI project is setup so that it copies the built NugetForUnity.PluginAPI.d
CreateDll project has two classes under PluginSupport folder:
-- `NugetPluginSupport` which implements the `INugetPluginService`
-- `PluginRegistry` that implements `INugetPluginRegistry` and also has `InitPlugins` method that is called after Nuget.config is loaded and a list of enabled plugins is read from it.
+- `NugetPluginSupport` which implements the `INugetPluginService`
+- `PluginRegistry` that implements `INugetPluginRegistry` and also has `InitPlugins` method that is called after Nuget.config is loaded and a list of enabled plugins is read from it.
Note that `AssemblyLoader` class it uses to load the plugins has a different implementation in `NuGetForUnity.Cli` project which is for running from command line. It also has a different implementation of `SessionStorage` class that will return "false" for `IsRunningInUnity` key.
diff --git a/src/NuGetForUnity.Tests/Assets/Tests/Resources/NuGet.config b/src/NuGetForUnity.Tests/Assets/Tests/Resources/NuGet.config
index 8362190c..d1dbc133 100644
--- a/src/NuGetForUnity.Tests/Assets/Tests/Resources/NuGet.config
+++ b/src/NuGetForUnity.Tests/Assets/Tests/Resources/NuGet.config
@@ -1,4 +1,4 @@
-
+
@@ -21,4 +21,4 @@
-
\ No newline at end of file
+
diff --git a/src/NuGetForUnity.Tests/Assets/packages.config b/src/NuGetForUnity.Tests/Assets/packages.config
index 3299dfcf..8f2c3662 100644
--- a/src/NuGetForUnity.Tests/Assets/packages.config
+++ b/src/NuGetForUnity.Tests/Assets/packages.config
@@ -1,2 +1,2 @@
-
-
\ No newline at end of file
+
+
From a416b2239e6bfeed43c53c30f866f648282c1039 Mon Sep 17 00:00:00 2001
From: JoC0de <53140583+JoC0de@users.noreply.github.com>
Date: Mon, 9 Dec 2024 23:36:18 +0100
Subject: [PATCH 3/3] fix spelling
---
README.md | 2 +-
.../Editor/Configuration/ConfigurationManager.cs | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index 8e94a674..fe72aa7c 100644
--- a/README.md
+++ b/README.md
@@ -214,7 +214,7 @@ Requires `protocolVersion` set to `3` the other required settings like `packageD
### Storing credentials outside of the project `NuGet.config` file
-When using a custom NuGet server that requires a `UserName` and a `Password` you probably wouldn't store it in the `NuGet.config` file that is stored in the Unity Project as it will be committed to source control. So we support loading the `packageSourceCredentials` section from the system or user-specific `nuget.config` file. The storage location of the system or user-specific `nuget.config` file is documented at [Microsoft's NuGet Configuration](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior) (e.g. on Windows `%appdata%\NuGet\NuGet.Config`).
+When using a custom NuGet server that requires a `UserName` and a `Password`, you probably wouldn't store it in the `NuGet.config` file that is stored in the Unity Project as it will be committed to source control. Therefore, we support loading the `packageSourceCredentials` section from the system or user-specific `nuget.config` file. The storage location of the system or user-specific `nuget.config` files are documented at [Microsoft's NuGet Configuration](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior) (e.g., on Windows `%AppData%\NuGet\NuGet.Config`).
## Disable automatic referencing of assemblies
diff --git a/src/NuGetForUnity/Editor/Configuration/ConfigurationManager.cs b/src/NuGetForUnity/Editor/Configuration/ConfigurationManager.cs
index f51bba77..2f514710 100644
--- a/src/NuGetForUnity/Editor/Configuration/ConfigurationManager.cs
+++ b/src/NuGetForUnity/Editor/Configuration/ConfigurationManager.cs
@@ -231,7 +231,7 @@ public static Task> SearchAsync(
///
/// Queries all active NuGet package source's with the given list of installed packages to get any updates that are available.
///
- /// The list of currently installed packages for witch updates are searched.
+ /// The list of currently installed packages for which updates are searched.
/// True to include pre-release packages (alpha, beta, etc).
/// The specific frameworks to target?.
/// The version constraints?.
@@ -278,7 +278,7 @@ internal static void MoveConfig(PackageInstallLocation newInstallLocation)
}
///
- /// Add package source credentials from a "external" package config file if the file exists.
+ /// Add package source credentials from an 'external' package config file if the file exists.
/// The location of global config is the same as the one used by NuGet CLI
/// .
///
@@ -289,10 +289,10 @@ private static void InjectSettingsFromGlobalNugetConfigFile()
nugetConfigFile.FillMissingPackageCredentialsFromExternalFile(userSettingsFilePath);
string machineWideBaseDir;
- var configEnvirnonmentVariable = Environment.GetEnvironmentVariable("NUGET_COMMON_APPLICATION_DATA");
- if (!string.IsNullOrEmpty(configEnvirnonmentVariable))
+ var configEnvironmentVariable = Environment.GetEnvironmentVariable("NUGET_COMMON_APPLICATION_DATA");
+ if (!string.IsNullOrEmpty(configEnvironmentVariable))
{
- machineWideBaseDir = configEnvirnonmentVariable;
+ machineWideBaseDir = configEnvironmentVariable;
}
else if (Application.platform == RuntimePlatform.WindowsEditor)
{