Skip to content

Commit 0d3bd1d

Browse files
committed
Update documentation with Version Conflict handeling + new screenshots + allow using local package icons
1 parent c2477b9 commit 0d3bd1d

File tree

13 files changed

+85
-22
lines changed

13 files changed

+85
-22
lines changed

README.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ You can learn more about NuGet here: [nuget.org](https://www.nuget.org/)
66

77
NuGetForUnity provides a visual editor window to see available packages on the server, see installed packages, and see available package updates. A visual interface is also provided to create and edit _.nuspec_ files in order to define and publish your own NuGet packages from within Unity.
88

9-
![](screenshots/online.png?raw=true)
9+
<img alt="Online Packages Tap" src="docs/screenshots/online.png" height="500px" />
1010

1111
# How do I install NuGetForUnity?
1212

@@ -62,11 +62,11 @@ Download the `*.unitypackage` file. Right-click on it in File Explorer and choos
6262
6363
To launch, select **NuGet → Manage NuGet Packages**
6464
65-
![](docs/screenshots/menu_item.png?raw=true)
65+
<img alt="Menu Items" src="docs/screenshots/menu_item.png" height="170px" />
6666
6767
After several seconds (it can take some time to query the server for packages), you should see a window like this:
6868
69-
![](docs/screenshots/online.png?raw=true)
69+
<img alt="Online Packages Tap" src="docs/screenshots/online.png" height="500px" />
7070
7171
The **Online** tab shows the packages available on the NuGet server.
7272
@@ -89,13 +89,13 @@ Note: If the package is already installed an **Uninstall** button will be displa
8989
9090
The **Installed** tabs shows the packages already installed in the current Unity project.
9191
92-
![](docs/screenshots/installed.png?raw=true)
92+
<img alt="Installed Packages Tap" src="docs/screenshots/installed.png" height="500px" />
9393
9494
Click the **Uninstall** button to uninstall the package.
9595
9696
The **Updates** tab shows the packages currently installed that have updates available on the server.
9797
98-
![](docs/screenshots/updates.png?raw=true)
98+
<img alt="Updates Packages Tap" src="docs/screenshots/updates.png" height="500px" />
9999
100100
The version in brackets on the left is the new version number. The version in brackets in the **Update** button is the currently installed version.
101101
@@ -128,13 +128,13 @@ You can change this to any other NuGet server (such as NuGet.Server or ProGet -
128128
129129
See more information about _NuGet.config_ files here: [https://docs.nuget.org/consume/nuget-config-settings](https://docs.nuget.org/consume/nuget-config-settings)
130130
131-
![](docs/screenshots/menu_item.png?raw=true)
131+
<img alt="Menu Items" src="docs/screenshots/menu_item.png" height="170px" />
132132
133133
NuGetForUnity installs packages into the local repository path defined in the _NuGet.config_ file (`repositoryPath`). By default, this is set to the `Assets/Packages` folder. In the _NuGet.config_ file, this can either be a full path, or it can be a relative path based on the project's Assets folder. Note: You'll probably want your Packages folder to be ignored by your version control software to prevent NuGet packages from being versioned in your repository.
134134
135135
When a package is installed, the _packages.config_ file in the project is automatically updated with the specific package information, as well as all of the dependencies that are also installed. This allows for the packages to be restored from scratch at any point. The `Restore` operation is automatically run every time the project is opened or the code is recompiled in the project. It can be run manually by selecting the **NuGet → Restore Packages** menu item.
136136
137-
![](docs/screenshots/menu_item.png?raw=true)
137+
<img alt="Menu Items" src="docs/screenshots/menu_item.png" height="170px" />
138138
139139
Note: Depending on the size and number of packages you need to install, the `Restore` operation could take a _long_ time, so please be patient. If it appears the Unity isn't launching or responding, wait a few more minutes before attempting to kill the process.
140140
@@ -161,11 +161,11 @@ When this setting is set to `false` the assemblies of the NuGet package are only
161161

162162
First, you'll need to create a _.nuspec_ file that defines your package. In your Project window, right click where you want the _.nuspec_ file to go and select **NuGet → Create Nuspec File**.
163163

164-
![](docs/screenshots/nuspec_menu.png?raw=true)
164+
<img alt="Create Nuspec Menu" src="docs/screenshots/nuspec_menu.png" height="400px" />
165165

166166
Select the new _.nuspec_ file and you should see something like this:
167167

168-
![](docs/screenshots/nuspec_editor.png?raw=true)
168+
<img alt="Nuspec editor" src="docs/screenshots/nuspec_editor.png" height="500px" />
169169

170170
Input the appropriate information for your package (ID, Version, Author, Description, etc). Be sure to include whatever dependencies are required by your package.
171171

@@ -177,6 +177,8 @@ Press the **Push** button to push your package up to the server. Be sure to set
177177

178178
You can use [NuGet.Server](http://nugetserver.net/), [NuGet Gallery](https://github.com/NuGet/NuGetGallery), [ProGet](http://inedo.com/proget), etc to create your own NuGet server.
179179

180+
> **Note:** NuGetForUnity currently only supports NuGet Api version v1
181+
180182
Alternatively, you can use a "local feed" which is just a folder on your hard-drive or a network share.
181183

182184
Be sure to set the proper URL/path in the _NuGet.config_ file and you should be good to go!
@@ -197,3 +199,24 @@ For more information see [.Net Tool Documentaion](https://learn.microsoft.com/en
197199
## Usage
198200

199201
Restore nuget packages of a single Unity Project: `dotnet nugetforunity restore <PROJECT_PATH>`. If installed as a global tool it can be called without the `dotnet` prefix: `nugetforunity restore <PROJECT_PATH>`.
202+
203+
# Common issues when installing NuGet packages
204+
205+
Unity is relatively special as it uses a different runtime, a fork of the [Mono](https://docs.unity3d.com/Manual/Mono.html) runtime, than the standerd .Net from Microsoft uses. For some platforms Unity even uses [IL2CPP](https://docs.unity3d.com/Manual/IL2CPP.html) that compiles all C# code to C++ code. So Unity also uses a different build-system. This can lead to some issues with NuGet packages that heavily depend on the standard .Net build-system. NuGetForUnity tries to handle most of the changes needed for NuGet packages to work inside Unity but it is not able to resolve all issues.
206+
207+
## Version Conflicts
208+
209+
If two NuGet packages depend on the same package but reference different versions of it, Unity shows a error like:
210+
211+
```
212+
Assembly 'Assets/Packages/System.Diagnostics.EventLog.4.7.0/lib/netstandard2.0/System.Diagnostics.EventLog.dll' will not be loaded due to errors:
213+
System.Diagnostics.EventLog references strong named System.Security.Principal.Windows Assembly references: 4.1.1.0 Found in project: 4.1.3.0.
214+
Assembly Version Validation can be disabled in Player Settings "Assembly Version Validation"
215+
```
216+
217+
As mentioned in the message this error can be suppresed by changing a setting. Just go to Edit -> Project Settings -> Player -> Scroll down and expand "Other Settings" than uncheck "Assembly Version Validation" unther the "Configuration" section.
218+
219+
<details>
220+
<summary>Screenshot of Player Settings</summary>
221+
<img als="Assembly Version Validation settings page" src="docs/screenshots/assembly-version-validation-setting.png" height="550px" />
222+
</details>
199 KB
Loading

docs/screenshots/installed.png

88 KB
Loading

docs/screenshots/menu_item.png

8.06 KB
Loading

docs/screenshots/nuspec_editor.png

39.2 KB
Loading

docs/screenshots/online.png

50.6 KB
Loading

docs/screenshots/preferences.png

48.7 KB
Loading

docs/screenshots/updates.png

31.1 KB
Loading

docs/screenshots/updates_all.png

49.1 KB
Loading

src/NuGetForUnity/Editor/NuGetPackageTextureHelper.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ internal static Task<Texture2D> DownloadImage(string url)
2323
try
2424
{
2525
var fromCache = false;
26-
if (ExistsInDiskCache(url))
26+
if (url.StartsWith("file://"))
27+
{
28+
// we only cache images coming from a remote server.
29+
fromCache = true;
30+
}
31+
else if (ExistsInDiskCache(url))
2732
{
2833
url = "file:///" + GetFilePath(url);
2934
fromCache = true;
@@ -35,7 +40,7 @@ internal static Task<Texture2D> DownloadImage(string url)
3540
var downloadHandler = new DownloadHandlerTexture(false);
3641

3742
request.downloadHandler = downloadHandler;
38-
request.timeout = 1;
43+
request.timeout = 1; // 1 second
3944
var operation = request.SendWebRequest();
4045
operation.completed += asyncOperation =>
4146
{

0 commit comments

Comments
 (0)