You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/create-packages/Creating-a-Package.md
+13-57Lines changed: 13 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ ms.date: 05/24/2019
7
7
ms.topic: conceptual
8
8
---
9
9
10
-
# Creating NuGet packages
10
+
# Create NuGet packages
11
11
12
12
No matter what your package does or what code it contains, you use one of the CLI tools, either `nuget.exe` or `dotnet.exe`, to package that functionality into a component that can be shared with and used by any number of other developers. To install NuGet CLI tools, see [Install NuGet client tools](../install-nuget-client-tools.md). Note that Visual Studio does not automatically include a CLI tool.
13
13
@@ -24,7 +24,7 @@ Packaging begins with the compiled code (assemblies), symbols, and/or other file
24
24
> [!Note]
25
25
> This topic applies to non-SDK-style projects, typically projects other than .NET Core and .NET Standard projects using Visual Studio 2017 and higher versions and NuGet 4.0+.
26
26
27
-
## Deciding which assemblies to package
27
+
## Decide which assemblies to package
28
28
29
29
Most general-purpose packages contain one or more assemblies that other developers can use in their own projects.
30
30
@@ -36,7 +36,7 @@ Most general-purpose packages contain one or more assemblies that other develope
36
36
37
37
Resources are, in fact, a special case. When a package is installed into a project, NuGet automatically adds assembly references to the package's DLLs, *excluding* those that are named `.resources.dll` because they are assumed to be localized satellite assemblies (see [Creating localized packages](creating-localized-packages.md)). For this reason, avoid using `.resources.dll` for files that otherwise contain essential package code.
38
38
39
-
If your library contains COM interop assemblies, follow additional the guidelines in [Authoring packages with COM interop assemblies](#authoring-packages-with-com-interop-assemblies).
39
+
If your library contains COM interop assemblies, follow additional the guidelines in [Create packages with COM interop assemblies](author-packages-with-com-interop-assemblies.md).
40
40
41
41
## The role and structure of the .nuspec file
42
42
@@ -146,7 +146,7 @@ Go into any *package\version* folder, copy the `.nupkg` file to a `.zip` file, t
146
146
> [!Note]
147
147
> When creating a `.nuspec` from a Visual Studio project, the manifest contains tokens that are replaced with information from the project when the package is built. See [Creating the .nuspec from a Visual Studio project](#from-a-visual-studio-project).
148
148
149
-
## Creating the .nuspec file
149
+
## Create the .nuspec file
150
150
151
151
Creating a complete manifest typically begins with a basic `.nuspec` file generated through one of the following methods:
152
152
@@ -223,7 +223,7 @@ This token is replaced with the `AssemblyName` value from the project file at pa
223
223
224
224
Tokens relieve you from needing to update crucial values like the version number in the `.nuspec` as you update the project. (You can always replace the tokens with literal values, if desired).
225
225
226
-
Note that there are several additional packaging options available when working from a Visual Studio project, as described in [Running nuget pack to generate the .nupkg file](#running-nuget-pack-to-generate-the-nupkg-file) later on.
226
+
Note that there are several additional packaging options available when working from a Visual Studio project, as described in [Running nuget pack to generate the .nupkg file](#run-nuget-pack-to-generate-the-nupkg-file) later on.
227
227
228
228
#### Solution-level packages
229
229
@@ -245,7 +245,7 @@ If you omit \<package-name\>, the resulting file is `Package.nuspec`. If you pro
245
245
246
246
The resulting `.nuspec` contains placeholders for values like the `projectUrl`. Be sure to edit the file before using it to create the final `.nupkg` file.
247
247
248
-
## Choosing a unique package identifier and setting the version number
248
+
## Choose a unique package identifier and setting the version number
249
249
250
250
The package identifier (`<id>` element) and the version number (`<version>` element) are the two most important values in the manifest because they uniquely identify the exact code that's contained in the package.
251
251
@@ -257,7 +257,7 @@ The package identifier (`<id>` element) and the version number (`<version>` elem
257
257
258
258
**Best practices for the package version:**
259
259
260
-
- In general, set the version of the package to match the library, though this is not strictly required. This is a simple matter when you limit a package to a single assembly, as described earlier in [Deciding which assemblies to package](#deciding-which-assemblies-to-package). Overall, remember that NuGet itself deals with package versions when resolving dependencies, not assembly versions.
260
+
- In general, set the version of the package to match the library, though this is not strictly required. This is a simple matter when you limit a package to a single assembly, as described earlier in [Deciding which assemblies to package](#decide-which-assemblies-to-package). Overall, remember that NuGet itself deals with package versions when resolving dependencies, not assembly versions.
261
261
- When using a non-standard version scheme, be sure to consider the NuGet versioning rules as explained in [Package versioning](../reference/package-versioning.md).
262
262
263
263
> The following series of brief blog posts are also helpful to understand versioning:
@@ -266,33 +266,7 @@ The package identifier (`<id>` element) and the version number (`<version>` elem
266
266
> -[Part 2: The core algorithm](http://blog.davidebbo.com/2011/01/nuget-versioning-part-2-core-algorithm.html)
267
267
> -[Part 3: Unification via Binding Redirects](http://blog.davidebbo.com/2011/01/nuget-versioning-part-3-unification-via.html)
268
268
269
-
## Setting a package type
270
-
271
-
With NuGet 3.5+, packages can be marked with a specific *package type* to indicate its intended use. Packages not marked with a type, including all packages created with earlier versions of NuGet, default to the `Dependency` type.
272
-
273
-
-`Dependency` type packages add build- or run-time assets to libraries and applications, and can be installed in any project type (assuming they are compatible).
274
-
275
-
-`DotnetCliTool` type packages are extensions to the [.NET CLI](/dotnet/articles/core/tools/index) and are invoked from the command line. Such packages can be installed only in .NET Core projects and have no effect on restore operations. More details about these per-project extensions are available in the [.NET Core extensibility](/dotnet/articles/core/tools/extensibility#per-project-based-extensibility) documentation.
276
-
277
-
- Custom type packages use an arbitrary type identifier that conforms to the same format rules as package IDs. Any type other than `Dependency` and `DotnetCliTool`, however, are not recognized by the NuGet Package Manager in Visual Studio.
278
-
279
-
Package types are set in the `.nuspec` file. It's best for backwards compatibility to *not* explicitly set the `Dependency` type and to instead rely on NuGet assuming this type when no type is specified.
280
-
281
-
-`.nuspec`: Indicate the package type within a `packageTypes\packageType` node under the `<metadata>` element:
To directly specify files to include in the package, use the `<files>` node in the `.nuspec` file, which *follows* the `<metadata>` tag:
298
272
@@ -322,7 +296,7 @@ When you include a file named `readme.txt` in the package root, Visual Studio di
322
296
> [!Note]
323
297
> If you include an empty `<files>` node in the `.nuspec` file, NuGet doesn't include any other content in the package other than what's in the `lib` folder.
324
298
325
-
## Including MSBuild props and targets in a package
299
+
## Include MSBuild props and targets in a package
326
300
327
301
In some cases, you might want to add custom build targets or properties in projects that consume your package, such as running a custom tool or process during build. You do this by placing files in the form `<package_id>.targets` or `<package_id>.props` (such as `Contoso.Utility.UsefulStuff.targets`) within the `\build` folder of the project.
328
302
@@ -362,27 +336,7 @@ MSBuild `.props` and `.targets` files for cross-framework targeting can be place
362
336
363
337
With NuGet 3.x, targets are not added to the project but are instead made available through the `project.lock.json`.
364
338
365
-
## Authoring packages with COM interop assemblies
366
-
367
-
Packages that contain COM interop assemblies must include an appropriate [targets file](#including-msbuild-props-and-targets-in-a-package) so that the correct `EmbedInteropTypes` metadata is added to projects using the PackageReference format. By default, the `EmbedInteropTypes` metadata is always false for all assemblies when PackageReference is used, so the targets file adds this metadata explicitly. To avoid conflicts, the target name should be unique; ideally, use a combination of your package name and the assembly being embedded, replacing the `{InteropAssemblyName}` in the example below with that value. (Also see [NuGet.Samples.Interop](https://github.com/NuGet/Samples/tree/master/NuGet.Samples.Interop) for an example.)
<ReferencePathCondition=" '%(FileName)' == '{InteropAssemblyName}' AND '%(ReferencePath.NuGetPackageId)' == '$(MSBuildThisFileName)' ">
373
-
<EmbedInteropTypes>true</EmbedInteropTypes>
374
-
</ReferencePath>
375
-
</ItemGroup>
376
-
</Target>
377
-
```
378
-
379
-
Note that when using the `packages.config` management format, adding references to the assemblies from the packages causes NuGet and Visual Studio to check for COM interop assemblies and set the `EmbedInteropTypes` to true in the project file. In this case the targets are overriden.
380
-
381
-
Additionally, by default the [build assets do not flow transitively](../consume-packages/package-references-in-project-files.md#controlling-dependency-assets). Packages authored as described here work differently when they are pulled as a transitive dependency from a project to project reference. The package consumer can allow them to flow by modifying the PrivateAssets default value to not include build.
382
-
383
-
<aname="creating-the-package"></a>
384
-
385
-
## Running nuget pack to generate the .nupkg file
339
+
## Run nuget pack to generate the .nupkg file
386
340
387
341
When using an assembly or the convention-based working directory, create a package by running `nuget pack` with your `.nuspec` file, replacing `<project-name>` with your specific filename:
388
342
@@ -436,7 +390,7 @@ The following options are a few that are common with Visual Studio projects:
436
390
nuget pack MyProject.csproj -symbols
437
391
```
438
392
439
-
### Testing package installation
393
+
### Test package installation
440
394
441
395
Before publishing a package, you typically want to test the process of installing a package into a project. The tests make sure that the necessarily files all end up in their correct places in the project.
442
396
@@ -460,6 +414,8 @@ You might also want to extend the capabilities of your package or otherwise supp
460
414
- [Transformations of source and configuration files](../create-packages/source-and-config-file-transformations.md)
title: Create packages with COM interop assemblies
3
+
description: Describes how to create packages that contain COM interop assemblies
4
+
author: karann-msft
5
+
ms.author: karann
6
+
ms.date: 07/09/2019
7
+
ms.topic: conceptual
8
+
---
9
+
10
+
## Create NuGet packages that contain COM interop assemblies
11
+
12
+
Packages that contain COM interop assemblies must include an appropriate [targets file](creating-a-package.md#include-msbuild-props-and-targets-in-a-package) so that the correct `EmbedInteropTypes` metadata is added to projects using the PackageReference format. By default, the `EmbedInteropTypes` metadata is always false for all assemblies when PackageReference is used, so the targets file adds this metadata explicitly. To avoid conflicts, the target name should be unique; ideally, use a combination of your package name and the assembly being embedded, replacing the `{InteropAssemblyName}` in the example below with that value. (Also see [NuGet.Samples.Interop](https://github.com/NuGet/Samples/tree/master/NuGet.Samples.Interop) for an example.)
<ReferencePathCondition=" '%(FileName)' == '{InteropAssemblyName}' AND '%(ReferencePath.NuGetPackageId)' == '$(MSBuildThisFileName)' ">
18
+
<EmbedInteropTypes>true</EmbedInteropTypes>
19
+
</ReferencePath>
20
+
</ItemGroup>
21
+
</Target>
22
+
```
23
+
24
+
Note that when using the `packages.config` management format, adding references to the assemblies from the packages causes NuGet and Visual Studio to check for COM interop assemblies and set the `EmbedInteropTypes` to true in the project file. In this case the targets are overriden.
25
+
26
+
Additionally, by default the [build assets do not flow transitively](../consume-packages/package-references-in-project-files.md#controlling-dependency-assets). Packages authored as described here work differently when they are pulled as a transitive dependency from a project to project reference. The package consumer can allow them to flow by modifying the PrivateAssets default value to not include build.
description: Describes packages types to indicate intended use of a package.
4
+
author: karann-msft
5
+
ms.author: karann
6
+
ms.date: 07/09/2019
7
+
ms.topic: conceptual
8
+
---
9
+
10
+
# Set a NuGet package type
11
+
12
+
With NuGet 3.5+, packages can be marked with a specific *package type* to indicate its intended use. Packages not marked with a type, including all packages created with earlier versions of NuGet, default to the `Dependency` type.
13
+
14
+
-`Dependency` type packages add build- or run-time assets to libraries and applications, and can be installed in any project type (assuming they are compatible).
15
+
16
+
-`DotnetCliTool` type packages are extensions to the [dotnet CLI](/dotnet/articles/core/tools/index) and are invoked from the command line. Such packages can be installed only in .NET Core projects and have no effect on restore operations. More details about these per-project extensions are available in the [.NET Core extensibility](/dotnet/articles/core/tools/extensibility#per-project-based-extensibility) documentation.
17
+
18
+
- Custom type packages use an arbitrary type identifier that conforms to the same format rules as package IDs. Any type other than `Dependency` and `DotnetCliTool`, however, are not recognized by the NuGet Package Manager in Visual Studio.
19
+
20
+
Package types are set in the `.nuspec` file. It's best for backwards compatibility to *not* explicitly set the `Dependency` type and to instead rely on NuGet assuming this type when no type is specified.
21
+
22
+
-`.nuspec`: Indicate the package type within a `packageTypes\packageType` node under the `<metadata>` element:
0 commit comments