Skip to content

Commit 9be2d4e

Browse files
author
BuildTools
committed
2 parents b5a3e45 + 059879d commit 9be2d4e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+218
-87
lines changed

docs/API/NuGet-Credential-Providers-for-Visual-Studio.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ A sample implementation can be found in [the VsCredentialProvider sample](https:
3838
> [!Note]
3939
> 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.
4040
>
41-
> 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](../api/nuget.exe-credential-providers.md).
41+
> 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](../api/nuget-exe-Credential-providers.md).
4242
4343
## Available NuGet credential providers for Visual Studio
4444

docs/Consume-Packages/Configuring-NuGet-Behavior.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,21 @@ The behavior of every NuGet command, whether issued from the command line, the P
5454
5555
## Changing config settings
5656

57-
A configuration file is a simple XML text file containing settings as described in the [NuGet Configuration Settings](../schema/nuget.config-file.md) topic.
57+
A configuration file is a simple XML text file containing settings as described in the [NuGet Configuration Settings](../Schema/nuget-config-file.md) topic.
5858

59-
The preferred method for changing the configuration is using the NuGet [config command](../tools/nuget.exe-cli-reference.md#config) to set a key and value.
59+
The preferred method for changing the configuration is using the NuGet [config command](../tools/nuget-exe-cli-reference.md#config) to set a key and value.
6060

6161
> [!Note]
6262
> Keys are always case sensitive.
6363
6464
To **set a value** in any existing configuration file, use the `-configFile` switch as shown in the examples below.
6565

66+
```bash
6667
nuget config -set repositoryPath=c:\packages -configfile c:\my.config
6768
nuget config -set repositoryPath=c:\packages -configfile .\myApp\NuGet.Config
6869
nuget config -set repositoryPath=c:\packages -configfile %ProgramData%\NuGet\Config\VisualStudio\14.0\NuGet.Config
6970
nuget config -set repositoryPath=c:\packages -configfile %ProgramData%\NuGet\NuGetDefaults.Config
71+
```
7072

7173
Without the `-configFile` switch, NuGet will make the change in the global config file.
7274

@@ -75,7 +77,9 @@ Without the `-configFile` switch, NuGet will make the change in the global confi
7577
7678
To **remove a value**, use the same commands but with an empty value, such as:
7779

80+
```bash
7881
nuget config -set repositoryPath= -configfile c:\my.config
82+
```
7983

8084
To create a new configuration file, copy the template below into that file and then use the `nuget config --configFile <filename>` command to set values:
8185

docs/Consume-Packages/Managing-the-NuGet-Cache.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,28 @@ ms.reviewer:
3333

3434
NuGet manages several local caches to avoid downloading packages that are already on the machine, and to provide offline support. NuGet versions 2.8 and later automatically fall back to the cache when installing or reinstalling packages without a network connection.
3535

36-
To see the list of cache locations, use the [locals command](../tools/nuget.exe-cli-reference.md#locals):
36+
To see the list of cache locations, use the [locals command](../tools/nuget-exe-cli-reference.md#locals):
3737

38+
```bash
3839
nuget locals all -list
40+
```
3941

4042
Typical output is as follows:
4143

42-
http-cache: C:\Users\kraigb\AppData\Local\NuGet\v3-cache #3.x cache
43-
packages-cache: C:\Users\kraigb\AppData\Local\NuGet\Cache #2.x cache
44-
global-packages: C:\Users\kraigb\.nuget\packages\ #Global cache
45-
temp: C:\Users\kraigb\AppData\Local\Temp\NuGetScratch #Temp folder
44+
http-cache: C:\Users\user\AppData\Local\NuGet\v3-cache #3.x cache
45+
packages-cache: C:\Users\user\AppData\Local\NuGet\Cache #2.x cache
46+
global-packages: C:\Users\user\.nuget\packages\ #Global cache
47+
temp: C:\Users\user\AppData\Local\Temp\NuGetScratch #Temp folder
4648

4749
If you encounter package installation problems or otherwise want to ensure that you're installing packages from the remote gallery, use the `locals -clear` option in one or more of the following ways:
4850

51+
```bash
4952
nuget locals http-cache -clear #Clear the 3.x cache
5053
nuget locals packages-cache -clear #Clear the 2.x cache
5154
nuget locals global-packages -clear #Clear the global cache
5255
nuget locals temp -clear #Clear the temporary cache
5356
nuget locals all -clear #Clears all caches
57+
```
5458

5559
Note that managing the cache is presently supported only from the NuGet command line, and not within Visual Studio or through the Package Manager Console. Also, managing the 2.x cache is not supported in NuGet 3.6 and later.
5660

docs/Consume-Packages/Overview-and-Workflow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Between nuget.org and private package galleries that your organization might est
3434

3535
![Flow of going to a package source, finding a package, installing it in a project, then adding a using statement and calls to the package API](media/Overview-01-GeneralFlow.png)
3636

37-
\* _Except with `nuget install` from the command-line, in which case it's necessary to edit the configuration files by hand. See the [install command reference](../tools/nuget.exe-cli-reference.md#install)._
37+
\* _Except with `nuget install` from the command-line, in which case it's necessary to edit the configuration files by hand. See the [install command reference](../tools/nuget-exe-cli-reference.md#install)._
3838

3939
NuGet remembers the identity and version number of each installed package, recording it in either `packages.config` or `project.json` in your project root, depending on project type. With NuGet 4.0+ and .NET Core projects, dependencies are instead stored in the project file directly. See [Package References in Project Files](../consume-packages/package-references-in-project-files.md). In any case, you can look in the appropriate file at any time to see the full list of dependencies for your project.
4040

docs/Consume-Packages/Package-References-in-Project-Files.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,25 @@ You might be using a dependency purely as a development harness and might not wa
110110

111111
The following metadata tags control dependency assets:
112112

113-
| Tag | Description | Default Value
114-
| IncludeAssets | These assets will be consumed | all
115-
| ExcludeAssetsTag | These assets will not be consumed | none
116-
| PrivateAssets | These assets will be consumed but won't flow to the parent project | contentfiles;analyzers;build
113+
Tag | Description | Default Value
114+
--- | --- | ---
115+
IncludeAssets | These assets will be consumed | all
116+
ExcludeAssetsTag | These assets will not be consumed | none
117+
PrivateAssets | These assets will be consumed but won't flow to the parent project | contentfiles;analyzers;build
117118

118119

119120
Allowable values for these tags are as follows, with multiple values separated by a semicolon except with `all` and `none` which must appear by themselves:
120121

121-
| Value | Description
122-
| compile | Contents of the `lib` folder
123-
| runtime | Contents of the `runtime` folder
124-
| contentFiles | Contents of the `contentfiles` folder
125-
| build | Props and targets in the `build` folder
126-
| anaylzers | .NET analyzers
127-
| native | Contents of the `native` folder
128-
| none | None of the above are used.
129-
| all | All of the above (except `none`)
122+
Value | Description
123+
--- | ---
124+
compile | Contents of the `lib` folder
125+
runtime | Contents of the `runtime` folder
126+
contentFiles | Contents of the `contentfiles` folder
127+
build | Props and targets in the `build` folder
128+
anaylzers | .NET analyzers
129+
native | Contents of the `native` folder
130+
none | None of the above are used.
131+
all | All of the above (except `none`)
130132

131133
In the following example, everything except the content files from the package would be consumed by the project and everything except content files and analyzers would flow to the parent project.
132134

docs/Consume-Packages/Package-Restore.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Package restore is primarily enabled through **Tools > Options > [NuGet] Package
8787
</configuration>
8888
```
8989

90-
For reference, see the [NuGet config file - packageRestore section](../schema/nuget.config-file.md#packagerestore-section).
90+
For reference, see the [NuGet config file - packageRestore section](../Schema/nuget-config-file.md#packagerestore-section).
9191

9292
MSBuild-integrated restore with NuGet 2.6 and earlier is typically enabled by right-clicking a solution in Visual Studio and selecting **Enable NuGet Package Restore**. This sets up the necessary files and folders for this option to work, as explained under [MSBuild-integrated restore in Visual Studio](#msbuild-integrated-restore).
9393

@@ -114,13 +114,15 @@ In both cases, use the notation described in [Dependency versions](../create-pac
114114

115115
## Command-line restore
116116

117-
For NuGet 2.6 and earlier, you use the [Install](../tools/nuget.exe-cli-reference.md#install) command and point to the `packages.config` file that lists all the dependencies.
117+
For NuGet 2.6 and earlier, you use the [Install](../tools/nuget-exe-cli-reference.md#install) command and point to the `packages.config` file that lists all the dependencies.
118118

119-
For NuGet 2.7 and above, use the [Restore](../tools/nuget.exe-cli-reference.md#restore) command to restore all packages in a solution (using either `packages.config` in NuGet 2.x and later or `project.json` in NuGet 3.x and later). For a given project folder such as `c:\proj\app`, the common variations below each restore the packages:
119+
For NuGet 2.7 and above, use the [Restore](../tools/nuget-exe-cli-reference.md#restore) command to restore all packages in a solution (using either `packages.config` in NuGet 2.x and later or `project.json` in NuGet 3.x and later). For a given project folder such as `c:\proj\app`, the common variations below each restore the packages:
120120

121+
```bash
121122
c:\proj\app\> nuget restore
122123
c:\proj\app\> nuget.exe restore app.sln
123124
c:\proj\> nuget restore app
125+
```
124126

125127
## Automatic restore in Visual Studio
126128

@@ -149,8 +151,10 @@ To correct these errors, do one of the following:
149151
1. [Migrate the project to automatic restore](#migrating-to-automatic-restore).
150152
1. Update `nuget.exe` in the `.nuget` folder** as follows
151153

154+
```bash
152155
cd .nuget
153156
nuget update -self
157+
```
154158

155159
1. Reset consent in your `%AppData%\NuGet\NuGet.config` file by going to **Tools > Options > NuGet Package Manager > General** in Visual Studio, uncheck and re-check both **Package Restore** options, and click OK. This re-saves `NuGet.config` with the proper consent settings for NuGet 2.6 and earlier.
156160

docs/Consume-Packages/Packages-and-Source-Control.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ To disable source control integration with TFVC for selected files:
7373
1. Create a folder called `.nuget` in your solution folder (where the `.sln` file is).
7474
* Tip: on Windows, to create this folder in Windows Explorer, use the name `.nuget.` *with* the training dot.
7575
1. In that folder, create a file named `NuGet.config` and open it for editing.
76-
1. Add the following text as a minimum, where the [disableSourceControlIntegration](../schema/nuget.config-file.md#solution-section) setting instructs Visual Studio to skip everything in the `packages` folder:
76+
1. Add the following text as a minimum, where the [disableSourceControlIntegration](../Schema/nuget-config-file.md#solution-section) setting instructs Visual Studio to skip everything in the `packages` folder:
7777

7878
```xml
7979
<?xml version="1.0" encoding="utf-8"?>

docs/Consume-Packages/Team-Foundation-Build.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ NuGet has supported [restoring packages](../consume-packages/package-restore.md)
5252

5353
The cure to this problem is making sure that packages are restored as the first step in the build process. NuGet 2.7+ makes this easy via a simplified command line:
5454

55+
```bash
5556
nuget restore path\to\solution.sln
57+
```
5658

5759
When your build process restores packages before building the code, you don't need to check-in **.targets** files
5860

docs/Create-Packages/Creating-a-Package.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ For details on declaring dependencies and specifying version numbers, see [Depen
128128

129129
Because the manifest is always included in a package, you can find any number of additional examples by examining existing packages. A good source is the global package cache on your machine, the location of which is returned by the following command:
130130

131+
```bash
131132
nuget locals -list global-packages
133+
```
132134

133135
Go into any *package\version* folder, copy the .nupkg file to a .zip file, then open that .zip file and examine the .nuspec within it.
134136

@@ -139,7 +141,9 @@ Note that when creating a `.nuspec` from a Visual Studio project, the manifest w
139141

140142
You can create a `.nuspec` file from scratch in any text editor, or by editing a file from another project. You can also have NuGet create a template manifest for your by using the following command:
141143

144+
```bash
142145
nuget spec <package_name>
146+
```
143147

144148
The resulting `<package_name>.nuspec` file (or `Package.nuspec` if you omit a specific name) will contain placeholders for values like the `projectUrl`, so be sure to edit it before using it to creating the package.
145149

@@ -149,13 +153,17 @@ You can also use `nuget spec` with an existing assembly, a Visual Studio project
149153

150154
If you have an assembly DLL, you can easily generate a `.nuspec` file from the metadata in the assembly using the following command:
151155

156+
```bash
152157
nuget spec MyAssembly.dll
158+
```
153159

154160
### From a Visual Studio project
155161

156162
Creating a `.nuspec` from a `.csproj` or `.vbproj` file is convenient because other packages that have been installed into those project will be automatically referenced as dependencies. Simply use the following command in the same folder as the project file:
157163

164+
```bash
158165
nuget spec
166+
```
159167

160168
This creates a template `<project_name>.nuspec` file as usual, but includes tokens that will be replaced at packaging time with values from the project. This means you do not need to update crucial values like the version number in the `.nuspec` as you update the project (but you can always replace the tokens with literal values, if desired).
161169

@@ -200,7 +208,9 @@ Think of the **content** folder as the root of the target application, so if you
200208

201209
Next, from the root folder of this layout, run the following command to create the `.nuspec` file:
202210

211+
```bash
203212
nuget spec
213+
```
204214

205215
In this case, the `.nuspec` will not contain any explicit references to the folder structure, but all those files will be automatically included when creating the package later on.
206216

@@ -333,11 +343,15 @@ With NuGet 3.x, targets are not added to the project but are instead made availa
333343

334344
When using an assembly or the convention-based working directory, create a package by running `nuget pack` with your `.nuspec` file:
335345

346+
```bash
336347
nuget pack &lt;your_project&gt;.nuspec
348+
```
337349

338350
When using a Visual Studio project, run `nuget pack` instead with your project file, which will automatically load the project's `.nuspec` file and replace any tokens within it using values in the project file:
339351

352+
```bash
340353
nuget pack &lt;your_project&gt;.csproj
354+
```
341355

342356
> [!Note]
343357
> Using the project file directly is necessary for token replacement because the project is the source of the token values. Token replacement does not happen if you use `nuget pack` with a `.nuspec` file.
@@ -355,26 +369,32 @@ Once `nuget pack` succeeds, you'll have a `.nupkg` file that you can publish to
355369

356370
### Additional options
357371

358-
You can use various command-line switches with `nuget pack` to exclude files, override the version number in the manifest, and change the output directory, among other features. For a complete list, refer to the [pack command reference](../tools/nuget.exe-cli-reference.md#pack).
372+
You can use various command-line switches with `nuget pack` to exclude files, override the version number in the manifest, and change the output directory, among other features. For a complete list, refer to the [pack command reference](../tools/nuget-exe-cli-reference.md#pack).
359373

360374
The following options are a few that are common with Visual Studio projects:
361375

362376
- **Referenced projects**: If the project references other projects, you can add the referenced projects as part of the package, or as dependencies, by using the `-IncludeReferencedProjects` option:
363377

378+
```bash
364379
nuget pack MyProject.csproj -IncludeReferencedProjects
380+
```
365381

366382
This inclusion process is recursive, so if MyProject.csproj references projects B and C, and those projects reference D, E, and F, then files from B, C, D, E, and F will be included in the package.
367383

368384
If a referenced project includes a `.nuspec` file of its own, then NuGet adds that referenced project as a dependency instead. You will need to package and publish that project separately.
369385

370386
- **Build configuration**: By default, NuGet will use the default build configuration set in the project file, typically *Debug*. To pack files from a different build configuration, such as *Release*, use the `-properties` option with the configuration:
371387

388+
```bash
372389
nuget pack MyProject.csproj -properties Configuration=Release
390+
```
373391

374392
- **Symbols**: to include symbols that allow consumers to step through your package code in the debugger, use the `-Symbols` option:
375393

394+
```bash
376395
nuget pack MyProject.csproj -symbols
377-
396+
```
397+
378398
## Next Steps
379399

380400
Once you've created a package, which is a `.nupkg` file, you can publish it to the gallery of your choice as described on [Publishing a Package](../create-packages/publish-a-package.md).

docs/Create-Packages/Prerelease-Packages.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ By default, NuGet does not include pre-release versions when working with packag
7272

7373
- **Package Manager Console**: Use the `-IncludePrerelease` switch with the `Find-Package`, `Get-Package`, `Install-Package`, `Sync-Package`, and `Update-Package` commands. Refer to the [PowerShell Reference](../tools/powershell-reference.md).
7474

75-
- **NuGet CLI**: Use the `-prerelease` switch with the `install`, `update`, `delete`, and `mirror` commands. Refer to the [NuGet CLI reference](../tools/nuget.exe-cli-reference.md)
75+
- **NuGet CLI**: Use the `-prerelease` switch with the `install`, `update`, `delete`, and `mirror` commands. Refer to the [NuGet CLI reference](../tools/nuget-exe-cli-reference.md)
7676

7777

7878
## Semantic versioning

docs/Create-Packages/Publish-a-package.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,17 @@ Next, you can either upload the package through the nuget.org web portal, or pus
5454

5555
3. At a command prompt, run the following command:
5656

57+
```bash
5758
nuget setApiKey Your-API-Key
59+
```
5860

5961
This will store your API key on the machine so that you will not need to do this step again on the same machine.
6062

6163
4. Push your package to NuGet Gallery using the command:
6264

65+
```bash
6366
nuget push YourPackage.nupkg -Source https://www.nuget.org/api/v2/package
67+
```
6468

6569
5. Before being made public, all packages uploaded to nuget.org are scanned for viruses and rejected if any viruses are found. All packages listed on nuget.org are also scanned periodically.
6670

docs/Create-Packages/Symbol-Packages.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ To create a symbol package, follow these conventions:
4343

4444
You can create both packages with the `-Symbols` option, either from a nuspec file or a project file:
4545

46+
```bash
4647
nuget pack MyPackage.nuspec -Symbols
4748

4849
nuget pack MyProject.csproj -Symbols
50+
```
4951

5052
Note that `pack` requires Mono 4.4.2 on Mac OS X and does not work on Linux systems. On a Mac, you must also convert Windows pathnames in the `.nuspec` file to Unix-style paths.
5153

@@ -110,18 +112,26 @@ A symbol package can be built by conventions, from a folder structure as describ
110112

111113
1. For convenience, first save your API key with NuGet (see [publish a package](../create-packages/publish-a-package.md), which will apply to both nuget.org and symbolsource.org, because symbolsource.org will check with nuget.org to verify that you are the package owner.
112114

115+
```bash
113116
nuget SetApiKey Your-API-Key
117+
```
114118

115119
1. After publishing your primary package to nuget.org, push the symbol package as follows, which will automatically use symbolsource.org as the target because of the `.symbols` in the filename:
116120

121+
```bash
117122
nuget push MyPackage.symbols.nupkg
123+
```
118124

119125
1. To publish to a different symbol repository, or to push a symbol package that doesn't follow the naming convention, use the `-Source` option:
120126

127+
```bash
121128
nuget push MyPackage.symbols.nupkg -source https://nuget.smbsrc.net/
129+
```
122130

123131
1. You can also push both primary and symbol packages to both repositories at the same time using the following:
124132

133+
```bash
125134
nuget push MyPackage.nupkg
135+
```
126136

127137
In this case, NuGet will publish `MyPackage.symbols.nupkg`, if present, to symbolsource.org (https://nuget.smbsrc.net/), after it publishes the primary package to nuget.org.

0 commit comments

Comments
 (0)