Skip to content

Commit d9230aa

Browse files
Added alert callout, link and details to related MSBuild article (dotnet#26625)
* Added alert callout, link and details to related MSBuild article * Apply suggestions from code review Co-authored-by: Genevieve Warren <[email protected]> Co-authored-by: Genevieve Warren <[email protected]>
1 parent edf9df9 commit d9230aa

File tree

1 file changed

+38
-36
lines changed

1 file changed

+38
-36
lines changed
Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,41 @@
11
---
22
title: "Set assembly attributes"
33
description: You can set assembly attributes for a .NET assembly, including assembly identity, informational, assembly manifest, and strong name attributes.
4-
ms.date: "08/20/2019"
4+
ms.date: 10/22/2021
55
helpviewer_keywords:
6-
- "assemblies [.NET], attributes"
7-
- "assembly binding, attributes"
8-
- "assembly manifest, attributes"
6+
- "assemblies [.NET], attributes"
7+
- "assembly binding, attributes"
8+
- "assembly manifest, attributes"
99
ms.assetid: 36a98a81-b5b5-4c19-912a-11f91eff7f4e
1010
dev_langs:
11-
- "csharp"
12-
- "vb"
13-
- "cpp"
11+
- "csharp"
12+
- "vb"
13+
- "cpp"
1414
---
15+
1516
# Set assembly attributes
1617

1718
Assembly attributes are values that provide information about an assembly. The attributes are divided into the following sets of information:
1819

1920
- Assembly identity attributes
20-
2121
- Informational attributes
22-
2322
- Assembly manifest attributes
24-
2523
- Strong name attributes
2624

25+
> [!TIP]
26+
> This article is scoped to adding assembly attributes from code. For information on adding assembly attributes to projects (not in code), see [MSBuild reference for .NET SDK projects: Assembly attribute properties](../../core/project-sdk/msbuild-props.md#assembly-attribute-properties).
27+
2728
## Assembly identity attributes
2829

2930
Three attributes, together with a strong name (if applicable), determine the identity of an assembly: name, version, and culture. These attributes form the full name of the assembly and are required when referencing the assembly in code. You can use attributes to set an assembly's version and culture. The compiler or the [Assembly Linker (Al.exe)](../../framework/tools/al-exe-assembly-linker.md) sets the name value when the assembly is created, based on the file containing the assembly manifest.
3031

3132
The following table describes the version and culture attributes.
3233

33-
|Assembly identity attribute|Description|
34-
|---------------------------------|-----------------|
35-
|<xref:System.Reflection.AssemblyCultureAttribute>|Enumerated field indicating the culture that the assembly supports. An assembly can also specify culture independence, indicating that it contains the resources for the default culture. **Note:** The runtime treats any assembly that does not have the culture attribute set to null as a satellite assembly. Such assemblies are subject to satellite assembly binding rules. For more information, see [How the runtime locates assemblies](../../framework/deployment/how-the-runtime-locates-assemblies.md).|
36-
|<xref:System.Reflection.AssemblyFlagsAttribute>|Value that sets assembly attributes, such as whether the assembly can be run side by side.|
37-
|<xref:System.Reflection.AssemblyVersionAttribute>|Numeric value in the format *major*.*minor*.*build*.*revision* (for example, 2.4.0.0). The common language runtime uses this value to perform binding operations in strong-named assemblies. **Note:** If the <xref:System.Reflection.AssemblyInformationalVersionAttribute> attribute is not applied to an assembly, the version number specified by the <xref:System.Reflection.AssemblyVersionAttribute> attribute is used by the <xref:System.Windows.Forms.Application.ProductVersion%2A?displayProperty=nameWithType>, <xref:System.Windows.Forms.Application.UserAppDataPath%2A?displayProperty=nameWithType>, and <xref:System.Windows.Forms.Application.UserAppDataRegistry%2A?displayProperty=nameWithType> properties.|
34+
| Assembly identity attribute | Description |
35+
|--|--|
36+
| <xref:System.Reflection.AssemblyCultureAttribute> | Enumerated field indicating the culture that the assembly supports. An assembly can also specify culture independence, indicating that it contains the resources for the default culture. **Note:** The runtime treats any assembly that does not have the culture attribute set to null as a satellite assembly. Such assemblies are subject to satellite assembly binding rules. For more information, see [How the runtime locates assemblies](../../framework/deployment/how-the-runtime-locates-assemblies.md). |
37+
| <xref:System.Reflection.AssemblyFlagsAttribute> | Value that sets assembly attributes, such as whether the assembly can be run side by side. |
38+
| <xref:System.Reflection.AssemblyVersionAttribute> | Numeric value in the format _major_._minor_._build_._revision_ (for example, 2.4.0.0). The common language runtime uses this value to perform binding operations in strong-named assemblies. **Note:** If the <xref:System.Reflection.AssemblyInformationalVersionAttribute> attribute is not applied to an assembly, the version number specified by the <xref:System.Reflection.AssemblyVersionAttribute> attribute is used by the <xref:System.Windows.Forms.Application.ProductVersion%2A?displayProperty=nameWithType>, <xref:System.Windows.Forms.Application.UserAppDataPath%2A?displayProperty=nameWithType>, and <xref:System.Windows.Forms.Application.UserAppDataRegistry%2A?displayProperty=nameWithType> properties. |
3839

3940
The following code example shows how to apply the version and culture attributes to an assembly.
4041

@@ -63,39 +64,39 @@ The following code example shows how to apply the version and culture attributes
6364

6465
You can use informational attributes to provide additional company or product information for an assembly. The following table describes the informational attributes you can apply to an assembly.
6566

66-
|Informational attribute|Description|
67-
|-----------------------------|-----------------|
68-
|<xref:System.Reflection.AssemblyCompanyAttribute>|String value specifying a company name.|
69-
|<xref:System.Reflection.AssemblyCopyrightAttribute>|String value specifying copyright information.|
70-
|<xref:System.Reflection.AssemblyFileVersionAttribute>|String value specifying the Win32 file version number. This normally defaults to the assembly version.|
71-
|<xref:System.Reflection.AssemblyInformationalVersionAttribute>|String value specifying version information that is not used by the common language runtime, such as a full product version number. **Note:** If this attribute is applied to an assembly, the string it specifies can be obtained at run time by using the <xref:System.Windows.Forms.Application.ProductVersion%2A?displayProperty=nameWithType> property. The string is also used in the path and registry key provided by the <xref:System.Windows.Forms.Application.UserAppDataPath%2A?displayProperty=nameWithType> and <xref:System.Windows.Forms.Application.UserAppDataRegistry%2A?displayProperty=nameWithType> properties.|
72-
|<xref:System.Reflection.AssemblyProductAttribute>|String value specifying product information.|
73-
|<xref:System.Reflection.AssemblyTrademarkAttribute>|String value specifying trademark information.|
67+
| Informational attribute | Description |
68+
|--|--|
69+
| <xref:System.Reflection.AssemblyCompanyAttribute> | String value specifying a company name. |
70+
| <xref:System.Reflection.AssemblyCopyrightAttribute> | String value specifying copyright information. |
71+
| <xref:System.Reflection.AssemblyFileVersionAttribute> | String value specifying the Win32 file version number. This normally defaults to the assembly version. |
72+
| <xref:System.Reflection.AssemblyInformationalVersionAttribute> | String value specifying version information that is not used by the common language runtime, such as a full product version number. **Note:** If this attribute is applied to an assembly, the string it specifies can be obtained at run time by using the <xref:System.Windows.Forms.Application.ProductVersion%2A?displayProperty=nameWithType> property. The string is also used in the path and registry key provided by the <xref:System.Windows.Forms.Application.UserAppDataPath%2A?displayProperty=nameWithType> and <xref:System.Windows.Forms.Application.UserAppDataRegistry%2A?displayProperty=nameWithType> properties. |
73+
| <xref:System.Reflection.AssemblyProductAttribute> | String value specifying product information. |
74+
| <xref:System.Reflection.AssemblyTrademarkAttribute> | String value specifying trademark information. |
7475

75-
These attributes can appear on the Windows Properties page of the assembly, or they can be overridden using the **/win32res** compiler option to specify your own Win32 resource file.
76+
These attributes can appear on the Windows Properties page of the assembly, or they can be overridden using the **/win32res** compiler option to specify your Win32 resource file.
7677

7778
## Assembly manifest attributes
7879

7980
You can use assembly manifest attributes to provide information in the assembly manifest, including title, description, the default alias, and configuration. The following table describes the assembly manifest attributes.
8081

81-
|Assembly manifest attribute|Description|
82-
|---------------------------------|-----------------|
83-
|<xref:System.Reflection.AssemblyConfigurationAttribute>|String value indicating the configuration of the assembly, such as Retail or Debug. The runtime does not use this value.|
84-
|<xref:System.Reflection.AssemblyDefaultAliasAttribute>|String value specifying a default alias to be used by referencing assemblies. This value provides a friendly name when the name of the assembly itself is not friendly (such as a GUID value). This value can also be used as a short form of the full assembly name.|
85-
|<xref:System.Reflection.AssemblyDescriptionAttribute>|String value specifying a short description that summarizes the nature and purpose of the assembly.|
86-
|<xref:System.Reflection.AssemblyTitleAttribute>|String value specifying a friendly name for the assembly. For example, an assembly named *comdlg* might have the title Microsoft Common Dialog Control.|
82+
| Assembly manifest attribute | Description |
83+
|--|--|
84+
| <xref:System.Reflection.AssemblyConfigurationAttribute> | String value indicating the configuration of the assembly, such as Retail or Debug. The runtime does not use this value. |
85+
| <xref:System.Reflection.AssemblyDefaultAliasAttribute> | String value specifying a default alias to be used by referencing assemblies. This value provides a friendly name when the name of the assembly itself is not friendly (such as a GUID value). This value can also be used as a short form of the full assembly name. |
86+
| <xref:System.Reflection.AssemblyDescriptionAttribute> | String value specifying a short description that summarizes the nature and purpose of the assembly. |
87+
| <xref:System.Reflection.AssemblyTitleAttribute> | String value specifying a friendly name for the assembly. For example, an assembly named _comdlg_ might have the title Microsoft Common Dialog Control. |
8788

8889
## Strong name attributes
8990

9091
You can use strong name attributes to set a strong name for an assembly. The following table describes the strong name attributes.
9192

92-
|Strong name attribute|Description|
93-
|----------------------------|-----------------|
94-
|<xref:System.Reflection.AssemblyDelaySignAttribute>|Boolean value indicating that delay signing is being used.|
95-
|<xref:System.Reflection.AssemblyKeyFileAttribute>|String value indicating the name of the file that contains either the public key (if using delay signing) or both the public and private keys passed as a parameter to the constructor of this attribute. Note that the file name is relative to the output file path (the *.exe* or *.dll*), not the source file path.|
96-
|<xref:System.Reflection.AssemblyKeyNameAttribute>|Indicates the key container that contains the key pair passed as a parameter to the constructor of this attribute.|
93+
| Strong name attribute | Description |
94+
|--|--|
95+
| <xref:System.Reflection.AssemblyDelaySignAttribute> | Boolean value indicating that delay signing is being used. |
96+
| <xref:System.Reflection.AssemblyKeyFileAttribute> | String value indicating the name of the file that contains either the public key (if using delay signing) or both the public and private keys passed as a parameter to the constructor of this attribute. Note that the file name is relative to the output file path (the _.exe_ or _.dll_), not the source file path. |
97+
| <xref:System.Reflection.AssemblyKeyNameAttribute> | Indicates the key container that contains the key pair passed as a parameter to the constructor of this attribute. |
9798

98-
The following code example shows the attributes to apply when using delay signing to create a strong-named assembly with a public key file called *myKey.snk*.
99+
The following code example shows the attributes to apply when using delay signing to create a strong-named assembly with a public key file called _myKey.snk_.
99100

100101
```cpp
101102
[assembly:AssemblyKeyFileAttribute("myKey.snk")];
@@ -115,3 +116,4 @@ The following code example shows the attributes to apply when using delay signin
115116
## See also
116117

117118
- [Create assemblies](create.md)
119+
- [MSBuild reference for .NET SDK projects](../../core/project-sdk/msbuild-props.md)

0 commit comments

Comments
 (0)