Merge all hard-coded versions and version suffixes to be defined in a single spot.

This commit is contained in:
Eric Erhardt 2017-01-10 17:31:43 -06:00
parent 36d03ce4ce
commit c481ad9cdc
22 changed files with 40 additions and 120 deletions

View file

@ -1,4 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<VersionPrefix>1.0.0-rc</VersionPrefix>
<TargetFramework>netcoreapp1.0</TargetFramework>
@ -8,7 +10,7 @@
</PropertyGroup>
<PropertyGroup>
<SdkNugetVersion Condition=" '$(SdkNugetVersion)' == ''">1.0.0-preview5-*</SdkNugetVersion>
<SdkNugetVersion Condition=" '$(SdkNugetVersion)' == ''">$(CliVersionPrefix)-*</SdkNugetVersion>
</PropertyGroup>
<ItemGroup>

View file

@ -1,9 +0,0 @@
# This is a file containing environment variables specific to this branch
# Any line that is not blank and does not start with '#' is interpreted as a variable to set
# Each line is expected to be in the format "[Name]=[Value]".
MAJOR_VERSION=2
MINOR_VERSION=0
PATCH_VERSION=0
RELEASE_SUFFIX=alpha
CHANNEL=master
BRANCH_NAME=master

View file

@ -49,19 +49,17 @@
<Output TaskParameter="CommitHash" PropertyName="CommitHash" />
</GetCommitHash>
<GenerateBuildVersionInfo RepoRoot="$(RepoRoot)">
<Output TaskParameter="VersionMajor" PropertyName="VersionMajor" />
<Output TaskParameter="VersionMinor" PropertyName="VersionMinor" />
<Output TaskParameter="VersionPatch" PropertyName="VersionPatch" />
<GenerateBuildVersionInfo RepoRoot="$(RepoRoot)"
VersionMajor="$(VersionMajor)"
VersionMinor="$(VersionMinor)"
VersionPatch="$(VersionPatch)"
ReleaseSuffix="$(ReleaseSuffix)">
<Output TaskParameter="CommitCount" PropertyName="CommitCount" />
<Output TaskParameter="ReleaseSuffix" PropertyName="ReleaseSuffix" />
<Output TaskParameter="VersionSuffix" PropertyName="VersionSuffix" />
<Output TaskParameter="SimpleVersion" PropertyName="SimpleVersion" />
<Output TaskParameter="NugetVersion" PropertyName="NugetVersion" />
<Output TaskParameter="MsiVersion" PropertyName="MsiVersion" />
<Output TaskParameter="VersionBadgeMoniker" PropertyName="VersionBadgeMoniker" />
<Output TaskParameter="Channel" PropertyName="Channel" />
<Output TaskParameter="BranchName" PropertyName="BranchName" />
</GenerateBuildVersionInfo>
<GenerateNuGetPackagesArchiveVersion RepoRoot="$(RepoRoot)">
@ -72,9 +70,7 @@
<VersionBadge>$(BaseOutputDirectory)/$(VersionBadgeMoniker)_$(Configuration)_version_badge.svg</VersionBadge>
<SdkVersion>$(NugetVersion)</SdkVersion>
<SdkNugetVersion>$(VersionMajor).$(VersionMinor).$(VersionPatch)-preview5-$(CommitCount)</SdkNugetVersion>
<ProjectModelNugetVersion>$(VersionMajor).$(VersionMinor).$(VersionPatch)-rc4-$(CommitCount)</ProjectModelNugetVersion>
<DependencyModelAndInternalAbstractionsNugetVersion>$(VersionMajor).$(VersionMinor).1-beta-$(CommitCount)</DependencyModelAndInternalAbstractionsNugetVersion>
<SdkNugetVersion>$(SdkVersion)</SdkNugetVersion>
<ArchiveExtension Condition=" '$(OSName)' == 'win' ">.zip</ArchiveExtension>
<ArchiveExtension Condition=" '$(OSName)' != 'win' ">.tar.gz</ArchiveExtension>

View file

@ -26,7 +26,7 @@
Output="$(NupkgOutputDirectory)"
ProjectPath="%(ProjectsToPack.Identity)/%(ProjectsToPack.ProjectName).csproj"
ToolPath="$(Stage0Directory)"
VersionSuffix="preview5-$(NupkgVersionSuffix)"
VersionSuffix="$(ReleaseSuffix)-$(NupkgVersionSuffix)"
Configuration="$(Configuration)" />
</Target>

View file

@ -76,7 +76,7 @@
<IsTool>True</IsTool>
<IsApplicable>True</IsApplicable>
<VersionPrefix>$(CliVersionPrefix)-</VersionPrefix>
<VersionSuffix>rc3-$(TestPackageBuildVersionSuffix)</VersionSuffix>
<VersionSuffix>$(ReleaseSuffix)-$(TestPackageBuildVersionSuffix)</VersionSuffix>
<Clean>False</Clean>
<Frameworks>netstandard1.5</Frameworks>
</BaseTestPackageProject>

View file

@ -12,21 +12,21 @@ namespace Microsoft.DotNet.Cli.Build
[Required]
public string RepoRoot { get; set; }
[Output]
[Required]
public int VersionMajor { get; set; }
[Output]
[Required]
public int VersionMinor { get; set; }
[Output]
[Required]
public int VersionPatch { get; set; }
[Required]
public string ReleaseSuffix { get; set; }
[Output]
public string CommitCount { get; set; }
[Output]
public string ReleaseSuffix { get; set; }
[Output]
public string VersionSuffix { get; set; }
@ -42,41 +42,27 @@ namespace Microsoft.DotNet.Cli.Build
[Output]
public string VersionBadgeMoniker { get; set; }
[Output]
public string Channel { get; set; }
[Output]
public string BranchName { get; set; }
private int _commitCount;
public override bool Execute()
{
base.Execute();
var branchInfo = new BranchInfo(RepoRoot);
var buildVersion = new BuildVersion()
{
Major = int.Parse(branchInfo.Entries["MAJOR_VERSION"]),
Minor = int.Parse(branchInfo.Entries["MINOR_VERSION"]),
Patch = int.Parse(branchInfo.Entries["PATCH_VERSION"]),
ReleaseSuffix = branchInfo.Entries["RELEASE_SUFFIX"],
Major = VersionMajor,
Minor = VersionMinor,
Patch = VersionPatch,
ReleaseSuffix = ReleaseSuffix,
CommitCount = _commitCount
};
VersionMajor = buildVersion.Major;
VersionMinor = buildVersion.Minor;
VersionPatch = buildVersion.Patch;
CommitCount = buildVersion.CommitCountString;
ReleaseSuffix = buildVersion.ReleaseSuffix;
VersionSuffix = buildVersion.VersionSuffix;
SimpleVersion = buildVersion.SimpleVersion;
NugetVersion = buildVersion.NuGetVersion;
MsiVersion = buildVersion.GenerateMsiVersion();
VersionBadgeMoniker = Monikers.GetBadgeMoniker();
Channel = branchInfo.Entries["CHANNEL"];
BranchName= branchInfo.Entries["BRANCH_NAME"];
return true;
}

View file

@ -1,45 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using Microsoft.DotNet.Cli.Build.Framework;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
namespace Microsoft.DotNet.Cli.Build
{
public class BranchInfo
{
private static readonly string s_branchInfoFileName = "branchinfo.txt";
private string _repoRoot;
private string _branchInfoFile;
public IDictionary<string, string> Entries { get; set; }
public BranchInfo(string repoRoot)
{
_repoRoot = repoRoot;
_branchInfoFile = Path.Combine(_repoRoot, s_branchInfoFileName);
Entries = ReadBranchInfo(_branchInfoFile);
}
private IDictionary<string, string> ReadBranchInfo(string path)
{
var lines = File.ReadAllLines(path);
var dict = new Dictionary<string, string>();
foreach (var line in lines)
{
if (!line.Trim().StartsWith("#") && !string.IsNullOrWhiteSpace(line))
{
var splat = line.Split(new[] { '=' }, 2);
dict[splat[0]] = splat[1];
}
}
return dict;
}
}
}

View file

@ -7,7 +7,5 @@ namespace Microsoft.DotNet.Cli.Build
public string SimpleVersion => $"{Major}.{Minor}.{Patch}.{CommitCountString}";
public string VersionSuffix => $"{ReleaseSuffix}-{CommitCountString}";
public string NuGetVersion => $"{Major}.{Minor}.{Patch}-{VersionSuffix}";
public string NetCoreAppVersion => $"{Major}.{Minor}.{Patch}-rc3-{CommitCountString}";
public string ProductionVersion => $"{Major}.{Minor}.{Patch}";
}
}

View file

@ -12,5 +12,13 @@
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
<VersionMajor>2</VersionMajor>
<VersionMinor>0</VersionMinor>
<VersionPatch>0</VersionPatch>
<ReleaseSuffix>alpha</ReleaseSuffix>
<Channel>master</Channel>
<BranchName>master</BranchName>
<CliVersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)-$(ReleaseSuffix)</CliVersionPrefix>
</PropertyGroup>
</Project>

View file

@ -40,14 +40,6 @@ else
$env:DOTNET_BUILD_SKIP_PACKAGING=0
}
# Load Branch Info
cat "$RepoRoot\branchinfo.txt" | ForEach-Object {
if(!$_.StartsWith("#") -and ![String]::IsNullOrWhiteSpace($_)) {
$splat = $_.Split([char[]]@("="), 2)
Set-Content "env:\$($splat[0])" -Value $splat[1]
}
}
# Use a repo-local install directory (but not the artifacts directory because that gets cleaned a lot
if (!$env:DOTNET_INSTALL_DIR_PJ)
{

View file

@ -120,14 +120,6 @@ done
temp="${args[@]}"
args=($temp)
# Load Branch Info
while read line; do
if [[ $line != \#* ]]; then
IFS='=' read -ra splat <<< "$line"
export ${splat[0]}="${splat[1]}"
fi
done < "$REPOROOT/branchinfo.txt"
# Use a repo-local install directory (but not the artifacts directory because that gets cleaned a lot
[ -z "$DOTNET_INSTALL_DIR_PJ" ] && export DOTNET_INSTALL_DIR_PJ=$REPOROOT/.dotnet_stage0PJ/$ARCHITECTURE
[ -d "$DOTNET_INSTALL_DIR_PJ" ] || mkdir -p $DOTNET_INSTALL_DIR_PJ

View file

@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Archive and compression types.</Description>
<VersionPrefix>1.0.0-preview5</VersionPrefix>
<VersionPrefix>$(CliVersionPrefix)</VersionPrefix>
<TargetFramework>netstandard1.3</TargetFramework>
<AssemblyOriginatorKeyFile>../../tools/Key.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>

View file

@ -3,7 +3,7 @@
<PropertyGroup>
<Description>SLN file reader/writer</Description>
<VersionPrefix>1.0.0-preview5</VersionPrefix>
<VersionPrefix>$(CliVersionPrefix)</VersionPrefix>
<TargetFramework>netstandard1.6</TargetFramework>
<DebugType>portable</DebugType>
<AssemblyName>Microsoft.DotNet.Cli.Sln.Internal</AssemblyName>

View file

@ -2,7 +2,7 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<VersionPrefix>1.0.0-preview5</VersionPrefix>
<VersionPrefix>$(CliVersionPrefix)</VersionPrefix>
<TargetFrameworks>netstandard1.5;net46</TargetFrameworks>
<WarningsAsErrors>true</WarningsAsErrors>
<AssemblyOriginatorKeyFile>../../tools/Key.snk</AssemblyOriginatorKeyFile>

View file

@ -2,7 +2,7 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<VersionPrefix>1.0.0-rc3</VersionPrefix>
<VersionPrefix>$(CliVersionPrefix)</VersionPrefix>
<TargetFramework>netstandard1.5</TargetFramework>
<WarningsAsErrors>true</WarningsAsErrors>
<AssemblyOriginatorKeyFile>../../tools/Key.snk</AssemblyOriginatorKeyFile>

View file

@ -2,7 +2,7 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<VersionPrefix>1.0.0-preview5</VersionPrefix>
<VersionPrefix>$(CliVersionPrefix)</VersionPrefix>
<TargetFramework>netcoreapp1.0</TargetFramework>
<WarningsAsErrors>true</WarningsAsErrors>
<AssemblyOriginatorKeyFile>../../tools/Key.snk</AssemblyOriginatorKeyFile>

View file

@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Microsoft.DotNet.TestFramework Class Library</Description>
<VersionPrefix>1.0.0-preview5</VersionPrefix>
<VersionPrefix>$(CliVersionPrefix)</VersionPrefix>
<TargetFrameworks>netstandard1.5;net46</TargetFrameworks>
<AssemblyOriginatorKeyFile>../../tools/Key.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>

View file

@ -2,7 +2,7 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<VersionPrefix>1.0.0-preview5</VersionPrefix>
<VersionPrefix>$(CliVersionPrefix)</VersionPrefix>
<TargetFramework>netcoreapp1.0</TargetFramework>
<AssemblyName>dotnet</AssemblyName>
<OutputType>Exe</OutputType>

View file

@ -2,7 +2,7 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<VersionPrefix>1.0.0-preview5</VersionPrefix>
<VersionPrefix>$(CliVersionPrefix)</VersionPrefix>
<TargetFramework>netcoreapp1.0</TargetFramework>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);dotnet5.4</PackageTargetFallback>

View file

@ -2,7 +2,7 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<VersionPrefix>1.0.0-preview5</VersionPrefix>
<VersionPrefix>$(CliVersionPrefix)</VersionPrefix>
<TargetFramework>netcoreapp1.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View file

@ -2,7 +2,7 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<VersionPrefix>1.0.0-preview5</VersionPrefix>
<VersionPrefix>$(CliVersionPrefix)</VersionPrefix>
<TargetFramework>netcoreapp1.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View file

@ -3,7 +3,7 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.tasks" />
<PropertyGroup>
<VersionPrefix>1.0.0-preview5</VersionPrefix>
<VersionPrefix>$(CliVersionPrefix)</VersionPrefix>
<TargetFramework>netcoreapp1.0</TargetFramework>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
</PropertyGroup>