Skip to content

Commit 34f492d

Browse files
authored
Merge pull request #3404 from NuGet/main
Publish Main to live
2 parents b93aee7 + 4c46659 commit 34f492d

17 files changed

+113
-347
lines changed

.openpublishing.redirection.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"source_path": "docs/Quickstart/Create-and-publish-a-package.md",
100100
"redirect_url": "/nuget/quickstart/create-and-publish-a-package-using-visual-studio",
101101
"redirect_document_id": false
102-
},
102+
},
103103
{
104104
"source_path": "docs/Quickstart/Use-a-Package.md",
105105
"redirect_url": "/nuget/quickstart/install-and-use-a-package-in-visual-studio",
@@ -384,6 +384,11 @@
384384
"source_path": "docs/reference/errors-and-warnings/NU1904.md",
385385
"redirect_url": "/nuget/reference/errors-and-warnings/NU1901-NU1904",
386386
"redirect_document_id": false
387+
},
388+
{
389+
"source_path": "docs/guides/create-packages-for-xamarin.md",
390+
"redirect_url": "/nuget",
391+
"redirect_document_id": false
387392
}
388393
]
389394
}

docs/TOC.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
### [Create a native package](guides/native-packages.md)
5656
### [Create UI controls as a NuGet package](guides/create-UI-controls.md)
5757
### [Create an analyzer as a NuGet package](guides/analyzers-conventions.md)
58-
### [Create a package for Xamarin with Visual Studio 2017 or 2019](guides/create-packages-for-xamarin.md)
5958
### [Create a package with COM interop assemblies](create-packages/author-packages-with-COM-interop-assemblies.md)
6059
## Sign packages
6160
### [Sign a package](create-packages/sign-a-package.md)

docs/concepts/Auditing-Packages.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ description: How to audit package dependencies for security vulnerabilities and
44
author: JonDouglas
55
ms.author: jodou
66
ms.topic: conceptual
7+
ms.date: 02/11/2025
78
---
89

910
# Auditing package dependencies for security vulnerabilities
@@ -105,6 +106,34 @@ Alternatively, if you want to keep low and moderate vulnerabilities as warnings,
105106
> [!NOTE]
106107
> MSBuild properties for message severity such as `NoWarn` and `TreatWarningsAsErrors` are not supported for packages.config projects.
107108
109+
## Ensure restore audited projects
110+
111+
NuGet in MSBuild 17.13 and .NET 9.0.200 added output properties `RestoreProjectCount`, `RestoreSkippedCount` and `RestoreProjectsAuditedCount` on the restore task.
112+
This can be used to enforce that audit ran during a restore.
113+
Note that these output properties are not available with [static graph restore](../reference/msbuild-targets.md#restoring-with-msbuild-static-graph-evaluation).
114+
115+
Since MSBuild is a scripting language, this can be achieved a number of different ways, but also has the same restrictions as MSBuild has.
116+
One example is to create a file *Directory.Solution.targets* in the same directory as your solution file, whose contents has a target similar to the following.
117+
Note that *Directory.Build.props* is commonly used, but is imported by projects.
118+
However, NuGet's restore target and task runs at the solution level, so needs to be in MSBuild's solution extensibility file, not the project/build file.
119+
120+
```xml
121+
<Project>
122+
<Target Name="AssertRestoreTaskOutputProperties"
123+
AfterTargets="Restore"
124+
Condition="'$(CI)' == 'true'">
125+
<Error
126+
Condition="'$(RestoreProjectsAuditedCount)' != '$(RestoreProjectCount)'"
127+
Text=""Restore did not audit every project in the solution. Expected: $(RestoreProjectCount) Found: $(RestoreProjectsAuditedCount)"" />
128+
</Target>
129+
</Project>
130+
```
131+
132+
Depending on your use-case, you may wish to use condition `'$(RestoreProjectCount)' != '$([MSBuild::Add($(RestoreProjectsAuditedCount), $(RestoreSkippedCount))'` on the error message, to account for projects that restore skipped because they were already up to date.
133+
Similarly, think about if you want this error to happen everywhere, or only in CI pipelines, and what environment variables are defined in your CI environment, and factor this into the target's condition.
134+
Again, since MSBuild is a scripting language, you can use any of its capabilities to customize your repo however you want.
135+
Viewing [MSBuild's metaproj](/visualstudio/msbuild/how-to-build-specific-targets-in-solutions-by-using-msbuild-exe#troubleshooting) and [binlogs](/visualstudio/msbuild/msbuild-command-line-reference#switches-for-loggers) are useful to develop and troubleshoot solution level targets.
136+
108137
## `dotnet list package --vulnerable`
109138

110139
Once a project is successfully restored, [`dotnet list package`](/dotnet/core/tools/dotnet-list-package) has a `--vulnerable` argument to filter the packages based on which packages have known vulnerabilities.

docs/concepts/Package-Versioning.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ Avoid specifying an upper bound to version ranges to packages you don't own unle
132132
Will resolve to the highest acceptable stable version.-->
133133
<PackageReference Include="ExamplePackage" Version="6.*" />
134134

135+
<!-- Accepts only version 6.1.0. -->
136+
<PackageReference Include="ExamplePackage" Version="[6.1.0]" />
137+
135138
<!-- Accepts any version above, but not including 4.1.3. Could be
136139
used to guarantee a dependency with a specific bug fix.
137140
Will resolve to the smallest acceptable stable version.-->

docs/consume-packages/Central-Package-Management.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ When you use the pack command to create a package, both packages will appear in
165165

166166
```xml
167167
<group targetFramework="net6.0">
168-
<dependency id="PackageA" version="6.12.1" exclude="Build,Analyzers" />
169-
<dependency id="PackageB" version="6.12.1" exclude="Build,Analyzers" />
168+
<dependency id="PackageA" version="1.0.0" exclude="Build,Analyzers" />
169+
<dependency id="PackageB" version="2.0.0" exclude="Build,Analyzers" />
170170
</group>
171171
```
172172

docs/consume-packages/Package-Restore.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Select **Automatically check for missing packages during build in Visual Studio*
8787
</configuration>
8888
```
8989

90-
For non-SDK-style projects, you must select **Allow NuGet to download missing packages** as well as **Automatically check for missing packages during build in Visual Studio** in **Options** to enable automatic restore.
90+
You must select **Allow NuGet to download missing packages** as well as **Automatically check for missing packages during build in Visual Studio** in **Options** to enable package restore during build.
9191

9292
<a name="choose-default-package-management-format"></a>
9393
#### Choose the default package management format

0 commit comments

Comments
 (0)