Skip to content

Commit 7226c5a

Browse files
committed
Updated build process
1 parent 1f5a062 commit 7226c5a

File tree

7 files changed

+68
-17
lines changed

7 files changed

+68
-17
lines changed

Diff for: .github/workflows/push-main.yaml

+2-5
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ jobs:
3636
- name: Get .NET information
3737
run: dotnet --info
3838

39-
- name: "Build target: BuildAll"
40-
run: dotnet run --project tools/builder --no-launch-profile -- BuildAll --timing
41-
42-
- name: "Build target: PublishPackages"
39+
- name: "Build target: BuildAll & PublishPackages"
4340
env:
4441
PUSH_APIKEY: ${{ secrets.PUSH_APIKEY }}
4542
PUSH_URI: ${{ secrets.PUSH_URI }}
@@ -50,7 +47,7 @@ jobs:
5047
SIGN_TENANT: ${{ secrets.SIGN_TENANT }}
5148
SIGN_TIMESTAMP_URI: ${{ secrets.SIGN_TIMESTAMP_URI }}
5249
SIGN_VAULT_URI: ${{ secrets.SIGN_VAULT_URI }}
53-
run: dotnet run --project tools/builder --no-launch-profile -- PublishPackages --timing
50+
run: dotnet run --project tools/builder --no-launch-profile -- BuildAll PublishPackages --timing
5451

5552
- name: "Upload artifact: test"
5653
uses: actions/upload-artifact@v3

Diff for: src/xunit.runner.visualstudio/xunit.runner.visualstudio.csproj

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646

4747
<Target Name="UpdateNuSpecProperties" BeforeTargets="GenerateNuspec" DependsOnTargets="GetBuildVersion">
4848
<PropertyGroup>
49+
<SignedPath />
50+
<SignedPath Condition=" '$(SIGN_APP_SECRET)' != '' ">signed\</SignedPath>
4951
<!-- Never put the Git hash in the package version -->
5052
<PackageVersion>$(BuildVersionSimple)$(PrereleaseVersion)</PackageVersion>
5153
<!-- Pass through values we don't know ahead of time for any hand-crafted .nuspec files -->
@@ -54,6 +56,7 @@
5456
GitCommitId=$(GitCommitId);
5557
MicrosoftTestPlatformObjectModelVersion=$(MicrosoftTestPlatformObjectModelVersion);
5658
PackageVersion=$(PackageVersion);
59+
SignedPath=$(SignedPath);
5760
</NuspecProperties>
5861
</PropertyGroup>
5962
</Target>

Diff for: src/xunit.runner.visualstudio/xunit.runner.visualstudio.nuspec

+9-2
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,21 @@
2525
<frameworkAssembly assemblyName="mscorlib" targetFramework="net462" />
2626
</frameworkAssemblies>
2727
</metadata>
28+
<!-- Remember to update tools\builder\targets\SignAssemblies.cs when assemblies are added or removed -->
2829
<files>
2930
<file target="_content\" src="..\..\logo-128-transparent.png" />
3031
<file target="_content\" src="..\..\README.md" />
3132

32-
<file target="build\net462\" src="bin\$Configuration$\net462\xunit.*.dll" />
33+
<file target="build\net462\" src="bin\$Configuration$\net462\xunit.abstractions.dll" />
34+
<file target="build\net462\" src="bin\$Configuration$\net462\xunit.runner.reporters.net452.dll" />
35+
<file target="build\net462\" src="bin\$Configuration$\net462\xunit.runner.utility.net452.dll" />
36+
<file target="build\net462\" src="bin\$Configuration$\net462\$SignedPath$xunit.runner.visualstudio.testadapter.dll" />
3337
<file target="build\net462\xunit.runner.visualstudio.props" src="build\xunit.runner.visualstudio.desktop.props" />
3438

35-
<file target="build\net6.0\" src="bin\$Configuration$\net6.0\xunit.*.dll" />
39+
<file target="build\net6.0\" src="bin\$Configuration$\net6.0\xunit.abstractions.dll" />
40+
<file target="build\net6.0\" src="bin\$Configuration$\net6.0\xunit.runner.reporters.netcoreapp10.dll" />
41+
<file target="build\net6.0\" src="bin\$Configuration$\net6.0\xunit.runner.utility.netcoreapp10.dll" />
42+
<file target="build\net6.0\" src="bin\$Configuration$\net6.0\$SignedPath$xunit.runner.visualstudio.testadapter.dll" />
3643
<file target="build\net6.0\xunit.runner.visualstudio.props" src="build\xunit.runner.visualstudio.dotnetcore.props" />
3744

3845
<file target="lib\net462\" src="build\_._" />

Diff for: src/xunit.runner.visualstudio/xunit.runner.visualstudio.sign-file-list

-2
This file was deleted.

Diff for: tools/builder/targets/Packages.cs

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.IO;
2+
using System.Linq;
23
using System.Threading.Tasks;
34
using Xunit.BuildTools.Models;
45

@@ -10,13 +11,20 @@ public static async Task OnExecute(BuildContext context)
1011
{
1112
context.BuildStep("Creating NuGet packages");
1213

13-
var packArgs = $"pack --nologo --no-build --configuration {context.ConfigurationText} --output {context.PackageOutputFolder} --verbosity {context.Verbosity} src/xunit.runner.visualstudio -p:NuspecFile=xunit.runner.visualstudio.nuspec";
14-
await context.Exec("dotnet", packArgs);
14+
// Clean up any existing packages to force re-packing
15+
var packageFiles = Directory.GetFiles(context.PackageOutputFolder, "*.nupkg");
16+
foreach (var packageFile in packageFiles)
17+
File.Delete(packageFile);
1518

16-
File.Copy(
17-
Path.Join(context.BaseFolder, "src", "xunit.runner.visualstudio", "xunit.runner.visualstudio.sign-file-list"),
18-
Path.Join(context.PackageOutputFolder, "xunit.runner.visualstudio.sign-file-list"),
19-
overwrite: true
20-
);
19+
// Enumerate the .nuspec files and pack those
20+
var srcFolder = Path.Join(context.BaseFolder, "src");
21+
var nuspecFiles =
22+
Directory
23+
.GetFiles(srcFolder, "*.nuspec", SearchOption.AllDirectories)
24+
.ToList();
25+
26+
// Pack the .nuspec file(s)
27+
foreach (var nuspecFile in nuspecFiles.OrderBy(x => x))
28+
await context.Exec("dotnet", $"pack --nologo --no-build --configuration {context.ConfigurationText} --output {context.PackageOutputFolder} --verbosity {context.Verbosity} \"{Path.GetDirectoryName(nuspecFile)}\" -p:NuspecFile={Path.GetFileName(nuspecFile)}");
2129
}
2230
}

Diff for: tools/builder/targets/SignAssemblies.cs

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System;
2+
using System.IO;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Xunit.BuildTools.Models;
6+
7+
namespace Xunit.BuildTools.Targets;
8+
9+
public static partial class SignAssemblies
10+
{
11+
public static Task OnExecute(BuildContext context)
12+
{
13+
// Check early because we don't need to make copies or show the banner for non-signed scenarios
14+
if (!context.CanSign)
15+
return Task.CompletedTask;
16+
17+
context.BuildStep("Signing binaries");
18+
19+
// Note that any changes to .nuspec files means this list needs to be updated
20+
var binaries =
21+
new[] {
22+
Path.Combine(context.BaseFolder, "src", "xunit.runner.visualstudio", "bin", context.ConfigurationText, "net462", "xunit.runner.visualstudio.testadapter.dll"),
23+
Path.Combine(context.BaseFolder, "src", "xunit.runner.visualstudio", "bin", context.ConfigurationText, "net6.0", "xunit.runner.visualstudio.testadapter.dll"),
24+
}.Select(unsignedPath =>
25+
{
26+
var unsignedFolder = Path.GetDirectoryName(unsignedPath) ?? throw new InvalidOperationException($"Path '{unsignedPath}' did not have a folder");
27+
var signedFolder = Path.Combine(unsignedFolder, "signed");
28+
Directory.CreateDirectory(signedFolder);
29+
30+
var signedPath = Path.Combine(signedFolder, Path.GetFileName(unsignedPath));
31+
File.Copy(unsignedPath, signedPath, overwrite: true);
32+
33+
return signedPath;
34+
}).ToArray();
35+
36+
return context.SignFiles(context.BaseFolder, binaries);
37+
}
38+
}

0 commit comments

Comments
 (0)