Skip to content

Commit

Permalink
update build + add net472 target
Browse files Browse the repository at this point in the history
  • Loading branch information
leastprivilege committed Nov 5, 2019
1 parent 60716be commit 4c5a7b3
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 43 deletions.
54 changes: 20 additions & 34 deletions build/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ namespace build
{
class Program
{
private const bool RequireTests = true;
private static class Targets
{
public const string Build = "build";
public const string Test = "test";
public const string Pack = "pack";
}

static string BinaryToSign = "IdentityModel.OidcClient.dll";

private const string ArtifactsDir = "artifacts";
private const string Build = "build";
private const string Test = "test";
private const string Pack = "pack";

static void Main(string[] args)
{
Expand All @@ -25,52 +28,35 @@ static void Main(string[] args)

app.OnExecute(() =>
{
Target(Build, () =>
Target(Targets.Build, () =>
{
var solution = Directory.GetFiles(".", "*.sln", SearchOption.TopDirectoryOnly).First();
Run("dotnet", $"build {solution} -c Release");
Run("dotnet", $"build -c Release");
if (sign.HasValue())
{
Sign("IdentityModel.OidcClient.dll", "./src/bin/release");
Sign(BinaryToSign, "./src/bin/release");
}
});
Target(Test, DependsOn(Build), () =>
Target(Targets.Test, DependsOn(Targets.Build), () =>
{
try
{
var tests = Directory.GetFiles("./test", "*.csproj", SearchOption.AllDirectories);
foreach (var test in tests)
{
Run("dotnet", $"test {test} -c Release --no-build");
}
}
catch (System.IO.DirectoryNotFoundException ex)
{
if (RequireTests)
{
throw new Exception($"No tests found: {ex.Message}");
};
}
Run("dotnet", $"test -c Release --no-build");
});
Target(Pack, DependsOn(Build), () =>
Target(Targets.Pack, DependsOn(Targets.Test), () =>
{
var project = Directory.GetFiles("./src", "*.csproj", SearchOption.TopDirectoryOnly).First();
Run("dotnet", $"pack {project} -c Release -o ./{ArtifactsDir} --no-build");
Run("dotnet", $"pack {project} -c Release -o ./artifacts --no-build");
if (sign.HasValue())
{
Sign("*.nupkg", $"./{ArtifactsDir}");
Sign("*.nupkg", $"./artifacts");
}
});
Target("default", DependsOn(Test, Pack));
Target("default", DependsOn(Targets.Test, Targets.Pack));
RunTargetsAndExit(app.RemainingArguments);
});

Expand All @@ -97,15 +83,15 @@ private static void Sign(string extension, string directory)
foreach (var file in files)
{
Console.WriteLine(" Signing " + file);
Run("./tools/signclient", $"sign -c {signClientConfig} -i {file} -r [email protected] -s \"{signClientSecret}\" -n 'IdentityServer4'", noEcho: true);
Run("dotnet", $"SignClient sign -c {signClientConfig} -i {file} -r [email protected] -s \"{signClientSecret}\" -n 'IdentityServer4'", noEcho: true);
}
}

private static void CleanArtifacts()
{
Directory.CreateDirectory($"./{ArtifactsDir}");
Directory.CreateDirectory($"./artifacts");

foreach (var file in Directory.GetFiles($"./{ArtifactsDir}"))
foreach (var file in Directory.GetFiles($"./artifacts"))
{
File.Delete(file);
}
Expand Down
8 changes: 4 additions & 4 deletions build/build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bullseye" Version="2.3.0" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.3.3" />
<PackageReference Include="SimpleExec" Version="5.0.1" />
<ItemGroup>
<PackageReference Include="Bullseye" Version="3.0.0" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.4.1" />
<PackageReference Include="SimpleExec" Version="6.0.0" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/IdentityModel.OidcClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net461;net472;netstandard2.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -34,7 +34,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="IdentityModel" Version="4.0.0" />
<PackageReference Include="IdentityModel" Version="4.1.0" />
<PackageReference Include="minver" Version="2.0.0" PrivateAssets="All" />

<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.6.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netcoreapp2.1;netcoreapp2.2;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
<TargetFrameworks>net461;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0</TargetFrameworks>
<TargetFrameworks>net461;net472;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions test/IdentityModel.OidcClient.Tests/Infrastructure/Crypto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public static RsaSecurityKey CreateKey()
{
var rsa = RSA.Create();

#if NET452 || NET461
#if NET452 || NET461 || NET472
if (rsa.KeySize < 2048)
{
rsa.Dispose();
rsa = new RSACryptoServiceProvider(2048);
}
#endif
RsaSecurityKey key = null;
#if NET452 || NET461
#if NET452 || NET461 || NET472
if (rsa is RSACryptoServiceProvider)
{
var parameters = rsa.ExportParameters(includePrivateParameters: true);
Expand Down

0 comments on commit 4c5a7b3

Please sign in to comment.