Skip to content

Commit 2c6d4e1

Browse files
authored
Merge pull request NuGet#1031 from NuGet/master
Merging Plugin changes to live.
2 parents c643dd2 + 58c7a51 commit 2c6d4e1

File tree

7 files changed

+422
-19
lines changed

7 files changed

+422
-19
lines changed

docs/consume-packages/managing-the-global-packages-and-cache-folders.md

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Whenever you install, update, or restore a package, NuGet manages packages and p
1717
| global&#8209;packages | The *global-packages* folder is where NuGet installs any downloaded package. Each package is fully expanded into a subfolder that matches the package identifier and version number. Projects using the PackageReference format always use packages directly from this folder. When using the `packages.config`, packages are installed to the *global-packages* folder, then copied into the project's `packages` folder.<br/><ul><li>Windows: `%userprofile%\.nuget\packages`</li><li>Mac/Linux: `~/.nuget/packages`</li><li>Override using the NUGET_PACKAGES environment variable, the `globalPackagesFolder` or `repositoryPath` [configuration settings](../reference/nuget-config-file.md#config-section) (when using PackageReference and `packages.config`, respectively), or the `RestorePackagesPath` MSBuild property (MSBuild only). The environment variable takes precedence over the configuration setting.</li></ul> |
1818
| http&#8209;cache | The Visual Studio Package Manager (NuGet 3.x+) and the `dotnet` tool store copies of downloaded packages in this cache (saved as `.dat` files), organized into subfolders for each package source. Packages are not expanded, and the cache has an expiration time of 30 minutes.<br/><ul><li>Windows: `%localappdata%\NuGet\v3-cache`</li><li>Mac/Linux: `~/.local/share/NuGet/v3-cache`</li><li>Override using the NUGET_HTTP_CACHE_PATH environment variable.</li></ul> |
1919
| temp | A folder where NuGet stores temporary files during its various operations.<br/><li>Windows: `%temp%\NuGetScratch`</li><li>Mac/Linux: `/tmp/NuGetScratch`</li></ul> |
20+
| plugins-cache **4.8+** | A folder where NuGet stores the results from the operation claims request.<br/><ul><li>Windows: `%localappdata%\NuGet\plugins-cache`</li><li>Mac/Linux: `~/.local/share/NuGet/plugins-cache`</li><li>Override using the NUGET_PLUGINS_CACHE_PATH environment variable.</li></ul> |
2021

2122
> [!Note]
2223
> NuGet 3.5 and earlier uses *packages-cache* instead of the *http-cache*, which is located in `%localappdata%\NuGet\Cache`.
@@ -29,38 +30,40 @@ For more information, see [What happens when a package is installed](ways-to-ins
2930

3031
## Viewing folder locations
3132

32-
You can view folder locations using the [dotnet nuget locals command](/dotnet/core/tools/dotnet-nuget-locals):
33+
You can view locations using the [nuget locals command](../tools/cli-ref-locals.md):
3334

3435
```cli
35-
dotnet nuget locals all --list
36+
# Display locals for all folders: global-packages, http cache, temp and plugins cache
37+
nuget locals all -list
3638
```
3739

38-
Typical output (Mac/Linux; "user1" is the current username):
40+
Typical output (Windows; "user1" is the current username):
3941

4042
```output
41-
info : http-cache: /home/user1/.local/share/NuGet/v3-cache
42-
info : global-packages: /home/user1/.nuget/packages/
43-
info : temp: /tmp/NuGetScratch
43+
http-cache: C:\Users\user1\AppData\Local\NuGet\v3-cache
44+
global-packages: C:\Users\user1\.nuget\packages\
45+
temp: C:\Users\user1\AppData\Local\Temp\NuGetScratch
46+
plugins-cache: C:\Users\user1\AppData\Local\NuGet\plugins-cache
4447
```
4548

46-
To display the location of a single folder, use `http-cache`, `global-packages`, or `temp` instead of `all`.
49+
(`package-cache` is used in NuGet 2.x and appears with NuGet 3.5 and earlier.)
4750

48-
You also view locations using the [nuget locals command](../tools/cli-ref-locals.md):
51+
You can also view folder locations using the [dotnet nuget locals command](/dotnet/core/tools/dotnet-nuget-locals):
4952

5053
```cli
51-
# Display locals for all folders: global-packages, cache, and temp
52-
nuget locals all -list
54+
dotnet nuget locals all --list
5355
```
5456

55-
Typical output (Windows; "user1" is the current username):
57+
Typical output (Mac/Linux; "user1" is the current username):
5658

5759
```output
58-
http-cache: C:\Users\user1\AppData\Local\NuGet\v3-cache
59-
global-packages: C:\Users\user1\.nuget\packages\
60-
temp: C:\Users\user1\AppData\Local\Temp\NuGetScratch
60+
info : http-cache: /home/user1/.local/share/NuGet/v3-cache
61+
info : global-packages: /home/user1/.nuget/packages/
62+
info : temp: /tmp/NuGetScratch
63+
info : plugins-cache: /home/user1/.local/share/NuGet/plugins-cache
6164
```
6265

63-
(`package-cache` is used in NuGet 2.x and appears with NuGet 3.5 and earlier.)
66+
To display the location of a single folder, use `http-cache`, `global-packages`, `temp`, or `plugins-cache` instead of `all`.
6467

6568
## Clearing local folders
6669

@@ -82,6 +85,10 @@ nuget locals global-packages -clear
8285
dotnet nuget locals temp --clear
8386
nuget locals temp -clear
8487
88+
# Clear the plugins cache (use either command)
89+
dotnet nuget locals plugins-cache --clear
90+
nuget locals plugins-cache -clear
91+
8592
# Clear all caches (use either command)
8693
dotnet nuget locals all --clear
8794
nuget locals all -clear

docs/quickstart/create-and-publish-a-package-using-visual-studio.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,26 @@ This step is an alternative to using `nuget.exe`.
145145
146146
[!INCLUDE [publish-manage](includes/publish-manage.md)]
147147
148+
## Adding a readme and other files
149+
150+
To directly specify files to include in the package, edit the project file and use the `content` property:
151+
152+
```xml
153+
<ItemGroup>
154+
<Content Include="readme.txt">
155+
<Pack>true</Pack>
156+
<PackagePath>\</PackagePath>
157+
</Content>
158+
</ItemGroup>
159+
```
160+
161+
This will include a file named `readme.txt` in the package root. Visual Studio displays the contents of that file as plain text immediately after installing the package directly. (Readme files are not displayed for packages installed as dependencies). For example, here's how the readme for the HtmlAgilityPack package appears:
162+
163+
![The display of a readme file for a NuGet package upon installation](../create-packages/media/Create_01-ShowReadme.png)
164+
165+
> [!Note]
166+
> Merely adding the readme.txt at the project root will not result in it being included in the resulting package.
167+
148168
## Related topics
149169

150170
- [Create a Package](../create-packages/creating-a-package.md)

docs/reference/extensibility/NuGet-Credential-Providers-for-Visual-Studio.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ After you install a NuGet credential provider for Visual Studio, the NuGet Visua
1515

1616
A sample implementation can be found in [the VsCredentialProvider sample](https://github.com/NuGet/Samples/tree/master/VsCredentialProvider).
1717

18+
Starting with 4.8+ NuGet in Visual Studio supports the new cross platform authentication plugins as well, but they are not the recommended approach for performance reasons.
19+
1820
> [!Note]
19-
> NuGet credential providers for Visual Studio must be installed as a regular Visual Studio extension and will require [Visual Studio 2017](https://aka.ms/vs/15/preview/vs_enterprise) (currently in preview) or above.
21+
> NuGet credential providers for Visual Studio must be installed as a regular Visual Studio extension and will require [Visual Studio 2017](http://aka.ms/vs/15/release/vs_enterprise.exe) or above.
2022
>
2123
> NuGet credential providers for Visual Studio work only in Visual Studio (not in dotnet restore or nuget.exe). For credential providers with nuget.exe, see [nuget.exe Credential Providers](nuget-exe-Credential-providers.md).
24+
> For credential providers in dotnet and msbuild see [NuGet cross platform plugins](#NuGet-Cross-Platform-Authentication-Plugin.md)
2225
2326
## Available NuGet credential providers for Visual Studio
2427

@@ -38,7 +41,8 @@ During credential acquisition, the credential service will try credential provid
3841

3942
1. Credentials will be fetched from NuGet configuration files (using the built-in `SettingsCredentialProvider`).
4043
1. If the package source is on Visual Studio Team Services, the `VisualStudioAccountProvider` will be used.
41-
1. All other plug-in credential providers will be tried sequentially.
44+
1. All other plug-in Visual Studio credential providers will be tried sequentially.
45+
1. Try to use all NuGet cross platform credential providers sequentially.
4246
1. If no credentials have been acquired yet, the user will be prompted for credentials using a standard basic authentication dialog.
4347

4448
### Implementing IVsCredentialProvider.GetCredentialsAsync
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: NuGet cross platform authentication plugin
3+
description: NuGet cross platform authentication plugins for NuGet.exe, dotnet.exe, msbuild.exe and Visual Studio
4+
author: nkolev92
5+
ms.author: nikolev
6+
manager: rrelyea
7+
ms.date: 07/01/2018
8+
ms.topic: conceptual
9+
---
10+
11+
# NuGet cross platform authentication plugin
12+
13+
In version 4.8+, all NuGet clients (NuGet.exe, Visual Studio, dotnet.exe and MSBuild.exe) can use an authentication plugin built on top of the [NuGet cross platform plugins](NuGet-Cross-Platform-Plugins.md) model.
14+
15+
## Available NuGet cross platform authentication plugins
16+
17+
TBD - Link to the VSTS provider
18+
19+
## Authentication in dotnet.exe
20+
21+
Visual Studio and NuGet.exe are by default interactive. NuGet.exe contains a switch to make it [non interactive](../../tools/nuget-exe-CLI-Reference.md).
22+
Additionally the NuGet.exe and Visual Studio plugins prompt the user for input.
23+
In dotnet.exe there is no prompting and the default is non interactive.
24+
25+
The authentication mechanism in dotnet.exe is device flow. When the restore or add package operation is run interactively, the operation blocks and instructions to the user how to complete the authentications will be provided on the command line.
26+
When the user completes the authentication the operation will continue.
27+
28+
To make the operation interactive, one should pass `--interactive`.
29+
Currently only the explicit `dotnet restore` and `dotnet add package` commands support an interactive switch.
30+
There is no interactive switch on `dotnet build` and `dotnet publish`.
31+
32+
## Authentication in MSBuild
33+
34+
Similar to dotnet.exe, MSBuild.exe is by default non interactive the MSBuild.exe authentication mechanism is device flow.
35+
To allow the restore to pause and wait for authentication, call restore with `msbuild /t:restore /p:NuGetInteractive="true"`.
36+
37+
## Creating a cross platform authentication plugin
38+
39+
A sample implementation can be found in [MSCredProvider plugin](https://github.com/Microsoft/mscredprovider).
40+
41+
It's very important that the plugins conforms to the security requirements set forth by the NuGet client tools.
42+
The minimum required version for a plugin to be an authentication plugin is *2.0.0*.
43+
NuGet will perform the handshake with the plugin and query for the supported operation claims.
44+
Please refer to the NuGet cross platform plugin [protocol messages](NuGet-Cross-Platform-Plugins.md#protocol-messages-index) for more details about the specific messages.
45+
46+
NuGet will set the log level and provide proxy information to the plugin when applicable.
47+
Logging to the NuGet console is only acceptable after NuGet has set the log level to the plugin.
48+
49+
- .NET Framework plugin authentication behavior
50+
51+
In .NET Framework, the plugins are allowed to prompt a user for input, in the form of a dialog.
52+
53+
- .NET Core plugin authentication behavior
54+
55+
In .NET Core, a dialog cannot be shown. The plugins should use device flow to authenticate.
56+
The plugin can send log messages to NuGet with instructions to the user.
57+
Note that logging is available after the log level has been set to the plugin.
58+
NuGet will not take any interactive input from the command line.
59+
60+
When the client calls the plugin with a Get Authentication Credentials, the plugins need to conform to the interactivity switch and respect the dialog switch.
61+
62+
The following table summarizes how the plugin should behave for all combinations.
63+
64+
| IsNonInteractive | CanShowDialog | Plugin behavior |
65+
| ---------------- | ------------- | --------------- |
66+
| true | true | The IsNonInteractive switch takes precedence over the dialog switch. The plugin is not allowed to pop a dialog. This combination is only valid for .NET Framework plugins |
67+
| true | false | The IsNonInteractive switch takes precedence over the dialog switch. The plugin is not allowed to block. This combination is only valid for .NET Core plugins |
68+
| false | true | The plugin should show a dialog. This combination is only valid for .NET Framework plugins |
69+
| false | false | The plugin should/can not show a dialog. The plugin should use device flow to authenticate by logging an instruction message via the logger. This combination is only valid for .NET Core plugins |
70+
71+
Please refer to the following specs before writing a plugin.
72+
73+
- [NuGet Package Download Plugin](https://github.com/NuGet/Home/wiki/NuGet-Package-Download-Plugin)
74+
- [NuGet cross plat authentication plugin](https://github.com/NuGet/Home/wiki/NuGet-cross-plat-authentication-plugin)

0 commit comments

Comments
 (0)