1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <Project xmlns =" http://schemas.microsoft.com/developer/msbuild/2003" >
3+
4+ <PropertyGroup >
5+ <GitSkipCache >true</GitSkipCache >
6+ <GitIgnoreTagVersion >true</GitIgnoreTagVersion >
7+
8+ <Company >Microsoft</Company >
9+ <Product >Microsoft NuGet Packaging</Product >
10+ <Copyright >Copyright © 2016</Copyright >
11+ </PropertyGroup >
12+
13+ <ItemGroup >
14+ <PackageReference Include =" MSBuilder.CI" Version =" 0.1.2" PrivateAssets =" all" />
15+ <PackageReference Include =" GitInfo" Version =" 2.0.7" PrivateAssets =" all" />
16+ </ItemGroup >
17+
18+ <Target Name =" Version" DependsOnTargets =" SetVersion" >
19+ <Message Importance =" high" Text =" PackageVersion=$(PackageVersion)
20+ AssemblyVersion=$(AssemblyVersion)" />
21+ </Target >
22+
23+ <Target Name =" _SetLocalCommits" BeforeTargets =" _GitPopulateVersionInfo" Condition =" '$(CI)' != 'true'" >
24+ <PropertyGroup >
25+ <!-- Local builds should always be commit count +1, since we'll be always working on the next version to be published. -->
26+ <GitCommits >$([MSBuild]::Add('$(GitCommits)', '1'))</GitCommits >
27+ </PropertyGroup >
28+ </Target >
29+
30+ <!-- '$(ExcludeRestorePackageImports)' == 'true' when invoking /t:Restore -->
31+ <Target Name =" SetVersion" BeforeTargets =" GetAssemblyVersion;GetPackageVersion" DependsOnTargets =" GitVersion" Condition =" '$(ExcludeRestorePackageImports)' != 'true'" >
32+ <PropertyGroup >
33+ <!-- PR builds are *always* prerelease -->
34+ <!-- TFS case: BUILD_REASON=PullRequest and BUILD_SOURCEBRANCH=refs/pull/#/merge -->
35+ <GitSemVerDashLabel Condition =" '$(TF_BUILD)' == 'true' and '$(BUILD_REASON)' == 'PullRequest'" >$(GitSemVerDashLabel)-pr$(BUILD_SOURCEBRANCH.Substring(10).TrimEnd('/merge'))</GitSemVerDashLabel >
36+ <GitSemVerDashLabel Condition =" '$(APPVEYOR_PULL_REQUEST_NUMBER)' != ''" >$(GitSemVerDashLabel)-pr$(APPVEYOR_PULL_REQUEST_NUMBER)</GitSemVerDashLabel >
37+
38+ <!-- NOTE: build metadata does not affect version matching, so even if you work from a different branch+commit that gets
39+ rebased+merged later on, the version # might still be the same (provided there weren't additional commits in master
40+ before the rebase+merge.
41+ -->
42+ <_IndexOfBranchSlash >$(GitBranch.LastIndexOf('/'))</_IndexOfBranchSlash >
43+ <_IndexOfBranchSubstring >$([MSBuild]::Add('$(_IndexOfBranchSlash)', '1'))</_IndexOfBranchSubstring >
44+ <_GitBranch Condition =" '$(_IndexOfBranchSlash)' != '0'" >$(GitBranch.Substring($(_IndexOfBranchSubstring)))</_GitBranch >
45+ <_GitBranch Condition =" '$(_IndexOfBranchSlash)' == '0'" >$(GitBranch)</_GitBranch >
46+
47+ <!-- We'll use GitFlow and ship publicly from a versioned branch, meaning we don't need branch metadata in those cases -->
48+ <GitSemVerDashLabel Condition =" '$(GitSemVerDashLabel)' == '' and $(_GitBranch.StartsWith('v')) == 'false'" >-$(_GitBranch)</GitSemVerDashLabel >
49+ <SemVerMetadata Condition =" '$(GitSemVerDashLabel)' != '-$(_GitBranch)' and $(_GitBranch.StartsWith('v')) == 'false' and '$(_GitBranch)' != 'undefined'" >$(_GitBranch).</SemVerMetadata >
50+ <SemVerMetadata >$(SemVerMetadata)sha.$(GitCommit)</SemVerMetadata >
51+
52+ <!-- If there is a pre-release label, fix the major.minor.build and increment the release label digit instead. -->
53+ <PackageVersion Condition =" '$(GitSemVerDashLabel)' != ''" >$(GitBaseVersionMajor).$(GitBaseVersionMinor).$(GitBaseVersionPatch)$(GitSemVerDashLabel).$(GitCommits)+$(SemVerMetadata)</PackageVersion >
54+ <!-- If shipping stable, semver the package version -->
55+ <PackageVersion Condition =" '$(GitSemVerDashLabel)' == ''" >$(GitSemVerMajor).$(GitSemVerMinor).$(GitSemVerPatch)+$(SemVerMetadata)</PackageVersion >
56+ <AssemblyVersion >$(GitBaseVersionMajor).$(GitBaseVersionMinor).$(GitBaseVersionPatch)</AssemblyVersion >
57+ <FileVersion >$(GitSemVerMajor).$(GitSemVerMinor).$(GitSemVerPatch)</FileVersion >
58+ <InformationalVersion >$(PackageVersion)</InformationalVersion >
59+ </PropertyGroup >
60+ </Target >
61+
62+ <Target Name =" LocalPublish" Condition =" '$(CI)' != 'true'" AfterTargets =" Pack" >
63+ <Exec Command =' rd "$(NuGetPackageRoot)$(PackageId.ToLowerInvariant())" /q /s' Condition =" Exists('$(NuGetPackageRoot)$(PackageId.ToLowerInvariant())')" />
64+
65+ <ItemGroup >
66+ <ToDelete Include =" $(TEMP)\packages\$(PackageId)*.nupkg" />
67+ </ItemGroup >
68+ <Delete Files =" @(ToDelete)" />
69+
70+ <MakeDir Directories =" $(TEMP)\packages" Condition =" !Exists('$(TEMP)\packages')" />
71+ <Copy SourceFiles =" $(PackageTargetPath)" DestinationFolder =" $(TEMP)\packages" />
72+ </Target >
73+
74+ </Project >
0 commit comments