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/consume-packages/migrate-packages-config-to-package-reference.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,7 +87,9 @@ You should now be able to see the migration option. Note that this option is not
87
87
88
88
## Create a package after migration
89
89
90
-
Once the migration is complete, we recommend that you add a reference to the [nuget.build.tasks.pack](https://www.nuget.org/packages/nuget.build.tasks.pack) nuget package, and then use [msbuild -t:pack](../reference/msbuild-targets.md#pack-target) to create the package. Although in some scenarios you could use `dotnet.exe pack` instead of `msbuild -t:pack`, it is not recommended.
90
+
Once the migration is complete, we recommend that you copy your package metadata from a `.nuspec` file to [MSBuild properties](../reference/msbuild-targets.md#pack-target), and then you can use `msbuild -t:pack` to create the package.
91
+
If you are using Visual Studio 2022 or earlier, you will also need to install the NuGet.Build.Tasks.Pack package.
92
+
From Visual Studio 2026, pack is built into MSBuild.
Copy file name to clipboardExpand all lines: docs/create-packages/creating-a-package-msbuild.md
+27-7Lines changed: 27 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,9 +13,12 @@ When you create a NuGet package from your code, you package that functionality i
13
13
14
14
For .NET Core and .NET Standard projects that use the [SDK-style format](../resources/check-project-format.md), and any other SDK-style projects, NuGet uses information in the project file directly to create a package. For a non-SDK-style project that uses `<PackageReference>`, NuGet also uses the project file to create a package.
15
15
16
-
SDK-style projects have the pack functionality available by default. For non SDK-style PackageReference projects, you need to add the NuGet.Build.Tasks.Pack package to the project dependencies. For detailed information about MSBuild pack targets, see [NuGet pack and restore as MSBuild targets](../reference/msbuild-targets.md).
16
+
SDK-style projects have the pack functionality available by default.
17
+
For non-SDK-style PackageReference projects, it is also available by default starting from Visual Studio 2026.
18
+
In earlier versions of Visual Studio you need to add the NuGet.Build.Tasks.Pack package to the project dependencies and we recommend removing this package reference when upgrading to Visual Studio 2026.
19
+
For detailed information about MSBuild pack targets, see [NuGet pack and restore as MSBuild targets](../reference/msbuild-targets.md).
17
20
18
-
The command that creates a package, `msbuild -t:pack`, is functionally equivalent to `dotnet pack`.
21
+
For SDK-style projects, `msbuild -t:pack` is functionally equivalent to `dotnet pack`.
19
22
20
23
> [!IMPORTANT]
21
24
> This topic applies to [SDK-style](../resources/check-project-format.md) projects, typically .NET Core and .NET Standard projects, and to non-SDK-style projects that use PackageReference.
@@ -77,16 +80,33 @@ For details on declaring dependencies and specifying version numbers, see [Packa
If you are using MSBuild with a non-SDK-style project and PackageReference, add the NuGet.Build.Tasks.Pack package to your project.
85
+
SDK-style projects do not require any additional configuration.
83
86
84
-
1. Open the project file and add the following after the `<PropertyGroup>` element:
87
+
Non-SDK-style projects either need at least one package installed (via PackageReference, not packages.config), or the project explicitly needs to instruct NuGet to treat the project as a PackageReference project via the `RestoreProjectStyle` property.
88
+
89
+
Visual Studio 2022 and earlier does not have pack built-in, so you also need to install the NuGet.Build.Tasks.Pack package.
90
+
When upgrading to Visual Studio 2026 or later, we recommend uninstalling the package, so that you benefit from new features and bug fixes.
91
+
92
+
1. Edit the project file.
93
+
94
+
If you want to explicitly instruct NuGet to treat the project as PackageReference (the project does not have any packages installed), find or add a `<PropertyGroup>` that does not have any `Condition` statement, and add:
@@ -98,7 +118,7 @@ If you are using MSBuild with a non-SDK-style project and PackageReference, add
98
118
99
119
You typically want to start the Developer Command Prompt for Visual Studio from the **Start** menu, as it will be configured with all the necessary paths for MSBuild.
100
120
101
-
3. Switch to the folder containing the project file and type the following command to install the NuGet.Build.Tasks.Pack package.
121
+
3. Switch to the folder containing the project file and type the following command to restore the NuGet.Build.Tasks.Pack package.
102
122
103
123
```cmd
104
124
# Uses the project file in the current folder by default
Copy file name to clipboardExpand all lines: docs/reference/msbuild-targets.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,9 @@ Similarly, you can write an MSBuild task, write your own target and consume NuGe
38
38
39
39
For .NET projects that use the `PackageReference` format, using `msbuild -t:pack` draws inputs from the project file to use in creating a NuGet package.
40
40
41
+
Non-SDK-style projects will need to install the NuGet.Build.Tasks.Pack package when using Visual Studio 2022 or earlier.
42
+
We recommend uninstalling this package when upgrading to Visual Studio 2026 to ensure your project can use the latest pack features and bug fixes.
43
+
41
44
The following table describes the MSBuild properties that can be added to a project file within the first `<PropertyGroup>` node. You can make these edits easily in Visual Studio 2017 and later by right-clicking the project and selecting **Edit {project_name}** on the context menu. For convenience, the table is organized by the equivalent property in a [`.nuspec` file](../reference/nuspec.md).
42
45
43
46
> [!NOTE]
@@ -307,7 +310,8 @@ When using `MSBuild -t:pack -p:IsTool=true`, all output files, as specified in t
307
310
308
311
### Packing using a `.nuspec` file
309
312
310
-
Although it is recommended that you [include all the properties](../reference/msbuild-targets.md#pack-target) that are usually in the `.nuspec` file in the project file instead, you can choose to use a `.nuspec` file to pack your project. For a non-SDK-style project that uses `PackageReference`, you must import `NuGet.Build.Tasks.Pack.targets` so that the pack task can be executed. You still need to restore the project before you can pack a nuspec file. (An SDK-style project includes the pack targets by default.)
313
+
Although it is recommended that you [include all the properties](../reference/msbuild-targets.md#pack-target) that are usually in the `.nuspec` file in the project file instead, you can choose to use a `.nuspec` file to pack your project.
314
+
You still need to restore the project before you can pack a nuspec file. (An SDK-style project includes the pack targets by default.)
311
315
312
316
The target framework of the project file is irrelevant and not used when packing a nuspec. The following three MSBuild properties are relevant to packing using a `.nuspec`:
0 commit comments