- Put
Directory.Build.props
andDirectory.Build.targets
to root of your repository (or to where exist.sln
file). These files are automatically added by msbuild to all projects (csproj
s) that are in file system in folders under.targets
and.props
files. - On your CI set required
GitBranch
msbuild property. This is required because most of CI do not checkout to branch, but to commit so you need explicitly add this to msbuild (dotnet cli). It is added to nuget metadata.- [optional] (but recommended) -
BuildNumber
is used for build number for prerelease packages (it is used . instead of + because nuget do not support it). If is not filled, is used git SHA (with this is not working proper prerelease sorting in git) (i.e.20201222.12
will be `1.0.0-prereleasefield..20201222.12) - [optional] -
PreReleaseField
is used for specifying prerelease field. If is not filled it is created from git branch without /
- [optional] (but recommended) -
- Add Git metadata to nugets (repository url, git branch, git commit)
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>TestClassLib</id>
<version>1.0.0-featurenewitem.20201222.11</version>
<authors>Patrik</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Package Description</description>
<repository type="git" url="https://dev.azure.com/mysuperorganization/GitMetadataInfrastructure/_git/GitMetadataInfrastructure" branch="feature/newitem" commit="4d21db7d9389f9d94d03b820ae4f5a9970390249" />
<dependencies>
<group targetFramework=".NETStandard2.0" />
</dependencies>
</metadata>
</package>
- Add git metadata to all created dlls (set
InformationalVersion
) - If is dll/nuget created with some nonstandard way (from dirty repo) add
dirty
field to dllInformationalVersion
and nuget version. - Add Sourcelink support for packages
- Add pdb to nugets (It is not best practice , but ADO do not support snupkg 😢 see docs)
- because of this is required to add to consumers this dotnet/sdk#1458 (comment)