Skip to content

Commit 932d59e

Browse files
committed
Add /docs/global-package-reference
1 parent 3b53ad5 commit 932d59e

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: GlobalPackageReference and xUnit.net
3+
---
4+
5+
# GlobalPackageReference and xUnit.net
6+
7+
Global package references are a part of [Central Package Management](https://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management#global-package-references) wherein you can specify that a package is used by every project in a solution.
8+
9+
As described in the documentation:
10+
11+
> A global package reference is used to specify that a package will be used by every project in a repository. This includes packages that do versioning, extend your build, or any other packages that are needed by all projects.
12+
13+
In essence, this feature is designed to be used for packages which _do some work during your build_, rather than packages that _have code that you want referenced in every project_. Even if for some reason you have a solution which would want xUnit.net referenced in every project, this still isn't an appropriate feature.
14+
15+
Again, according to the documentation:
16+
17+
> Global package references are added to the PackageReference item group with the following metadata:
18+
>
19+
> * `IncludeAssets="Runtime;Build;Native;contentFiles;Analyzers"`<br />
20+
This ensures that the package is only used as a development dependency and prevents it from being included as a compile-time assembly reference.
21+
>
22+
> * `PrivateAssets="All"`<br />
23+
> This prevents global package references from being picked up by downstream dependencies.
24+
25+
What's notably missing in that `IncludeAssets` list is `Compile`, which is what lets you link against the libraries in the assembly.
26+
27+
The `GlobalPackageReference` feature was clearly designed to explicit exclude the idea of using it for any code related NuGet packages. This makes it unusable with xUnit.net, since you need code provided by the NuGet packages (assertions, attributes, etc.).

site/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@
289289
href: https://github.com/xunit/xunit/blob/main/BUILDING.md
290290
- name: Why can't my test project target netstandard?
291291
href: /docs/why-no-netstandard
292+
- name: GlobalPackageReference and xUnit.net
293+
href: /docs/global-package-reference
292294

293295
- name: Advanced topics
294296
items:

0 commit comments

Comments
 (0)