Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 3 additions & 29 deletions docs/project/library-servicing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,11 @@ This document provides the steps necessary after modifying a library in a servic

## Check if a package is generated

If a library's source project sets `<IsPackable>true</IsPackable>` a package is generated. If the library's source project doesn't set `<IsPackable>true</IsPackable>`, the library likely is part of the shared framework (to check for that, look into the `NetCoreAppLibrary.props` file). If it is, then there is nothing that needs to be done here.
If a library is packable (check for the `<IsPackable>true</IsPackable>` property) you'll need to set `<GeneratePackageOnBuild>true</GeneratePackageOnBuild>` in the source project. That is necessary as packages aren't generated by default in servicing releases.

## Determine PackageVersion
## Determine ServiceVersion

Each package has a property called `PackageVersion`. When you make a change to a library & ship it, the `PackageVersion` must be bumped. This property could either be in one of two places inside your library's source folder: `Directory.Build.Props`, or in the the source project (under src/). It's also possible that the property is in neither of those files, in which case we're using the default version which is calculated based on the version properties in the [Versions.props](https://github.com/dotnet/runtime/blob/95147163dac477da5177f5c5402ae9b93feb5c89/eng/Versions.props#L6-L8) file. (IMPORTANT - make sure to check the default version from the branch that you're making changes to, not from main). You'll need to increment this package version. If the property is already present in your library's source folder, just increment the patch version by 1 (e.g. `4.6.0` -> `4.6.1`). If it's not present, add it to the library's `Directory.Build.props`, where it is equal to the patch version in `Version.props`, but with the patch version incremented by one.

Note that it's possible that somebody else has already incremented the package version since our last release. If this is the case, you don't need to increment it yourself. To confirm, check [Nuget.org](https://www.nuget.org/) to see if there is already a published version of your package with the same package version. If so, the `PackageVersion` must be incremented. If not, there's still a possibility that the version should be bumped, in the event that we've already built the package with its current version in an official build, but haven't released it publicly yet. If you see that the `PackageVersion` has been changed in the last 1-2 months, but don't see a matching package in Nuget.org, contact somebody on the servicing team for guidance.

## Determine AssemblyVersion

A library's assembly version is controlled by the property `AssemblyVersion`. If the property exists, it's either located in the library's source project or in its `Directory.Build.props` file. If it doesn't exist, it uses the [centrally defined version](https://github.com/dotnet/runtime/blob/1fb151f63dca644347a5c608d7ab17f7cb8e1ccb/eng/Versions.props#L14) and you want to add the property to the library's `Directory.Build.props` file. For servicing events you will want to increment the revision by 1 (e.g `4.0.0.0` -> `4.0.0.1`) if the library ships in its own package and has an asset that is applicable to .NET Framework. To determine if it applies to .NET Framework you should check to see if there are any `netstandard` or `net4x` target frameworks in the source project and if there are, it has assets that apply.

The reason we need to increment the assembly version for things running on .NET Framework is because of the way binding works there. If there are two assemblies with the same assembly version the loader will essentially pick the first one it finds and use that version so applications don't have full control over using the later build with a particular fix included. This is worse if someone puts the older assembly in the GAC as the GAC will always win for matching assembly versions so an application couldn't load the newer one because it has the same assembly version.

If this library ships both inbox on a platform and in its own library package then we need to keep the reference assembly version pinned to the same version that was shipped inbox on. In those cases we generally need to condition the AssemblyVersion in the library `ref` project like such:

```
<!-- Must match version supported by frameworks which support 4.0.* inbox.
Can be removed when API is added and this assembly is versioned to 4.1.* -->
<AssemblyVersion Condition="!$(TargetFramework.StartsWith('net4'))' != 'true'">4.0.3.0</AssemblyVersion>
```
Where the `AssemblyVersion` is set to the old version before updating. To determine if the library ships inbox you can look at the list in [NetCoreAppLibrary.props](https://github.com/dotnet/runtime/blob/95147163dac477da5177f5c5402ae9b93feb5c89/src/libraries/NetCoreAppLibrary.props#L1).

If the library is part of a Aspnetcore or .NET targeting pack then we cannot increment the assembly version. For Aspnetcore, You can examine the ```<IsAspNetCoreApp>true</IsAspNetCoreApp>``` property in the library`s ```Directory.Build.props```
For .Net you can examine the list in ```NetCoreAppLibrary.props```

If the library is part of a targeting pack and also contains an asset applicable to the .NET Framework then we will increment the assembly version for that asset.
eg.
```
<AssemblyVersion Condition="$(TargetFramework.StartsWith('net4'))">6.0.0.1</AssemblyVersion>
```
When you make a change to a library & ship it during the servicing release, the `ServicingVersion` must be bumped. This property is found in the library's source project. It's also possible that the property is not in that file, in which case you'll need to add it to the library's source project and set it to 1. If the property is already present in your library's source project, just increment the servicing version by 1.
Comment thread
Anipik marked this conversation as resolved.
Resolved

## Test your changes

Expand Down
9 changes: 9 additions & 0 deletions eng/packaging.targets
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@
<UseIntellisenseDocumentationFile Condition="'$(UseIntellisenseDocumentationFile)' == '' and Exists('$(LibIntellisenseDocumentationFilePath)')">true</UseIntellisenseDocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(ServicingVersion)' != ''">
<!-- Always update the package version in servicing. -->
<PackageVersion>$(MajorVersion).$(MinorVersion).$(ServicingVersion)</PackageVersion>
<IsWindowsDesktop Condition="$(WindowsDesktopCoreAppLibrary.Contains('$(AssemblyName);'))">true</IsWindowsDesktop>
Comment thread
Anipik marked this conversation as resolved.
Resolved
<_AssemblyInTargetingPack Condition="'$(IsNETCoreAppSrc)' == 'true' or '$(IsAspNetCoreApp)' == 'true' or '$(IsWindowsDesktop)' == 'true'">true</_AssemblyInTargetingPack>
<!-- Assembly version do not get updated in non-netfx ref pack assemblies. -->
<AssemblyVersion Condition="'$(_AssemblyInTargetingPack)' != 'true' or '$(TargetFrameworkIdentifier)' == '.NETFramework'">$(MajorVersion).$(MinorVersion).0.$(ServicingVersion)</AssemblyVersion>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't AssemblyVersion be set outside of this file so that it also applies to reference assemblies and source generators assemblies (the latter doesn't import this file as they aren't packable)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't AssemblyVersion be set outside of this file so that it also applies to reference assemblies and source generators assemblies (the latter doesn't import this file as they aren't packable)?

we don`t need to update the reference assemblies as we never change them in servicing and anyway we are not shipping them in 6.0.
For generators assemblies, we will have to decide if we want to always increment with the package or only when we make a change in generator.

Shouldn't AssemblyVersion be set outside of this files

Instead i will suggest to add the packaging.targets file to analyzers as well. (using IsNETCoreAppAnalyzer property)

are any of the analyzers part of the shared framework ?

@ViktorHofer ViktorHofer Aug 12, 2021 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are any of the analyzers part of the shared framework ?

Yes, the System.Text.Json one is part of the shared framework.

Instead i will suggest to add the packaging.targets file to analyzers as well. (using IsNETCoreAppAnalyzer property)

Analyzers aren't packable themselves so it doesn't make sense for them to import packaging.targets. The code in that file is specific to projects which pack. I would keep the PackageVersion property in packaging.props and move the AssemblyVersion sectionout and make sure that it applies to both source projects and analyzers.

For generators assemblies, we will have to decide if we want to always increment with the package or only when we make a change in generator.

My gut feeling says that we should keep the AssemblyVersion of source assemblies in sync with their source generators. For that we might need two more properties in NetCoreAppLibrary.props (btw we should change that file's name at some point): AspNetCoreAppAnalyzer and NetCoreAppAnalyzer.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting more thought into this, I don't think that introducing properties for analyzers in NetCoreAppLibrary.props is necessary. It is probably easier to apply the same assembly version to both the source assembly and the analyzer assembly.

If the project is a generator project you would need to check if the "corresponding" source assembly is part of any shared framework.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now all existing source generators are shipping as part of a shared framework (either netcoreapp or aspnetcoreapp) so if this becomes to complicated to implement you might just ignore them for 6.0 and never increment their assembly version.

If you want to go down that path then your PR in its current state is probably sufficient.

</PropertyGroup>

<ItemGroup Condition="'$(EnablePackageValidation)' == 'true'">
<PackageReference Include="Microsoft.DotNet.PackageValidation" Version="$(MicrosoftDotNetPackageValidationVersion)" PrivateAssets="all" IsImplicitlyDefined="true" />
<!-- TODO: Remove when the SDK is upgraded to RC1. -->
Expand Down
1 change: 1 addition & 0 deletions src/libraries/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<IsNETCoreAppRef Condition="'$(IsNETCoreAppRef)' == '' and
'$(IsReferenceAssembly)' == 'true' and
$(NetCoreAppLibrary.Contains('$(AssemblyName);'))">true</IsNETCoreAppRef>
<IsAspNetCoreApp Condition="$(AspNetCoreAppLibrary.Contains('$(AssemblyName);'))">true</IsAspNetCoreApp>

<!-- By default, disable implicit framework references for NetCoreAppCurrent libraries. -->
<DisableImplicitFrameworkReferences Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project>
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<IsAspNetCoreApp>true</IsAspNetCoreApp>
<IncludePlatformAttributes>true</IncludePlatformAttributes>
</PropertyGroup>
</Project>

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project>
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<IsAspNetCoreApp>true</IsAspNetCoreApp>
<IncludePlatformAttributes>true</IncludePlatformAttributes>
</PropertyGroup>
</Project>
6 changes: 0 additions & 6 deletions src/libraries/Microsoft.Extensions.Http/Directory.Build.props

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@

<PropertyGroup>
<NoWarn>$(NoWarn);PKG0001</NoWarn>
<IsAspNetCoreApp>true</IsAspNetCoreApp>
</PropertyGroup>
</Project>

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

19 changes: 18 additions & 1 deletion src/libraries/NetCoreAppLibrary.props
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,27 @@
System.IO.Pipelines;
System.Security.Cryptography.Xml;
</AspNetCoreAppLibrary>
<WindowsDesktopCoreAppLibrary>
Comment thread
Anipik marked this conversation as resolved.
Resolved
System.CodeDom;
System.Configuration.ConfigurationManager;
System.Diagnostics.EventLog;
System.Diagnostics.PerformanceCounter;
System.DirectoryServices;
System.Drawing.Common;
System.IO.Packaging;
System.Resources.Extensions;
System.Security.Cryptography.Pkcs;
System.Security.Cryptography.ProtectedData;
System.Security.Cryptography.Xml;
System.Security.Permissions;
System.Threading.AccessControl;
System.Windows.Extensions;
</WindowsDesktopCoreAppLibrary>
</PropertyGroup>
<!-- Make NetCoreAppLibrary available as an item. -->
<!-- Make available as an item. -->
<ItemGroup>
<NetCoreAppLibrary Include="$(NetCoreAppLibrary)" />
<AspNetCoreAppLibrary Include="$(AspNetCoreAppLibrary)" />
<WindowsDesktopCoreAppLibrary Include="$(WindowsDesktopCoreAppLibrary)" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project>
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<IsAspNetCoreApp>true</IsAspNetCoreApp>
<SupportedOSPlatforms>windows</SupportedOSPlatforms>
</PropertyGroup>
</Project>
6 changes: 0 additions & 6 deletions src/libraries/System.IO.Pipelines/Directory.Build.props

This file was deleted.

1 change: 0 additions & 1 deletion src/libraries/System.Net.Quic/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<StrongNameKeyId>Microsoft</StrongNameKeyId>
<IncludePlatformAttributes>true</IncludePlatformAttributes>
<IsAspNetCoreApp>true</IsAspNetCoreApp>
<SupportedOSPlatforms>windows;linux;macos</SupportedOSPlatforms>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<StrongNameKeyId>Microsoft</StrongNameKeyId>
<IsAspNetCoreApp>true</IsAspNetCoreApp>
<IncludePlatformAttributes>true</IncludePlatformAttributes>
<UnsupportedOSPlatforms>browser</UnsupportedOSPlatforms>
</PropertyGroup>
Expand Down
Loading