Skip to content

Commit 3ebda2a

Browse files
authored
Merge pull request #297 from AArnott/pr296
Reapply "Merge pull request #296 from japj/fix294"
2 parents 87f68cc + 2fd1ca5 commit 3ebda2a

File tree

12 files changed

+47
-32
lines changed

12 files changed

+47
-32
lines changed

src/Cake.GitVersioning/Cake.GitVersioning.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
</ItemDefinitionGroup>
3636

3737
<ItemGroup>
38-
<PackageReference Include="Cake.Core" Version="0.30.0" />
38+
<PackageReference Include="Cake.Core" Version="0.32.1" />
3939
<PackageReference Include="DotNetMDDocs" Version="0.111.0" Condition=" '$(GenerateMarkdownApiDocs)' == 'true' " />
4040
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="1.6.20-beta-gfea83a8c9e" />
4141
</ItemGroup>

src/NerdBank.GitVersioning.Tests/BuildIntegrationTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ public async Task CloudBuildVariables_SetInCI(IReadOnlyDictionary<string, string
549549
}
550550

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

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

820820
/// <summary>
@@ -862,7 +862,6 @@ public async Task AssemblyInfo_SuppressedImplicitlyByTargetExt()
862862
/// information is set correctly.
863863
/// </summary>
864864
[Fact]
865-
[Trait("TestCategory", "FailsOnAzurePipelines")]
866865
public async Task NativeVersionInfo_CreateNativeResourceDll()
867866
{
868867
this.testProject = this.CreateNativeProjectRootElement(this.projectDirectory, "test.vcxproj");
@@ -1006,6 +1005,7 @@ private async Task<BuildResults> BuildAsync(string target = Targets.GetBuildVers
10061005
{
10071006
var eventLogger = new MSBuildLogger { Verbosity = LoggerVerbosity.Minimal };
10081007
var loggers = new ILogger[] { eventLogger };
1008+
this.testProject.Save(); // persist generated project on disk for analysis
10091009
var buildResult = await this.buildManager.BuildAsync(
10101010
this.Logger,
10111011
this.projectCollection,
@@ -1037,6 +1037,7 @@ where name.StartsWith(prefix, StringComparison.Ordinal)
10371037
{
10381038
var targetsFile = ProjectRootElement.Create(XmlReader.Create(stream), this.projectCollection);
10391039
targetsFile.FullPath = Path.Combine(this.RepoPath, name.Substring(prefix.Length));
1040+
targetsFile.Save(); // persist files on disk
10401041
}
10411042
}
10421043
}

src/NerdBank.GitVersioning.Tests/GitExtensionsTests.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ public void GetIdAsVersion_Roundtrip_UnstableOffset(int startingOffset, int offs
325325
Assert.Contains(commits[i], matchingCommits);
326326
if (!allowCollisions)
327327
{
328-
Assert.Equal(1, matchingCommits.Count);
328+
Assert.Single(matchingCommits);
329329
}
330330
}
331331
}
@@ -397,10 +397,13 @@ public void GetIdAsVersion_MigrationFromVersionTxtToJson()
397397
Assert.Equal(2, v2.Build);
398398
}
399399

400-
////[Fact] // Manual, per machine test
400+
[SkippableFact] // Skippable, only run test on specific machine
401401
public void TestBiggerRepo()
402402
{
403-
using (this.Repo = new Repository(@"C:\Users\andrew\git\NerdBank.GitVersioning"))
403+
var testBiggerRepoPath = @"C:\Users\andrew\git\NerdBank.GitVersioning";
404+
Skip.If(!Directory.Exists(testBiggerRepoPath));
405+
406+
using (this.Repo = new Repository(testBiggerRepoPath))
404407
{
405408
foreach (var commit in this.Repo.Head.Commits)
406409
{

src/NerdBank.GitVersioning.Tests/NerdBank.GitVersioning.Tests.csproj

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,22 @@
2929
</ItemGroup>
3030
<ItemGroup>
3131
<PackageReference Include="7z.NET" Version="1.0.3" />
32-
<PackageReference Include="Newtonsoft.Json.Schema" Version="2.0.11" />
33-
<PackageReference Include="System.Collections.Immutable" Version="1.3.1" />
34-
<PackageReference Include="Microsoft.Build" Version="14.3" Condition=" '$(TargetFramework)' == 'net461' " />
35-
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.5.24" />
36-
<PackageReference Include="Xunit.Combinatorial" Version="1.1.12" />
37-
<PackageReference Include="xunit" Version="2.2.0" />
38-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="1.1.1" />
32+
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.10" />
33+
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
34+
<PackageReference Include="Microsoft.Build" Version="15.9.20" Condition=" '$(TargetFramework)' == 'net461' " />
35+
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.9.0" />
36+
<PackageReference Include="Xunit.Combinatorial" Version="1.2.7" />
37+
<PackageReference Include="xunit" Version="2.4.1" />
38+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.10.0" />
3939
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="1.6.20-beta-gfea83a8c9e" />
40-
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
40+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
41+
<PrivateAssets>all</PrivateAssets>
42+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
43+
</PackageReference>
44+
<PackageReference Include="Xunit.SkippableFact" Version="1.3.12" />
4145
</ItemGroup>
4246
<ItemGroup Condition="'$(TargetFramework)' == 'net461' ">
43-
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="14.3" />
47+
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.9.20" />
4448
</ItemGroup>
4549
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
4650
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.1.548" />

src/NerdBank.GitVersioning.Tests/ReleaseManagerTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ public void PrepareRelease_ReleaseBranch(string initialVersion, string releaseOp
176176
}
177177

178178
[Theory]
179-
[InlineData("1.2", "rc", "release/v{version}", "release/v1.2")]
180-
[InlineData("1.2+metadata", "rc", "release/v{version}", "release/v1.2")]
181-
public void PrepeareRelease_ReleaseBranchWithVersionDecrement(string initialVersion, string releaseUnstableTag, string releaseOptionsBranchName, string branchName)
179+
[InlineData("1.2", "rc", "release/v1.2")]
180+
[InlineData("1.2+metadata", "rc", "release/v1.2")]
181+
public void PrepeareRelease_ReleaseBranchWithVersionDecrement(string initialVersion, string releaseUnstableTag, string branchName)
182182
{
183183
// create and configure repository
184184
this.InitializeSourceControl();

src/NerdBank.GitVersioning.Tests/VersionOptionsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void AssemblyVersionOptions_Equality()
6363
var avo1a = new VersionOptions.AssemblyVersionOptions { };
6464
var avo1b = new VersionOptions.AssemblyVersionOptions { };
6565
Assert.Equal(avo1a, avo1b);
66-
Assert.NotEqual(avo1a, null);
66+
Assert.NotNull(avo1a);
6767

6868
var avo2a = new VersionOptions.AssemblyVersionOptions
6969
{

src/NerdBank.GitVersioning.Tests/VersionOracleTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ public void SemVerStableNonPublicVersion()
174174
this.InitializeSourceControl();
175175
var oracle = VersionOracle.Create(this.RepoPath);
176176
oracle.PublicRelease = false;
177-
Assert.True(Regex.IsMatch(oracle.SemVer1, @"^2.3.1-[^g]{10}$"));
178-
Assert.True(Regex.IsMatch(oracle.SemVer2, @"^2.3.1-[^g]{10}$"));
179-
Assert.True(Regex.IsMatch(oracle.NuGetPackageVersion, @"^2.3.1-g[a-f0-9]{10}$"));
180-
Assert.True(Regex.IsMatch(oracle.ChocolateyPackageVersion, @"^2.3.1-g[a-f0-9]{10}$"));
177+
Assert.Matches(@"^2.3.1-[^g]{10}$", oracle.SemVer1);
178+
Assert.Matches(@"^2.3.1-[^g]{10}$", oracle.SemVer2);
179+
Assert.Matches(@"^2.3.1-g[a-f0-9]{10}$", oracle.NuGetPackageVersion);
180+
Assert.Matches(@"^2.3.1-g[a-f0-9]{10}$", oracle.ChocolateyPackageVersion);
181181
}
182182

183183
[Fact]

src/NerdBank.GitVersioning.Tests/test.vcprj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
4+
<!-- Get the windows 10 ProductVersion from registry and use it-->
5+
<PropertyGroup>
6+
<WindowsTargetPlatformVersion Condition="'$(_WindowsProductVersion)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0@ProductVersion).0</WindowsTargetPlatformVersion>
7+
<WindowsTargetPlatformVersion Condition="'$(_WindowsProductVersion)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0@ProductVersion).0</WindowsTargetPlatformVersion>
8+
</PropertyGroup>
9+
310
<ItemGroup Label="ProjectConfigurations">
411
<ProjectConfiguration Include="Debug|Win32">
512
<Configuration>Debug</Configuration>
@@ -22,7 +29,6 @@
2229
<VCProjectVersion>15.0</VCProjectVersion>
2330
<ProjectGuid>{8FD9B6E8-A6E4-42A3-8B5A-E6F7ADC826F5}</ProjectGuid>
2431
<RootNamespace>test</RootNamespace>
25-
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
2632
<ConfigurationType>DynamicLibrary</ConfigurationType>
2733
<ResourceOnlyDll>true</ResourceOnlyDll>
2834
<AssemblyCompany>NerdBank</AssemblyCompany>

src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<PackageReference Include="DotNetMDDocs" Version="0.111.0" PrivateAssets="all" Condition=" '$(GenerateMarkdownApiDocs)' == 'true' " />
1111
<PackageReference Include="LibGit2Sharp" Version="0.26.0-preview-0070" PrivateAssets="none" />
1212
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="2.1.0" />
13-
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
13+
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
1414
<PackageReference Include="System.Diagnostics.Tools" Version="4.3.0" Condition=" '$(TargetFramework)' == 'netcoreapp2.0' " />
1515
<PackageReference Include="Validation" Version="2.4.18" />
1616
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="1.6.20-beta-gfea83a8c9e" />

src/NerdBank.GitVersioning/VersionOptions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Reflection;
88
using Newtonsoft.Json;
99
using Newtonsoft.Json.Converters;
10+
using Newtonsoft.Json.Serialization;
1011
using Validation;
1112

1213
/// <summary>
@@ -188,7 +189,7 @@ public static JsonSerializerSettings GetJsonSettings(bool includeDefaults = fals
188189
new VersionConverter(),
189190
new SemanticVersionJsonConverter(),
190191
new AssemblyVersionOptionsConverter(includeDefaults),
191-
new StringEnumConverter() { CamelCaseText = true },
192+
new StringEnumConverter() { NamingStrategy = new CamelCaseNamingStrategy() },
192193
},
193194
ContractResolver = new VersionOptionsContractResolver
194195
{

0 commit comments

Comments
 (0)