Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add netcoreapp2.0 solution and project files #81

Closed
wants to merge 3 commits into from
Closed

Add netcoreapp2.0 solution and project files #81

wants to merge 3 commits into from

Conversation

doomkin
Copy link

@doomkin doomkin commented Jul 14, 2017

I suggest to add a solution file, two project files, two build task files for VSCode and insert a conditional compilation in AssemblyInfo.cs to avoid build error. Tested on Arch Linux on netcoreapp2.0 by dotnet build BouncyCastle.netcore2.sln.

@clairernovotny
Copy link

This duplicates functionality in #68 as that version supports .NET Standard, which works with .NET Core 2.0.

@clairernovotny
Copy link

@doomkin Can you try using the Portable.BouncyCastle NuGet package and see if that works for you? It's built off of my fork from #68. Lots of people are using it today. Happy to address any issues that you find there.

@doomkin
Copy link
Author

doomkin commented Jul 14, 2017

@onovotny Portable.BouncyCastle via NuGet works too. My PR related to building BouncyCastle on netcoreapp2.0 SDK.

@clairernovotny
Copy link

I guess I'm wondering why you need this at all though. Once my PR is merged in, it'll build there too... What does this add over the other PR? I'm happy to take PR's to my fork as well.

@doomkin
Copy link
Author

doomkin commented Jul 14, 2017

@onovotny You change 337 files, its a lot of work to check this changes. I suggest to add a solution file, two project files, and insert a conditional compilation in AssemblyInfo.cs

@clairernovotny
Copy link

The files I change are all Unit tests to rename the Main method because of compiler things. The rest are globed in.

@doomkin
Copy link
Author

doomkin commented Jul 14, 2017

@onovotny In my opinion, I propose a more elegant solution.

@clairernovotny
Copy link

@doomkin I respectfully disagree. Please look at my csproj compared to what's here. One csproj for all platforms and almost nothing in it:
https://github.com/onovotny/bc-csharp/blob/netstandard/crypto/src/crypto.csproj

@doomkin
Copy link
Author

doomkin commented Jul 14, 2017

@onovotny It looks compact. I inserted the framework netcoreapp2.0 into your project file crypto.portable.csproj and tried to build it on Arch Linux:

$ dotnet build crypto.portable.csproj 
Microsoft (R) Build Engine version 15.3.388.41745 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

/home/ar/.nuget/packages/gitversiontask/4.0.0-beta0011/buildMultiTargeting/GitVersionTask.targets(43,5): error MSB4062: The "GitVersionTask.WriteVersionInfoToBuildLog" task could not be loaded from the assembly /home/ar/.nuget/packages/gitversiontask/4.0.0-beta0011/buildMultiTargeting/../build/GitVersionTask.dll. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL'. The system cannot find the file specified. [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/gitversiontask/4.0.0-beta0011/buildMultiTargeting/GitVersionTask.targets(43,5): error MSB4062:  Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]

@clairernovotny
Copy link

clairernovotny commented Jul 14, 2017

@doomkin That's a temporary limitation until 1.8.2 is shipped. The auto-versioning library I'm using, GitVersionTask only works on MSBuild, not dotnet build. If you remove the PackageReference for it, it'll build with dotnet build.

The alternative is to use Nerdbank.GitVersioning, but it only preserves the first three parts of the version -- i.e., I can't have 1.8.1.x builds easily. I'm trying to stay aligned with the main BC versions.

@clairernovotny
Copy link

clairernovotny commented Jul 14, 2017

@doomkin Also, there should be no need to build for netcoreapp2.0. The netstandard1.3 version should cover it. If there's additional surface area unlocked by netstandard2.0, that's totally worth including, I'd agree. netcoreapp2.0 is a platform, not a contract, so it's not really ideal to target unless you need an API that's only there and not in netstandard2.0 or below.

@doomkin
Copy link
Author

doomkin commented Jul 14, 2017

@onovotny This does not work. I hope you will attach your version of the csproj that will build the dotnet build on netstandard2.0 on Arch Linux.

@clairernovotny
Copy link

@doomkin I've pushed a branch that can do this dotnet-build:
https://github.com/onovotny/bc-csharp/blob/dotnet-build/crypto/src/crypto.csproj

That version has to drop the portable-net4+sl5+wp8+win8+wpa81 target because dotnet simply cannot build it, only MSBuild can do that.

@doomkin
Copy link
Author

doomkin commented Jul 14, 2017

@onovotny Thank you, but this does not work:

[ar@arch crypto]$ dotnet build crypto.portable.csproj 
Microsoft (R) Build Engine version 15.3.388.41745 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly. [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load DLL '/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/MSBuildFull/lib/linux/x86_64/libgit2-1196807.so': The specified module or one of its dependencies could not be found. [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:  (Exception from HRESULT: 0x8007007E) [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at System.Runtime.Loader.AssemblyLoadContext.InternalLoadUnmanagedDllFromPath(String unmanagedDllPath) [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at MSBuildExtensionTask.ContextAwareTask.CustomAssemblyLoader.LoadUnmanagedDll(String unmanagedDllName) [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at System.Runtime.Loader.AssemblyLoadContext.ResolveUnmanagedDll(String unmanagedDllName, IntPtr gchManagedAssemblyLoadContext) [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_libgit2_init() [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.LibraryLifetimeObject..ctor() [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods..cctor() [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    --- End of inner exception stack trace --- [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_repository_open(git_repository*& repository, FilePath path) [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at LibGit2Sharp.Core.Proxy.git_repository_open(String path) [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at LibGit2Sharp.Repository..ctor(String path, RepositoryOptions options, RepositoryRequiredParameter requiredParameter) [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at Nerdbank.GitVersioning.VersionOracle.OpenGitRepo(String repoRoot) [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at Nerdbank.GitVersioning.VersionOracle.Create(String projectDirectory, String gitRepoDirectory, ICloudBuild cloudBuild, Nullable`1 overrideBuildNumberOffset) [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at Nerdbank.GitVersioning.Tasks.GetBuildVersion.ExecuteInner() [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly. [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load DLL '/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/MSBuildFull/lib/linux/x86_64/libgit2-1196807.so': The specified module or one of its dependencies could not be found. [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:  (Exception from HRESULT: 0x8007007E) [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at System.Runtime.Loader.AssemblyLoadContext.InternalLoadUnmanagedDllFromPath(String unmanagedDllPath) [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at MSBuildExtensionTask.ContextAwareTask.CustomAssemblyLoader.LoadUnmanagedDll(String unmanagedDllName) [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at System.Runtime.Loader.AssemblyLoadContext.ResolveUnmanagedDll(String unmanagedDllName, IntPtr gchManagedAssemblyLoadContext) [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_libgit2_init() [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.LibraryLifetimeObject..ctor() [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods..cctor() [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    --- End of inner exception stack trace --- [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_repository_open(git_repository*& repository, FilePath path) [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at LibGit2Sharp.Core.Proxy.git_repository_open(String path) [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at LibGit2Sharp.Repository..ctor(String path, RepositoryOptions options, RepositoryRequiredParameter requiredParameter) [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at Nerdbank.GitVersioning.VersionOracle.OpenGitRepo(String repoRoot) [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at Nerdbank.GitVersioning.VersionOracle.Create(String projectDirectory, String gitRepoDirectory, ICloudBuild cloudBuild, Nullable`1 overrideBuildNumberOffset) [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/home/ar/.nuget/packages/nerdbank.gitversioning/2.0.37-beta/build/Nerdbank.GitVersioning.targets(58,5): error MSB4018:    at Nerdbank.GitVersioning.Tasks.GetBuildVersion.ExecuteInner() [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(1122,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]

@clairernovotny
Copy link

clairernovotny commented Jul 14, 2017

A couple things.

  1. Building on arch Linux may be very hard for most libraries. LibGit2Sharp doesn't seem to support that. Tagging @AArnott if he has any ideas.
  2. Building net4 on arch Linux is also not apparently supported

I've removed those two dependencies in that branch:
https://github.com/onovotny/bc-csharp/blob/dotnet-build/crypto/src/crypto.csproj

But I would not expect that to be ultimately merged in. The end result may require Windows to build in order to fully support the older frameworks. What targets are supported ultimately is not my call. If the library is NETStandard only, and older things can be dropped, then great. Otherwise, I'm afraid you wouldn't be able to build it there. Note that that doesn't affect actually consuming the library however it is built.

@doomkin
Copy link
Author

doomkin commented Jul 14, 2017

@onovotny This does not work too: 5019 Errors.

test/src/openpgp/test/PGPNoPrivateKeyTest.cs(161,10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
test/src/openpgp/test/PGPNoPrivateKeyTest.cs(161,10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?) [/home/ar/projects/crypto/bc-csharp/crypto/crypto.portable.csproj]
    12 Warning(s)
    5019 Error(s)

My crypto.netcore2.csproj works fine. Perhaps it can be simplified. Please note that I do not change anything except AssembyInfo.cs

#if !NETCORE
[assembly: AssemblyTitle("BouncyCastle.Crypto")]
[assembly: AssemblyDescription("Bouncy Castle Cryptography API")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("The Legion of the Bouncy Castle Inc.")]
[assembly: AssemblyProduct("Bouncy Castle for .NET")]
[assembly: AssemblyCopyright("Copyright (C) 2000-2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
#endif

#if !NETCORE
[assembly: AssemblyVersion("1.8.1.0")]
[assembly: AssemblyFileVersion("1.8.15362.1")]
[assembly: AssemblyInformationalVersion("1.8.1")]
#endif

Information about assembly contains in csproj to avoid build error.

    <Company>The Legion of the Bouncy Castle Inc.</Company>
    <Copyright>Copyright (C) 2000-2017</Copyright>
    <Description>Bouncy Castle Cryptography API</Description>
    <FileVersion>1.8.15362.1</FileVersion>
    <Version>1.8.1.0</Version>
    <Product>Bouncy Castle for .NET</Product>
    <AssemblyTitle>BouncyCastle.Crypto</AssemblyTitle>
    <AssemblyVersion>1.8.1</AssemblyVersion>
    <NeutralLanguage></NeutralLanguage>

Therefore, my PR causes more trusted than yours when it comes to cryptography. Do you agree?

@clairernovotny
Copy link

clairernovotny commented Jul 14, 2017

No, your PR is not more trusted. I don't need to change anything important in the code itself. The PR here adds an additional project to build and then package. That's hard to maintain.

My PR leverages the multi-targeting capabilities to generate targets for all supported platforms within a single project.

The only real things that were changed are this:

In the tests:
public static void Main() to public static void MainOld() to avoid multiple entrypoints based on the way the tests are structured. Those are legacy Nunit test suites, which are not really needed as the Nunit adapters run all of the tests anyway.

In the code, a few places where MemoryStream.GetBuffer() was used, which is valid in net4, was updated to use ToArray() on the platforms that don't have GetBuffer() on them.

No significant changes were made to the code.

@doomkin
Copy link
Author

doomkin commented Jul 14, 2017

@onovotny Ok, men 🥇 Trust is the same

@AArnott
Copy link

AArnott commented Jul 15, 2017

Building on arch Linux may be very hard for most libraries. LibGit2Sharp doesn't seem to support that. Tagging @AArnott if he has any ideas.

That's not true. libgit2sharp does indeed build on linux, including with NB.GV applied.

@AArnott
Copy link

AArnott commented Jul 15, 2017

I guess I'm a little lost here. I don't see NB.GV being added here, nor linux being added to any CI server. So where does this error repro, and why with this PR only?

@clairernovotny
Copy link

clairernovotny commented Jul 15, 2017

@AArnott It was an earlier commit in this branch https://github.com/onovotny/bc-csharp/blob/dotnet-build/crypto/src/crypto.csproj, that I was trying to help @doomkin build this on his preferred OS. I removed it from that branch to try and unblock him....

@Peter-Optiway
Copy link

Any news when this might hit the nuget package?

@clairernovotny
Copy link

It's already in Portable.bouncycastle. You can see it in my pr and fork.

@Peter-Optiway
Copy link

@onovotny it would be nice if it was included in the official nuget package, but thanks for the information.

@clairernovotny
Copy link

FWIW, my fork is essentially the official portable version. Once the current set of changes in master are released as stable, I believe the intent is to merge my pr.

Always happy for code reviews to verify authenticity, and my libraries are all authenticode signed so you can be sure they came from me.

@LarinLive
Copy link

LarinLive commented Nov 16, 2017

IGNOREME: I am commenting here so I can easily find this issue again in the future, since I can't do that by subscribing alone.

@Devvox93
Copy link

Devvox93 commented Apr 9, 2018

@onovotny Just thought to notify you of the conflict in AssemblyInfo.cs as I was reading the comments in this PR, if it is still valid (it's still Open).

@clairernovotny
Copy link

@Devvox93 this PR is not mine, it has a different set of changes that I disagree with (see above thread). My PR is here and is up-to-date: #68

@Devvox93
Copy link

@onovotny My apologies. I had both PR's open in tabs and have mixed them up.

@peterdettman
Copy link
Collaborator

Obsoleted by the impending release of v2.0 NuGet package with support for net461, netstandard2.0, net6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants