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

package-source-credentials in system or user nuget.config #678

Merged
merged 3 commits into from
Dec 11, 2024
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
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"jetbrains.resharper.globaltools": {
"version": "2024.2.4",
"version": "2024.3.0",
"commands": ["jb"],
"rollForward": false
}
Expand Down
8 changes: 4 additions & 4 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?]
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)$)
Expand All @@ -30,9 +30,9 @@ 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
rev: v5.0.0
hooks:
- id: trailing-whitespace
exclude: \.(pdf|meta|prefab|shader|controller|asset|cginc|mat|unity|anim|shadergraph)$
Expand Down
82 changes: 41 additions & 41 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<!-- omit in toc -->

## 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

Expand All @@ -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.

Expand All @@ -55,24 +55,24 @@ 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?

<!-- omit in toc -->

#### How Do I Submit a Good Bug Report?

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.

Expand All @@ -84,32 +84,32 @@ 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.

<!-- omit in toc -->

#### How Do I Submit a Good Enhancement Suggestion?

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

Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ Requires `protocolVersion` set to `3` the other required settings like `packageD
</configuration>
```

### 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. 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

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._
Expand Down Expand Up @@ -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: &lt;local feed path&gt;/&lt;package id&gt;.&lt;package version&gt;.nupkg
- hierarchical: &lt;local feed path&gt;/&lt;package id&gt;/&lt;package version&gt;/&lt;package id&gt;.&lt;package version&gt;.nupkg
- flat: &lt;local feed path&gt;/&lt;package id&gt;.&lt;package version&gt;.nupkg
- hierarchical: &lt;local feed path&gt;/&lt;package id&gt;/&lt;package version&gt;/&lt;package id&gt;.&lt;package version&gt;.nupkg

Be sure to set the proper URL/path in the _NuGet.config_ file and you should be good to go!

Expand All @@ -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).

Expand Down
20 changes: 10 additions & 10 deletions plugin-dev-readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.

Expand All @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions src/NuGetForUnity.Tests/Assets/Tests/Resources/NuGet.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
Expand All @@ -21,4 +21,4 @@
<add key="slimRestore" value="true" />
<add key="PreferNetStandardOverNetFramework" value="true" />
</config>
</configuration>
</configuration>
4 changes: 2 additions & 2 deletions src/NuGetForUnity.Tests/Assets/packages.config
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<packages />
<?xml version="1.0" encoding="utf-8" ?>
<packages />
Loading
Loading