Skip to content

Commit

Permalink
Merge pull request #297 from AArnott/pr296
Browse files Browse the repository at this point in the history
Reapply "Merge pull request #296 from japj/fix294"
  • Loading branch information
AArnott authored Feb 3, 2019
2 parents 87f68cc + 2fd1ca5 commit 3ebda2a
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/Cake.GitVersioning/Cake.GitVersioning.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</ItemDefinitionGroup>

<ItemGroup>
<PackageReference Include="Cake.Core" Version="0.30.0" />
<PackageReference Include="Cake.Core" Version="0.32.1" />
<PackageReference Include="DotNetMDDocs" Version="0.111.0" Condition=" '$(GenerateMarkdownApiDocs)' == 'true' " />
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="1.6.20-beta-gfea83a8c9e" />
</ItemGroup>
Expand Down
7 changes: 4 additions & 3 deletions src/NerdBank.GitVersioning.Tests/BuildIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ public async Task CloudBuildVariables_SetInCI(IReadOnlyDictionary<string, string
}

// Assert that env variables were also set in context of the build.
Assert.True(buildResult.LoggedEvents.Any(e => string.Equals(e.Message, $"n1=v1", StringComparison.OrdinalIgnoreCase)));
Assert.Contains(buildResult.LoggedEvents, e => string.Equals(e.Message, $"n1=v1", StringComparison.OrdinalIgnoreCase));

versionOptions.CloudBuild.SetVersionVariables = false;
this.WriteVersionFile(versionOptions);
Expand Down Expand Up @@ -814,7 +814,7 @@ public async Task AssemblyInfo_NotProducedWithoutCodeDomProvider()
Assert.Equal(BuildResultCode.Failure, result.BuildResult.OverallResult);
string versionCsFilePath = Path.Combine(this.projectDirectory, result.BuildResult.ProjectStateAfterBuild.GetPropertyValue("VersionSourceFile"));
Assert.False(File.Exists(versionCsFilePath));
Assert.Equal(1, result.LoggedEvents.OfType<BuildErrorEventArgs>().Count());
Assert.Single(result.LoggedEvents.OfType<BuildErrorEventArgs>());
}

/// <summary>
Expand Down Expand Up @@ -862,7 +862,6 @@ public async Task AssemblyInfo_SuppressedImplicitlyByTargetExt()
/// information is set correctly.
/// </summary>
[Fact]
[Trait("TestCategory", "FailsOnAzurePipelines")]
public async Task NativeVersionInfo_CreateNativeResourceDll()
{
this.testProject = this.CreateNativeProjectRootElement(this.projectDirectory, "test.vcxproj");
Expand Down Expand Up @@ -1006,6 +1005,7 @@ private async Task<BuildResults> BuildAsync(string target = Targets.GetBuildVers
{
var eventLogger = new MSBuildLogger { Verbosity = LoggerVerbosity.Minimal };
var loggers = new ILogger[] { eventLogger };
this.testProject.Save(); // persist generated project on disk for analysis
var buildResult = await this.buildManager.BuildAsync(
this.Logger,
this.projectCollection,
Expand Down Expand Up @@ -1037,6 +1037,7 @@ where name.StartsWith(prefix, StringComparison.Ordinal)
{
var targetsFile = ProjectRootElement.Create(XmlReader.Create(stream), this.projectCollection);
targetsFile.FullPath = Path.Combine(this.RepoPath, name.Substring(prefix.Length));
targetsFile.Save(); // persist files on disk
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/NerdBank.GitVersioning.Tests/GitExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public void GetIdAsVersion_Roundtrip_UnstableOffset(int startingOffset, int offs
Assert.Contains(commits[i], matchingCommits);
if (!allowCollisions)
{
Assert.Equal(1, matchingCommits.Count);
Assert.Single(matchingCommits);
}
}
}
Expand Down Expand Up @@ -397,10 +397,13 @@ public void GetIdAsVersion_MigrationFromVersionTxtToJson()
Assert.Equal(2, v2.Build);
}

////[Fact] // Manual, per machine test
[SkippableFact] // Skippable, only run test on specific machine
public void TestBiggerRepo()
{
using (this.Repo = new Repository(@"C:\Users\andrew\git\NerdBank.GitVersioning"))
var testBiggerRepoPath = @"C:\Users\andrew\git\NerdBank.GitVersioning";
Skip.If(!Directory.Exists(testBiggerRepoPath));

using (this.Repo = new Repository(testBiggerRepoPath))
{
foreach (var commit in this.Repo.Head.Commits)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,22 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="7z.NET" Version="1.0.3" />
<PackageReference Include="Newtonsoft.Json.Schema" Version="2.0.11" />
<PackageReference Include="System.Collections.Immutable" Version="1.3.1" />
<PackageReference Include="Microsoft.Build" Version="14.3" Condition=" '$(TargetFramework)' == 'net461' " />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.5.24" />
<PackageReference Include="Xunit.Combinatorial" Version="1.1.12" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="1.1.1" />
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.10" />
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
<PackageReference Include="Microsoft.Build" Version="15.9.20" Condition=" '$(TargetFramework)' == 'net461' " />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.9.0" />
<PackageReference Include="Xunit.Combinatorial" Version="1.2.7" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.10.0" />
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="1.6.20-beta-gfea83a8c9e" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Xunit.SkippableFact" Version="1.3.12" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net461' ">
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="14.3" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.9.20" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.1.548" />
Expand Down
6 changes: 3 additions & 3 deletions src/NerdBank.GitVersioning.Tests/ReleaseManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ public void PrepareRelease_ReleaseBranch(string initialVersion, string releaseOp
}

[Theory]
[InlineData("1.2", "rc", "release/v{version}", "release/v1.2")]
[InlineData("1.2+metadata", "rc", "release/v{version}", "release/v1.2")]
public void PrepeareRelease_ReleaseBranchWithVersionDecrement(string initialVersion, string releaseUnstableTag, string releaseOptionsBranchName, string branchName)
[InlineData("1.2", "rc", "release/v1.2")]
[InlineData("1.2+metadata", "rc", "release/v1.2")]
public void PrepeareRelease_ReleaseBranchWithVersionDecrement(string initialVersion, string releaseUnstableTag, string branchName)
{
// create and configure repository
this.InitializeSourceControl();
Expand Down
2 changes: 1 addition & 1 deletion src/NerdBank.GitVersioning.Tests/VersionOptionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void AssemblyVersionOptions_Equality()
var avo1a = new VersionOptions.AssemblyVersionOptions { };
var avo1b = new VersionOptions.AssemblyVersionOptions { };
Assert.Equal(avo1a, avo1b);
Assert.NotEqual(avo1a, null);
Assert.NotNull(avo1a);

var avo2a = new VersionOptions.AssemblyVersionOptions
{
Expand Down
8 changes: 4 additions & 4 deletions src/NerdBank.GitVersioning.Tests/VersionOracleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ public void SemVerStableNonPublicVersion()
this.InitializeSourceControl();
var oracle = VersionOracle.Create(this.RepoPath);
oracle.PublicRelease = false;
Assert.True(Regex.IsMatch(oracle.SemVer1, @"^2.3.1-[^g]{10}$"));
Assert.True(Regex.IsMatch(oracle.SemVer2, @"^2.3.1-[^g]{10}$"));
Assert.True(Regex.IsMatch(oracle.NuGetPackageVersion, @"^2.3.1-g[a-f0-9]{10}$"));
Assert.True(Regex.IsMatch(oracle.ChocolateyPackageVersion, @"^2.3.1-g[a-f0-9]{10}$"));
Assert.Matches(@"^2.3.1-[^g]{10}$", oracle.SemVer1);
Assert.Matches(@"^2.3.1-[^g]{10}$", oracle.SemVer2);
Assert.Matches(@"^2.3.1-g[a-f0-9]{10}$", oracle.NuGetPackageVersion);
Assert.Matches(@"^2.3.1-g[a-f0-9]{10}$", oracle.ChocolateyPackageVersion);
}

[Fact]
Expand Down
8 changes: 7 additions & 1 deletion src/NerdBank.GitVersioning.Tests/test.vcprj
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- Get the windows 10 ProductVersion from registry and use it-->
<PropertyGroup>
<WindowsTargetPlatformVersion Condition="'$(_WindowsProductVersion)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0@ProductVersion).0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(_WindowsProductVersion)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0@ProductVersion).0</WindowsTargetPlatformVersion>
</PropertyGroup>

<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand All @@ -22,7 +29,6 @@
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{8FD9B6E8-A6E4-42A3-8B5A-E6F7ADC826F5}</ProjectGuid>
<RootNamespace>test</RootNamespace>
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<ResourceOnlyDll>true</ResourceOnlyDll>
<AssemblyCompany>NerdBank</AssemblyCompany>
Expand Down
2 changes: 1 addition & 1 deletion src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageReference Include="DotNetMDDocs" Version="0.111.0" PrivateAssets="all" Condition=" '$(GenerateMarkdownApiDocs)' == 'true' " />
<PackageReference Include="LibGit2Sharp" Version="0.26.0-preview-0070" PrivateAssets="none" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="2.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="System.Diagnostics.Tools" Version="4.3.0" Condition=" '$(TargetFramework)' == 'netcoreapp2.0' " />
<PackageReference Include="Validation" Version="2.4.18" />
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="1.6.20-beta-gfea83a8c9e" />
Expand Down
3 changes: 2 additions & 1 deletion src/NerdBank.GitVersioning/VersionOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Reflection;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
using Validation;

/// <summary>
Expand Down Expand Up @@ -188,7 +189,7 @@ public static JsonSerializerSettings GetJsonSettings(bool includeDefaults = fals
new VersionConverter(),
new SemanticVersionJsonConverter(),
new AssemblyVersionOptionsConverter(includeDefaults),
new StringEnumConverter() { CamelCaseText = true },
new StringEnumConverter() { NamingStrategy = new CamelCaseNamingStrategy() },
},
ContractResolver = new VersionOptionsContractResolver
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@
<ProjectReference Include="..\NerdBank.GitVersioning\NerdBank.GitVersioning.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net461' ">
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="14.3" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.9.20" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.1.548" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.9.20" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/nbgv/nbgv.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NuGet.PackageManagement" Version="4.7.0" NoWarn="NU1701" />
<PackageReference Include="NuGet.Resolver" Version="4.7.0" />
<PackageReference Include="NuGet.PackageManagement" Version="4.9.3" NoWarn="NU1701" />
<PackageReference Include="NuGet.Resolver" Version="4.9.3" />
<PackageReference Include="System.CommandLine" Version="0.1.0-preview2-180503-2" />
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="1.6.20-beta-gfea83a8c9e" PrivateAssets="all" />
<PackageReference Include="System.Diagnostics.Tools" Version="4.3.0" />
<PackageReference Include="Microsoft.Build" Version="15.7.179" />
<PackageReference Include="Microsoft.Build" Version="15.9.20" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 3ebda2a

Please sign in to comment.