Skip to content

Commit e978fe5

Browse files
author
JoshuaMiller
committed
package path fix; reverse assert fix
1 parent 638db0f commit e978fe5

6 files changed

Lines changed: 65 additions & 57 deletions

File tree

Jenkins.NET.Tests/IntegrationTests/ClientTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#endif
99

1010
#if NETCORE
11-
using System.Threading.Tasks;
1211
using Xunit.Abstractions;
1312
#else
1413
using System.IO;

Jenkins.NET.Tests/UnitTests/NetPathTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,35 @@ public class NetPathTests
99
[Trait("Category", "Unit")]
1010
public void JoinsNoSlash()
1111
{
12-
Assert.Equal(NetPath.Combine("root", "path"), "root/path");
12+
Assert.Equal("root/path", NetPath.Combine("root", "path"));
1313
}
1414

1515
[Fact]
1616
[Trait("Category", "Unit")]
1717
public void JoinsLeftSlash()
1818
{
19-
Assert.Equal(NetPath.Combine("root/", "path"), "root/path");
19+
Assert.Equal("root/path", NetPath.Combine("root/", "path"));
2020
}
2121

2222
[Fact]
2323
[Trait("Category", "Unit")]
2424
public void JoinsRightSlash()
2525
{
26-
Assert.Equal(NetPath.Combine("root", "/path"), "root/path");
26+
Assert.Equal("root/path", NetPath.Combine("root", "/path"));
2727
}
2828

2929
[Fact]
3030
[Trait("Category", "Unit")]
3131
public void JoinsBothSlash()
3232
{
33-
Assert.Equal(NetPath.Combine("root/", "/path"), "root/path");
33+
Assert.Equal("root/path", NetPath.Combine("root/", "/path"));
3434
}
3535

3636
[Fact]
3737
[Trait("Category", "Unit")]
3838
public void JoinsMultiple()
3939
{
40-
Assert.Equal(NetPath.Combine("root", "path1", "path2", "path3"), "root/path1/path2/path3");
40+
Assert.Equal("root/path1/path2/path3", NetPath.Combine("root", "path1", "path2", "path3"));
4141
}
4242
}
4343
}

Jenkins.NET.Tests/UnitTests/StringCastTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public void Null_To_String()
1616
[Trait("Category", "Unit")]
1717
public void Null_To_Int()
1818
{
19-
Assert.Equal(((string)null).To<int>(), 0);
19+
Assert.Equal(0, ((string)null).To<int>());
2020
}
2121

2222
[Fact]
@@ -30,21 +30,21 @@ public void Null_To_NullableInt()
3030
[Trait("Category", "Unit")]
3131
public void To_String()
3232
{
33-
Assert.Equal("2".To<int>(), 2);
33+
Assert.Equal(2, "2".To<int>());
3434
}
3535

3636
[Fact]
3737
[Trait("Category", "Unit")]
3838
public void To_Int()
3939
{
40-
Assert.Equal("2".To<int>(), 2);
40+
Assert.Equal(2, "2".To<int>());
4141
}
4242

4343
[Fact]
4444
[Trait("Category", "Unit")]
4545
public void To_Double()
4646
{
47-
Assert.Equal("123.456".To<double>(), 123.456d);
47+
Assert.Equal(123.456d, "123.456".To<double>());
4848
}
4949
}
5050
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"id": "jenkinsnet",
3+
"name": "Jenkins.NET",
4+
"description": "Publishes a pre-compiled and pre-tested NuGet Package for Jenkins.NET.",
5+
"project": "jenkins.net",
6+
"assembly": "Jenkins.Net.Publishing.dll",
7+
"script": "Publish",
8+
"files": [
9+
{
10+
"path": "bin\\Debug\\**",
11+
"destination": "",
12+
"exclude": [
13+
"**\\*.xml",
14+
"**\\*.pdb"
15+
]
16+
},
17+
{
18+
"path": "bin\\Package\\**",
19+
"destination": "PublishPackage"
20+
}
21+
]
22+
}

Jenkins.Net.Publishing/Scripts/Package.cs

Lines changed: 33 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -18,46 +18,55 @@ public class Package : IBuildTask
1818

1919
public async Task RunAsync(CancellationToken token)
2020
{
21-
var packageDir = Path.Combine(Context.ContentDirectory, "PublishPackages");
21+
//var packageDir = Path.Combine(Context.ContentDirectory, "PublishPackages");
2222

2323
await BuildTools.BuildSolution(Context, token);
2424
await TestTools.UnitTest(Context, token);
2525

26-
await CreateNugetPackage(packageDir, token);
26+
await CreateNugetPackage(token);
2727

2828
await CreateProjectPackage(token);
2929
}
3030

31-
private async Task CreateProjectPackage(CancellationToken token)
31+
private async Task CreateNugetPackage(CancellationToken token)
3232
{
33-
var def = new ProjectPackageDefinition {
34-
Id = "jenkinsnet",
35-
Name = "Jenkins.NET",
36-
Description = "Publishes a pre-compiled and pre-tested NuGet Package for Jenkins.NET.",
37-
Project = "jenkins.net",
38-
Assembly = "Jenkins.Net.Publishing.dll",
39-
Script = "Publish",
40-
Files = {
41-
new PackageFileDefinition {
42-
Path = "Jenkins.Net.Publishing\\bin\\Debug\\**",
43-
Destination = "",
44-
},
45-
new PackageFileDefinition {
46-
Path = "PublishPackages\\**",
47-
Destination = "PublishPackages",
48-
}
49-
}
33+
var packageDir = Path.Combine(Context.ContentDirectory, "Jenkins.Net", "bin", "Package");
34+
35+
var args = new[] {
36+
"pack",
37+
"\"Jenkins.Net\\Jenkins.Net.csproj\"",
38+
"--configuration Release",
39+
"--no-build",
40+
$"--output \"{packageDir}\"",
41+
};
42+
43+
var info = new ProcessRunInfo {
44+
Filename = "dotnet",
45+
Arguments = string.Join(" ", args),
46+
WorkingDirectory = Context.ContentDirectory,
5047
};
5148

52-
var version = Context.BuildNumber.ToString();
53-
var output = Path.Combine(Context.ContentDirectory, "PublishPackages", "Jenkins.Net.zip");
49+
var runner = new ProcessRunner(Context);
50+
var result = await runner.RunAsync(info, token);
51+
52+
if (result.ExitCode != 0) throw new ApplicationException($"Build Failed! [{result.ExitCode}]");
53+
}
54+
55+
private async Task CreateProjectPackage(CancellationToken token)
56+
{
57+
var projectPath = Path.Combine(Context.ContentDirectory, "Jenkins.Net.Publishing");
58+
var packageDefFile = Path.Combine(projectPath, "Jenkins.Net.Publishing.json");
59+
var output = Path.Combine(Context.ContentDirectory, "PublishPackage", "Jenkins.Net.zip");
5460

5561
try {
5662
Context.WriteTagLine("Creating project package...", ConsoleColor.White);
5763

64+
var version = Context.BuildNumber.ToString();
65+
var packageDef = ProjectPackageTools.LoadDefinition(packageDefFile);
66+
5867
await ProjectPackageTools.CreatePackage(
59-
definition: def,
60-
rootPath: Context.ContentDirectory,
68+
definition: packageDef,
69+
rootPath: projectPath,
6170
version: version,
6271
outputFilename: output);
6372

@@ -80,27 +89,5 @@ await ProjectPackageTools.CreatePackage(
8089
throw;
8190
}
8291
}
83-
84-
private async Task CreateNugetPackage(string packageDir, CancellationToken token)
85-
{
86-
var args = new[] {
87-
"pack",
88-
"\"Jenkins.Net\\Jenkins.Net.csproj\"",
89-
"--configuration Release",
90-
"--no-build",
91-
$"--output \"{packageDir}\"",
92-
};
93-
94-
var info = new ProcessRunInfo {
95-
Filename = "dotnet",
96-
Arguments = string.Join(" ", args),
97-
WorkingDirectory = Context.ContentDirectory,
98-
};
99-
100-
var runner = new ProcessRunner(Context);
101-
var result = await runner.RunAsync(info, token);
102-
103-
if (result.ExitCode != 0) throw new ApplicationException($"Build Failed! [{result.ExitCode}]");
104-
}
10592
}
10693
}

Jenkins.Net.Publishing/Scripts/Publish.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public async Task RunAsync(CancellationToken token)
2323
};
2424
nugetCore.Initialize();
2525

26-
var packageDir = Path.Combine(Context.ContentDirectory, "PublishPackages");
26+
var packageDir = Path.Combine(Context.ContentDirectory, "PublishPackage");
2727

2828
var packageFilename = Directory
2929
.GetFiles(packageDir, "jenkinsnet.*.nupkg")

0 commit comments

Comments
 (0)