Skip to content

Commit 7d863fd

Browse files
author
JoshuaMiller
committed
update packages; nunit package
1 parent 4e3aefe commit 7d863fd

5 files changed

Lines changed: 122 additions & 76 deletions

File tree

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
using Photon.Framework.Agent;
22
using Photon.Framework.Tasks;
3-
using Photon.MSBuild;
3+
using Photon.MSBuildPlugin;
44
using System.Threading;
55
using System.Threading.Tasks;
66

77
namespace Jenkins.NET.Publishing
88
{
99
public class Build_Linux : IBuildTask
1010
{
11+
private MSBuildCommand msbuild;
12+
1113
public IAgentBuildContext Context {get; set;}
1214

1315

1416
public async Task RunAsync(CancellationToken token)
1517
{
18+
msbuild = new MSBuildCommand(Context) {
19+
Exe = "msbuild",
20+
WorkingDirectory = Context.ContentDirectory,
21+
};
22+
1623
await BuildSolution(token);
1724
}
1825

1926
private async Task BuildSolution(CancellationToken token)
2027
{
21-
var msbuild = new MSBuildCommand(Context) {
22-
Exe = "msbuild",
23-
WorkingDirectory = Context.ContentDirectory,
24-
};
25-
26-
var buildArgs = new MSBuildArguments {
28+
await msbuild.RunAsync(new MSBuildArguments {
2729
ProjectFile = "Jenkins.NET.sln",
2830
Properties = {
2931
["Configuration"] = "Release",
3032
["Platform"] = "Any CPU",
3133
},
32-
Verbosity = MSBuildVerbosityLevel.Minimal,
34+
Verbosity = MSBuildVerbosityLevels.Minimal,
3335
MaxCpuCount = 0,
34-
};
35-
36-
await msbuild.RunAsync(buildArgs, token);
36+
}, token);
3737
}
3838
}
3939
}
Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,57 @@
11
using Photon.Framework.Agent;
2-
using Photon.Framework.Process;
32
using Photon.Framework.Tasks;
4-
using Photon.MSBuild;
3+
using Photon.MSBuildPlugin;
4+
using Photon.NUnitPlugin;
55
using System.Threading;
66
using System.Threading.Tasks;
77

88
namespace Jenkins.NET.Publishing
99
{
1010
public class Build_Windows : IBuildTask
1111
{
12+
private MSBuildCommand msbuild;
13+
private NUnit3Command nunit;
14+
1215
public IAgentBuildContext Context {get; set;}
1316

1417

1518
public async Task RunAsync(CancellationToken token)
1619
{
20+
msbuild = new MSBuildCommand(Context) {
21+
Exe = Context.AgentVariables["global"]["msbuild_exe"],
22+
WorkingDirectory = Context.ContentDirectory,
23+
};
24+
25+
nunit = new NUnit3Command(Context) {
26+
Exe = Context.AgentVariables["global"]["nunit_exe"],
27+
WorkingDirectory = Context.ContentDirectory,
28+
};
29+
1730
await BuildSolution(token);
1831
await UnitTest(token);
1932
}
2033

2134
private async Task BuildSolution(CancellationToken token)
2235
{
23-
var msbuild = new MSBuildCommand(Context) {
24-
Exe = Context.AgentVariables["global"]["msbuild_exe"],
25-
WorkingDirectory = Context.ContentDirectory,
26-
};
27-
28-
var buildArgs = new MSBuildArguments {
36+
await msbuild.RunAsync(new MSBuildArguments {
2937
ProjectFile = "Jenkins.NET.sln",
3038
Properties = {
3139
["Configuration"] = "Release",
3240
["Platform"] = "Any CPU",
3341
},
34-
Verbosity = MSBuildVerbosityLevel.Minimal,
42+
Verbosity = MSBuildVerbosityLevels.Minimal,
3543
MaxCpuCount = 0,
36-
};
37-
38-
await msbuild.RunAsync(buildArgs, token);
44+
}, token);
3945
}
4046

4147
private async Task UnitTest(CancellationToken token)
4248
{
43-
var info = new ProcessRunInfo {
44-
Filename = Context.AgentVariables["global"]["nunit_exe"],
45-
Arguments = "\"Jenkins.NET.Tests\\bin\\Release\\Jenkins.NET.Tests.dll\" --where=\"cat == 'unit'\"",
46-
WorkingDirectory = Context.ContentDirectory,
47-
};
48-
49-
var runner = new ProcessRunner(Context);
50-
await runner.RunAsync(info, token);
49+
await nunit.RunAsync(new NUnit3Arguments {
50+
InputFiles = {
51+
"Jenkins.NET.Tests\\bin\\Release\\Jenkins.NET.Tests.dll",
52+
},
53+
Where = "cat == 'unit'",
54+
}, token);
5155
}
5256
}
5357
}

Jenkins.NET.Publishing/Jenkins.NET.Publishing.csproj

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,18 @@
3636
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
3737
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
3838
</Reference>
39+
<Reference Include="NuGet.Client, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
40+
<HintPath>..\packages\NuGet.Client.4.2.0\lib\net45\NuGet.Client.dll</HintPath>
41+
</Reference>
3942
<Reference Include="NuGet.Common, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
4043
<HintPath>..\packages\NuGet.Common.4.2.0\lib\net45\NuGet.Common.dll</HintPath>
4144
</Reference>
4245
<Reference Include="NuGet.Configuration, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
4346
<HintPath>..\packages\NuGet.Configuration.4.2.0\lib\net45\NuGet.Configuration.dll</HintPath>
4447
</Reference>
48+
<Reference Include="NuGet.ContentModel, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
49+
<HintPath>..\packages\NuGet.ContentModel.4.2.0\lib\net45\NuGet.ContentModel.dll</HintPath>
50+
</Reference>
4551
<Reference Include="NuGet.Core, Version=2.13.0.824, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
4652
<HintPath>..\packages\NuGet.Core.2.13.0\lib\net40-Client\NuGet.Core.dll</HintPath>
4753
</Reference>
@@ -66,17 +72,29 @@
6672
<Reference Include="NuGet.Protocol.Core.v3, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6773
<HintPath>..\packages\NuGet.Protocol.Core.v3.4.2.0\lib\net45\NuGet.Protocol.Core.v3.dll</HintPath>
6874
</Reference>
75+
<Reference Include="NuGet.Repositories, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
76+
<HintPath>..\packages\NuGet.Repositories.4.2.0\lib\net45\NuGet.Repositories.dll</HintPath>
77+
</Reference>
78+
<Reference Include="NuGet.RuntimeModel, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
79+
<HintPath>..\packages\NuGet.RuntimeModel.4.2.0\lib\net45\NuGet.RuntimeModel.dll</HintPath>
80+
</Reference>
6981
<Reference Include="NuGet.Versioning, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7082
<HintPath>..\packages\NuGet.Versioning.4.2.0\lib\net45\NuGet.Versioning.dll</HintPath>
7183
</Reference>
72-
<Reference Include="Photon.Framework, Version=0.0.69.0, Culture=neutral, processorArchitecture=MSIL">
73-
<HintPath>..\packages\Photon.Framework.0.0.69\lib\net46\Photon.Framework.dll</HintPath>
84+
<Reference Include="Photon.Framework, Version=0.0.70.0, Culture=neutral, processorArchitecture=MSIL">
85+
<HintPath>..\packages\Photon.Framework.0.0.70\lib\net46\Photon.Framework.dll</HintPath>
86+
</Reference>
87+
<Reference Include="Photon.MSBuild, Version=0.0.6.0, Culture=neutral, processorArchitecture=MSIL">
88+
<HintPath>..\packages\Photon.MSBuild.0.0.6\lib\net46\Photon.MSBuild.dll</HintPath>
89+
</Reference>
90+
<Reference Include="Photon.NuGet, Version=0.0.14.0, Culture=neutral, processorArchitecture=MSIL">
91+
<HintPath>..\packages\Photon.NuGet.0.0.14\lib\net46\Photon.NuGet.dll</HintPath>
7492
</Reference>
75-
<Reference Include="Photon.MSBuild, Version=0.0.4.0, Culture=neutral, processorArchitecture=MSIL">
76-
<HintPath>..\packages\Photon.MSBuild.0.0.4\lib\net46\Photon.MSBuild.dll</HintPath>
93+
<Reference Include="Photon.NuGet.Core, Version=0.0.3.0, Culture=neutral, processorArchitecture=MSIL">
94+
<HintPath>..\packages\Photon.NuGet.Core.0.0.3\lib\net46\Photon.NuGet.Core.dll</HintPath>
7795
</Reference>
78-
<Reference Include="Photon.NuGet, Version=0.0.12.0, Culture=neutral, processorArchitecture=MSIL">
79-
<HintPath>..\packages\Photon.NuGet.0.0.12\lib\net46\Photon.NuGet.dll</HintPath>
96+
<Reference Include="Photon.NUnit, Version=0.0.1.0, Culture=neutral, processorArchitecture=MSIL">
97+
<HintPath>..\packages\Photon.NUnit.0.0.1\lib\net46\Photon.NUnit.dll</HintPath>
8098
</Reference>
8199
<Reference Include="System" />
82100
<Reference Include="System.Core" />
Lines changed: 54 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,97 @@
11
using Photon.Framework.Agent;
22
using Photon.Framework.Tasks;
33
using Photon.Framework.Tools;
4-
using Photon.MSBuild;
4+
using Photon.MSBuildPlugin;
5+
using Photon.NuGet.CorePlugin;
56
using Photon.NuGetPlugin;
7+
using System;
68
using System.IO;
9+
using System.Linq;
710
using System.Threading;
811
using System.Threading.Tasks;
912

1013
namespace Jenkins.NET.Publishing
1114
{
1215
public class Publish_Windows : IBuildTask
1316
{
17+
private MSBuildCommand msbuild;
18+
private NuGetCore nugetCore;
19+
private NuGetCommand nugetCmd;
20+
1421
public IAgentBuildContext Context {get; set;}
1522

1623

1724
public async Task RunAsync(CancellationToken token)
1825
{
26+
msbuild = new MSBuildCommand(Context) {
27+
Exe = Context.AgentVariables["global"]["msbuild_exe"],
28+
WorkingDirectory = Context.ContentDirectory,
29+
};
30+
31+
nugetCore = new NuGetCore(Context) {
32+
ApiKey = Context.ServerVariables["global"]["nuget/apiKey"],
33+
};
34+
nugetCore.Initialize();
35+
36+
nugetCmd = new NuGetCommand(Context) {
37+
Exe = Path.Combine(Context.ContentDirectory, "bin", "NuGet.exe"), //Context.AgentVariables["global"]["nuget_exe"];
38+
WorkingDirectory = Context.ContentDirectory,
39+
};
40+
1941
await BuildSolution(token);
2042

2143
await PublishPackage(token);
2244
}
2345

2446
private async Task BuildSolution(CancellationToken token)
2547
{
26-
var msbuild = new MSBuildCommand(Context) {
27-
Exe = Context.AgentVariables["global"]["msbuild_exe"],
28-
WorkingDirectory = Context.ContentDirectory,
29-
};
30-
31-
var buildArgs = new MSBuildArguments {
48+
await msbuild.RunAsync(new MSBuildArguments {
3249
ProjectFile = "Jenkins.NET.sln",
3350
Properties = {
3451
["Configuration"] = "Release",
3552
["Platform"] = "Any CPU",
3653
},
37-
Verbosity = MSBuildVerbosityLevel.Minimal,
54+
Verbosity = MSBuildVerbosityLevels.Minimal,
3855
MaxCpuCount = 0,
39-
};
40-
41-
await msbuild.RunAsync(buildArgs, token);
56+
}, token);
4257
}
4358

4459
private async Task PublishPackage(CancellationToken token)
4560
{
61+
const string packageId = "jenkinsnet";
4662
var assemblyFilename = Path.Combine(Context.ContentDirectory, "Jenkins.NET", "bin", "Release", "Jenkins.NET.dll");
47-
var version = AssemblyTools.GetVersion(assemblyFilename);
63+
var packageDefinitionFilename = Path.Combine(Context.ContentDirectory, "Jenkins.NET", "Jenkins.NET.csproj");
64+
var nugetPackageDir = Path.Combine(Context.WorkDirectory, "Packages");
65+
var assemblyVersion = AssemblyTools.GetVersion(assemblyFilename);
4866

49-
var apiKey = Context.ServerVariables["global"]["nuget.apiKey"];
5067

51-
var nugetTool = new NuGetPackagePublisher(Context) {
52-
Mode = NugetModes.Hybrid,
53-
Client = new NuGetCore {
54-
EnableV3 = true,
55-
Output = Context.Output,
56-
ApiKey = apiKey,
57-
},
58-
CL = new NuGetCommandLine {
59-
ExeFilename = Path.Combine(Context.ContentDirectory, "bin", "NuGet.exe"),
60-
Output = Context.Output,
61-
},
62-
PackageId = "jenkinsnet",
63-
PackageDefinition = Path.Combine(Context.ContentDirectory, "Jenkins.NET", "Jenkins.NET.csproj"),
64-
PackageDirectory = Path.Combine(Context.WorkDirectory, "Packages"),
65-
//Configuration = "Release",
66-
//Platform = "AnyCPU",
67-
Version = version,
68-
PackProperties = {
69-
["configuration"] = "Release",
70-
["platform"] = "AnyCPU",
68+
var versionList = await nugetCore.GetAllPackageVersions(packageId, token);
69+
var packageVersion = versionList.Any() ? versionList.Max() : null;
70+
71+
if (!VersionTools.HasUpdates(packageVersion, assemblyVersion)) {
72+
Context.Output.WriteLine($"Package '{packageId}' is up-to-date. Version {packageVersion}", ConsoleColor.DarkCyan);
73+
return;
74+
}
75+
76+
await nugetCmd.RunAsync(new NuGetPackArguments {
77+
Filename = packageDefinitionFilename,
78+
Version = assemblyVersion,
79+
OutputDirectory = nugetPackageDir,
80+
Properties = {
81+
["Configuration"] = "Release",
82+
["Platform"] = "AnyCPU",
83+
["Version"] = assemblyVersion,
7184
},
72-
};
85+
}, token);
86+
87+
var packageFilename = Directory
88+
.GetFiles(nugetPackageDir, $"{packageId}.*.nupkg")
89+
.FirstOrDefault();
7390

74-
nugetTool.Client.Initialize();
91+
if (string.IsNullOrEmpty(packageFilename))
92+
throw new ApplicationException($"No package found matching package ID '{packageId}'!");
7593

76-
await nugetTool.PublishAsync(token);
94+
await nugetCore.PushAsync(packageFilename, token);
7795
}
7896
}
7997
}

Jenkins.NET.Publishing/packages.config

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
<packages>
33
<package id="Microsoft.Web.Xdt" version="2.1.2" targetFramework="net46" />
44
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net46" />
5+
<package id="NuGet.Client" version="4.2.0" targetFramework="net46" />
56
<package id="NuGet.Common" version="4.2.0" targetFramework="net46" />
67
<package id="NuGet.Configuration" version="4.2.0" targetFramework="net46" />
8+
<package id="NuGet.ContentModel" version="4.2.0" targetFramework="net46" />
79
<package id="NuGet.Core" version="2.13.0" targetFramework="net46" />
810
<package id="NuGet.Frameworks" version="4.2.0" targetFramework="net46" />
911
<package id="NuGet.Packaging" version="4.2.0" targetFramework="net46" />
@@ -12,8 +14,12 @@
1214
<package id="NuGet.Protocol.Core.Types" version="4.2.0" targetFramework="net46" />
1315
<package id="NuGet.Protocol.Core.v2" version="3.5.0" targetFramework="net46" />
1416
<package id="NuGet.Protocol.Core.v3" version="4.2.0" targetFramework="net46" />
17+
<package id="NuGet.Repositories" version="4.2.0" targetFramework="net46" />
18+
<package id="NuGet.RuntimeModel" version="4.2.0" targetFramework="net46" />
1519
<package id="NuGet.Versioning" version="4.2.0" targetFramework="net46" />
16-
<package id="Photon.Framework" version="0.0.69" targetFramework="net46" />
17-
<package id="Photon.MSBuild" version="0.0.4" targetFramework="net46" />
18-
<package id="Photon.NuGet" version="0.0.12" targetFramework="net46" />
20+
<package id="Photon.Framework" version="0.0.70" targetFramework="net46" />
21+
<package id="Photon.MSBuild" version="0.0.6" targetFramework="net46" />
22+
<package id="Photon.NuGet" version="0.0.14" targetFramework="net46" />
23+
<package id="Photon.NuGet.Core" version="0.0.3" targetFramework="net46" />
24+
<package id="Photon.NUnit" version="0.0.1" targetFramework="net46" />
1925
</packages>

0 commit comments

Comments
 (0)