|
| 1 | +<Project> |
| 2 | + <!-- To extend/change the defaults, create a Directory.props alongside this file --> |
| 3 | + |
| 4 | + <PropertyGroup Label="CI" Condition="'$(CI)' == ''"> |
| 5 | + <CI>false</CI> |
| 6 | + <!-- GH, CircleCI, GitLab and BitBucket already use CI --> |
| 7 | + <CI Condition="'$(TF_BUILD)' == 'true' or |
| 8 | + '$(TEAMCITY_VERSION)' != '' or |
| 9 | + '$(APPVEYOR)' != '' or |
| 10 | + '$(BuildRunner)' == 'MyGet' or |
| 11 | + '$(JENKINS_URL)' != '' or |
| 12 | + '$(TRAVIS)' == 'true' or |
| 13 | + '$(BUDDY)' == 'true'">true</CI> |
| 14 | + </PropertyGroup> |
| 15 | + |
| 16 | + <PropertyGroup> |
| 17 | + <!-- The Microsoft.Managed.Core.targets use this property to use deterministic source paths in CI builds --> |
| 18 | + <ContinuousIntegrationBuild>$(CI)</ContinuousIntegrationBuild> |
| 19 | + </PropertyGroup> |
| 20 | + |
| 21 | + <PropertyGroup Label="NuGet"> |
| 22 | + <Authors>Daniel Cazzulino</Authors> |
| 23 | + <Copyright>Copyright (C) Daniel Cazzulino and Contributors. All rights reserved.</Copyright> |
| 24 | + <PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance> |
| 25 | + <PackageLicenseExpression>MIT</PackageLicenseExpression> |
| 26 | + |
| 27 | + <!-- Pick src-level readme+icon automatically --> |
| 28 | + <PackageIcon Condition="Exists('$(MSBuildThisFileDirectory)icon.png')">icon.png</PackageIcon> |
| 29 | + <PackageReadmeFile Condition="'$(PackReadme)' != 'false' and Exists('$(MSBuildThisFileDirectory)readme.md')">readme.md</PackageReadmeFile> |
| 30 | + <!-- Pick project-level readme+icon overrides automatically --> |
| 31 | + <PackageIcon Condition="Exists('$(MSBuildProjectDirectory)\icon.png')">icon.png</PackageIcon> |
| 32 | + <PackageReadmeFile Condition="'$(PackReadme)' != 'false' and Exists('$(MSBuildProjectDirectory)\readme.md')">readme.md</PackageReadmeFile> |
| 33 | + |
| 34 | + <PublishRepositoryUrl>true</PublishRepositoryUrl> |
| 35 | + <GenerateRepositoryUrlAttribute>true</GenerateRepositoryUrlAttribute> |
| 36 | + |
| 37 | + <PackageOutputPath Condition="'$(PackageOutputPath)' == ''">$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\bin'))</PackageOutputPath> |
| 38 | + |
| 39 | + <!-- Use Directory.Packages.props if possible. NOTE: other MSBuild SDKs (i.e. NoTargets/Traversal) do not support central packages --> |
| 40 | + <ManagePackageVersionsCentrally Condition="Exists('$(MSBuildThisFileDirectory)Directory.Packages.props')">true</ManagePackageVersionsCentrally> |
| 41 | + <CentralPackageFloatingVersionsEnabled>true</CentralPackageFloatingVersionsEnabled> |
| 42 | + |
| 43 | + <!-- Ensure MSBuild tooling can access package artifacts always via PKG_[PackageId] --> |
| 44 | + <GeneratePathProperty>true</GeneratePathProperty> |
| 45 | + </PropertyGroup> |
| 46 | + |
| 47 | + <PropertyGroup Label="Build"> |
| 48 | + <Configuration Condition="'$(Configuration)' == '' and $(CI)">Release</Configuration> |
| 49 | + <LangVersion>Latest</LangVersion> |
| 50 | + |
| 51 | + <!-- See https://docs.microsoft.com/en-us/dotnet/standard/assembly/reference-assemblies --> |
| 52 | + <ProduceReferenceAssembly>false</ProduceReferenceAssembly> |
| 53 | + <!-- Because they are small and super useful and supported everywhere --> |
| 54 | + <DebugType>embedded</DebugType> |
| 55 | + <DebugSymbols>true</DebugSymbols> |
| 56 | + <Nullable>enable</Nullable> |
| 57 | + <!-- See https://www.meziantou.net/csharp-compiler-strict-mode.htm --> |
| 58 | + <Features>strict</Features> |
| 59 | + |
| 60 | + <!-- Simplify namespaces by defaulting to the single root name --> |
| 61 | + <RootNamespace>$(MSBuildProjectName)</RootNamespace> |
| 62 | + <RootNamespaceDot>$(MSBuildProjectName.IndexOf('.'))</RootNamespaceDot> |
| 63 | + <RootNamespace Condition="'$(RootNamespaceDot)' != '-1'">$(MSBuildProjectName.Substring(0, $(RootNamespaceDot)))</RootNamespace> |
| 64 | + |
| 65 | + <!-- We typically don't want these files shown in the solution explorer --> |
| 66 | + <DefaultItemExcludes>$(DefaultItemExcludes);*.binlog;*.zip;*.rsp;*.items;**/TestResults/**/*.*</DefaultItemExcludes> |
| 67 | + |
| 68 | + <EnableSourceLink>true</EnableSourceLink> |
| 69 | + <EnableSourceControlManagerQueries>true</EnableSourceControlManagerQueries> |
| 70 | + <EmbedUntrackedSources>true</EmbedUntrackedSources> |
| 71 | + <UseSourceLink>true</UseSourceLink> |
| 72 | + |
| 73 | + <!-- Generate satellite assemblies using csc.exe to avoid some al.exe issues. See https://github.com/dotnet/msbuild/pull/2726 --> |
| 74 | + <GenerateSatelliteAssembliesForCore>true</GenerateSatelliteAssembliesForCore> |
| 75 | + |
| 76 | + <!-- See: https://www.cazzulino.com/project-dependencies-as-project-references.html --> |
| 77 | + <AddSyntheticProjectReferencesForSolutionDependencies>false</AddSyntheticProjectReferencesForSolutionDependencies> |
| 78 | + |
| 79 | + <!-- Don't warn for packages using semver 2.0 --> |
| 80 | + <NoWarn>NU5105;$(NoWarn)</NoWarn> |
| 81 | + <!-- Turn warnings into errors in CI or Release builds --> |
| 82 | + <WarningsAsErrors Condition="$(CI) or '$(Configuration)' == 'Release'">true</WarningsAsErrors> |
| 83 | + |
| 84 | + <!-- Preserve transitively copied content in VS: https://github.com/dotnet/msbuild/issues/1054#issuecomment-847959047 --> |
| 85 | + <MSBuildCopyContentTransitively>true</MSBuildCopyContentTransitively> |
| 86 | + |
| 87 | + <!-- Global tools should run on whatever latest runtime is installed. See https://docs.microsoft.com/en-us/dotnet/core/versions/selection#framework-dependent-apps-roll-forward --> |
| 88 | + <RollForward>LatestMinor</RollForward> |
| 89 | + </PropertyGroup> |
| 90 | + |
| 91 | + <PropertyGroup Label="StrongName" Condition="Exists('$(MSBuildThisFileDirectory)kzu.snk')"> |
| 92 | + <!-- We use a single oss signing key for consumers that need strong-named assemblies --> |
| 93 | + <AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)kzu.snk</AssemblyOriginatorKeyFile> |
| 94 | + <!-- These properties make it easier to add internals visible to other projects, even when signing is involved. |
| 95 | + For example, you can simply add: |
| 96 | + <InternalsVisibleTo Include="MyProject.UnitTests" /> |
| 97 | +
|
| 98 | + and the key will be appended automatically. |
| 99 | + --> |
| 100 | + <PublicKey>002400000480000094000000060200000024000052534131000400000100010051155fd0ee280be78d81cc979423f1129ec5dd28edce9cd94fd679890639cad54c121ebdb606f8659659cd313d3b3db7fa41e2271158dd602bb0039a142717117fa1f63d93a2d288a1c2f920ec05c4858d344a45d48ebd31c1368ab783596b382b611d8c92f9c1b3d338296aa21b12f3bc9f34de87756100c172c52a24bad2db</PublicKey> |
| 101 | + <PublicKeyToken>00352124762f2aa5</PublicKeyToken> |
| 102 | + <SignAssembly>true</SignAssembly> |
| 103 | + </PropertyGroup> |
| 104 | + |
| 105 | + <PropertyGroup Label="Version"> |
| 106 | + <!-- Versioning: when building locally, it's always 42.42.42. |
| 107 | + This makes it always bigger than any public package version, and |
| 108 | + consistent and fixed for dogfooding. |
| 109 | + NuGetizer nukes the package cache on build, making this straightforward too. |
| 110 | + CI (non-release) builds pass in a VersionSuffix property to append a label |
| 111 | + after the fixed prefix. This allows dogfooding a branch build. |
| 112 | + The suffix is sanitized and optionally turned into |
| 113 | + --> |
| 114 | + <VersionPrefix Condition="$(VersionPrefix) == ''">42.42.42</VersionPrefix> |
| 115 | + </PropertyGroup> |
| 116 | + |
| 117 | + <PropertyGroup Label="Version" Condition="$(VersionLabel) != ''"> |
| 118 | + <_VersionLabel>$(VersionLabel.Replace('refs/heads/', ''))</_VersionLabel> |
| 119 | + <_VersionLabel>$(_VersionLabel.Replace('refs/tags/v', ''))</_VersionLabel> |
| 120 | + |
| 121 | + <!-- For PRs, we just need a fixed package version numbered after the PR # itself, so remove the commits # at the end --> |
| 122 | + <_VersionLabel Condition="$(_VersionLabel.Contains('refs/pull/'))">$(VersionLabel.TrimEnd('.0123456789'))</_VersionLabel> |
| 123 | + <!-- Next replace the prefix for simply 'pr', so we end up with 'pr99/merge' by default --> |
| 124 | + <_VersionLabel>$(_VersionLabel.Replace('refs/pull/', 'pr'))</_VersionLabel> |
| 125 | + <!-- Remove the /merge now, if present --> |
| 126 | + <_VersionLabel>$(_VersionLabel.Replace('/merge', ''))</_VersionLabel> |
| 127 | + <!-- Finally sanitize the branch with dashes, so we can build path-separated branches, like rel/v1.0.0 or feature/foo --> |
| 128 | + <_VersionLabel>$(_VersionLabel.Replace('/', '-'))</_VersionLabel> |
| 129 | + |
| 130 | + <!-- Set sanitized version to the actual version suffix used in build/pack --> |
| 131 | + <VersionSuffix Condition="!$(VersionLabel.Contains('refs/tags/'))">$(_VersionLabel)</VersionSuffix> |
| 132 | + <!-- Special case for tags, the label is actually the version. Backs compat since passed-in value overrides MSBuild-set one --> |
| 133 | + <Version Condition="$(VersionLabel.Contains('refs/tags/'))">$(_VersionLabel)</Version> |
| 134 | + </PropertyGroup> |
| 135 | + |
| 136 | + <ItemGroup Label="ThisAssembly.Project"> |
| 137 | + <ProjectProperty Include="CI" /> |
| 138 | + |
| 139 | + <ProjectProperty Include="Version" /> |
| 140 | + <ProjectProperty Include="VersionPrefix" /> |
| 141 | + <ProjectProperty Include="VersionSuffix" /> |
| 142 | + |
| 143 | + <ProjectProperty Include="PublicKey" /> |
| 144 | + <ProjectProperty Include="PublicKeyToken" /> |
| 145 | + </ItemGroup> |
| 146 | + |
| 147 | + <ItemGroup Label="Throw"> |
| 148 | + <Using Include="System.ArgumentException" Static="true" /> |
| 149 | + <Using Include="System.ArgumentOutOfRangeException" Static="true" /> |
| 150 | + <Using Include="System.ArgumentNullException" Static="true" /> |
| 151 | + </ItemGroup> |
| 152 | + |
| 153 | + <Import Project="Directory.props" Condition="Exists('Directory.props')"/> |
| 154 | + <Import Project="Directory.props.user" Condition="Exists('Directory.props.user')" /> |
| 155 | + |
| 156 | + <!-- If the imported props changed ManagePackageVersionsCentrally, we need to replicate |
| 157 | + the Version defaults from Microsoft.NET.DefaultAssemblyInfo.targets since it's too |
| 158 | + early here and Directory.Packages.props will be imported right after this time, |
| 159 | + meaning dependencies that expect to use the currently building Version would not |
| 160 | + get the expected value. |
| 161 | + --> |
| 162 | + <PropertyGroup Condition="'$(ManagePackageVersionsCentrally)' == 'true' and '$(Version)' == ''"> |
| 163 | + <VersionPrefix Condition=" '$(VersionPrefix)' == '' ">1.0.0</VersionPrefix> |
| 164 | + <Version Condition=" '$(VersionSuffix)' != '' ">$(VersionPrefix)-$(VersionSuffix)</Version> |
| 165 | + <Version Condition=" '$(Version)' == '' ">$(VersionPrefix)</Version> |
| 166 | + </PropertyGroup> |
| 167 | + |
| 168 | + <!-- Implemented by SDK in .targets, guaranteeing it's overwritten. Added here since we add a DependsOnTargets to it. |
| 169 | + Covers backwards compatiblity with non-SDK projects. --> |
| 170 | + <Target Name="InitializeSourceControlInformation" /> |
| 171 | +</Project> |
0 commit comments