Giter Site home page Giter Site logo

Comments (24)

tam481 avatar tam481 commented on May 19, 2024 1

Hello mate. I cracked it. I ran dotnet add package Newtonsoft.Json --version 12.0.2 then dotnet add package Newtonsoft.Json --version 12.0.1

Then attempted to generate a licence and it generated one.

from bitbetter.

JeffAlyanak avatar JeffAlyanak commented on May 19, 2024

What version of the dotnet-sdk did you install? It seems like it wants version 12.0.0 of Newtonsoft.Json.

from bitbetter.

tam481 avatar tam481 commented on May 19, 2024

I installed "dotnet-sdk-2.1"

from bitbetter.

tam481 avatar tam481 commented on May 19, 2024

running (dotnet --version)
Returns (2.1.700)

from bitbetter.

JeffAlyanak avatar JeffAlyanak commented on May 19, 2024

And just to confirm, you ran the dotnet add package Newtonsoft.Json --version 11.0.0 command from within the /src/licenseGen/ directory before running the build script for the license generator?

Perhaps there's something different about your dotnet install or your environment that is causing it to look for version 12.0.0. You can try just adding that package and rebuilding.

from bitbetter.

tam481 avatar tam481 commented on May 19, 2024

I did exactly as per your documentation.
I ran dotnet add package Newtonsoft.Json --version 11.0.0 inside both /src/licenseGen and /src/bitBetter

from bitbetter.

tam481 avatar tam481 commented on May 19, 2024

This morning I tried dotnet add package Newtonsoft.Json --version 12.0.0 to no avail

from bitbetter.

JeffAlyanak avatar JeffAlyanak commented on May 19, 2024

Can you please re-run the src/licenseGen/build.sh and post what it returns to the command line? Please use a multi-line code comment to keep it as readable as possible.

Can you also confirm the contents of your src/licenseGen/licenseGen.csproj file.

from bitbetter.

tam481 avatar tam481 commented on May 19, 2024

Running src/licenceGen/build.sh returns the following:

/opt/BitBetter/src/licenseGen/licenseGen.csproj : warning NU1603: licenseGen depends on Newtonsoft.Json (>= 11.0.0) but Newtonsoft.Json 11.0.0 was not found. An approximate best match of Newtonsoft.Json 11.0.1 was resolved.
  Restore completed in 46.21 ms for /opt/BitBetter/src/licenseGen/licenseGen.csproj.
Microsoft (R) Build Engine version 16.1.76+g14b0a930a7 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

/opt/BitBetter/src/licenseGen/licenseGen.csproj : warning NU1603: licenseGen depends on Newtonsoft.Json (>= 11.0.0) but Newtonsoft.Json 11.0.0 was not found. An approximate best match of Newtonsoft.Json 11.0.1 was resolved.
  Restore completed in 39.9 ms for /opt/BitBetter/src/licenseGen/licenseGen.csproj.
/opt/BitBetter/src/licenseGen/licenseGen.csproj : warning NU1603: licenseGen depends on Newtonsoft.Json (>= 11.0.0) but Newtonsoft.Json 11.0.0 was not found. An approximate best match of Newtonsoft.Json 11.0.1 was resolved.
  licenseGen -> /opt/BitBetter/src/licenseGen/bin/Debug/netcoreapp2.0/licenseGen.dll
  licenseGen -> /opt/BitBetter/src/licenseGen/bin/Debug/netcoreapp2.0/publish/
Sending build context to Docker daemon  949.8kB
Step 1/3 : FROM bitbetter/api
 ---> 0fb112c12c9a
Step 2/3 : COPY bin/Debug/netcoreapp2.0/publish/* /app/
 ---> Using cache
 ---> 1de3b1785a6c
Step 3/3 : ENTRYPOINT [ "dotnet", "/app/licenseGen.dll", "--core", "/app/Core.dll", "--cert", "/cert.pfx" ]
 ---> Using cache
 ---> f00f07f76b7a
Successfully built f00f07f76b7a
Successfully tagged bitbetter/licensegen:latest

from bitbetter.

tam481 avatar tam481 commented on May 19, 2024

Below are the contents of the csproj:

root@debian:/opt/BitBetter/src/licenseGen# cat licenseGen.csproj
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.CommandLineUtils" Version="1.1.1" />
    <PackageReference Include="Newtonsoft.Json" Version="11.0.0" />
    <PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
  </ItemGroup>

</Project>

from bitbetter.

JeffAlyanak avatar JeffAlyanak commented on May 19, 2024

Below are the contents of the csproj:

root@debian:/opt/BitBetter/src/licenseGen# cat licenseGen.csproj

Have you been following all of the steps as the root user? I wouldn't recommend that for security and environment reasons.

We've seen users in the past having issues getting the dotnet builds and the docker containers working correctly due to the way that dotnet and docker set environment variables.

In the past, those issues have been solved by using a regular, unprivileged user instead.

from bitbetter.

tam481 avatar tam481 commented on May 19, 2024

oh OK. I thought I wouldn't be able to execute the commands as a standard user. Wouldn't doing sudo ./build.sh be the same as running it as root?

from bitbetter.

tam481 avatar tam481 commented on May 19, 2024

I can't run ./build.sh or the dotnet add package Newtonsoft.Json --version 11.0.0 without sudo

I'm I doing this all wrong?

from bitbetter.

JeffAlyanak avatar JeffAlyanak commented on May 19, 2024

You shouldn't have to run with sudo at all for anything other than installing the prerequisites.

If you followed the recommended steps when installing docker, you would have added an unprivileged user to the docker usergroup with a command like sudo usermod -aG docker someuser and you'd have used sudo to install any required packages (dotnet sdk) but aside from that nothing needs sudo or root access.

As a rule of thumb, you should never run anything with root that doesn't require root.

The reason you can't run the dotnet command is probably because the BitBetter directory and the files inside are owned by root now. You should chown those to the correct user or git clone them as an unprivileged user and then go through those instructions again without using the root user.

from bitbetter.

tam481 avatar tam481 commented on May 19, 2024

OK. Just recreated everything and I'm doing things as my non-privileged user "user"

Everything is installed in /opt/
user owns bwdata and BitBetter and the bitwarden.sh scripts
It is also a member of the docker group and I've managed to get Bitwarden started

I'm still getting the same error message though!

user@debian:/opt/BitBetter/src/licenseGen$ ./run.sh /opt/BitBetter/.keys/cert.pfx user User [email protected] GUID
Oops: System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.

File name: 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
   at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.IsCustomAttributeDefined(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Int32 attributeCtorToken, Boolean mustBeInheritable)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.GetSerializableMembers(Type objectType)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateProperties(Type type, MemberSerialization memberSerialization)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract(Type objectType)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(Type objectType)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer)
   at bitwardenSelfLicensor.Program.GenerateUserLicense(X509Certificate2 cert, String corePath, String userName, String email, Guid userId, String key) in /opt/BitBetter/src/licenseGen/Program.cs:line 175
   at bitwardenSelfLicensor.Program.<>c__DisplayClass0_1.<Main>b__6() in /opt/BitBetter/src/licenseGen/Program.cs:line 75
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at bitwardenSelfLicensor.Program.Main(String[] args) in /opt/BitBetter/src/licenseGen/Program.cs:line 137

I've changed details such as user, email and GUID before posting but the actual command has the correct ones.

What else can I do now?

from bitbetter.

JeffAlyanak avatar JeffAlyanak commented on May 19, 2024

For now I've been unable to recreate this issue, trying clean installs on fresh Debian 9 and Ubuntu 19.04 systems.

What operating system and OS version are you attempting this install on?

Using the most recent version of BitBetter (commit 15371c3), the default version that installs with the dotnet-sdk-2.1 (oddly enough, this is 2.2.300) and the most recent version of Bitwarden I can't replicate the issue. I've also tried using the version of the dotnet-sdk that you have (2.1.700), but still can't replicate the issue.

Perhaps you can try manually installing a different version of the dotnet-sdk. I believe that Microsoft simply provides package names for different versions, so you can try installing dotnet-sdk-2.2.

Remember that you have to rebuild the license generator again after installing a new version of dotnet-sdk and updating the dotnet packages with dotnet add package Newtonsoft.Json --version 11.0.0.

from bitbetter.

tam481 avatar tam481 commented on May 19, 2024

Thanks @JeffAlyanak
I am running a clean version of Debian 9

user@debian:~$ cat /etc/*-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
user@debian:~$ cat /proc/version
Linux version 4.9.0-9-amd64 ([email protected]) (gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1) ) #1 SMP Debian 4.9.168-1+deb9u2 (2019-05-13)

Followed the instructions on the main page for BitBetter and managed to build the Docker images for both BitBetter and Bitwarden with no issues other than the warning about the version being 11.0.1 instead of 11.0.0 and that's all.

Also, with regards to the certificate, this is the self-signed one described under "Note: Manually generating Certificate & Key" right?

I even searched all the files inside licenceGen for 12.0.0 and could not find any reference. All references I found are for version 11.0.0 as expected.

I'm doing this on a virtual machine and I've reverted to the snapshot that only has the minimum Debian installation plus unzip and sudo and nothing else.

I will try a different version of dotnet and see.

from bitbetter.

tam481 avatar tam481 commented on May 19, 2024

I've not had much luck with the commit you referred to above (git clone https://github.com/jakeswenson/BitBetter.git). This is the one right?

Not much luck with dotnet2.2 either :-(

Edit: removed references to new issue #20 which is now closed.

from bitbetter.

JeffAlyanak avatar JeffAlyanak commented on May 19, 2024

Since your issue with bitbetter/identity has been resolved by rebuilding can you try deleting and rebuilding the license gen and posting the resulting output below if that does not solve the issue?

from bitbetter.

tam481 avatar tam481 commented on May 19, 2024

Tried again multiple times last night and in a completely new environment (lab at work) with a proper certificate and everything. Still getting the same error message!

I cannot for the life of me figure out where the reference to 12.0.0.0 is!

Oops: System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.

File name: 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
   at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.IsCustomAttributeDefined(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Int32 attributeCtorToken, Boolean mustBeInheritable)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.GetSerializableMembers(Type objectType)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateProperties(Type type, MemberSerialization memberSerialization)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract(Type objectType)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(Type objectType)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer)
   at bitwardenSelfLicensor.Program.GenerateOrgLicense(X509Certificate2 cert, String corePath, String userName, String email, Guid instalId, String key) in /opt/BitBetter/src/licenseGen/Program.cs:line 220
   at bitwardenSelfLicensor.Program.<>c__DisplayClass0_2.<Main>b__7() in /opt/BitBetter/src/licenseGen/Program.cs:line 121
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at bitwardenSelfLicensor.Program.Main(String[] args) in /opt/BitBetter/src/licenseGen/Program.cs:line 137

from bitbetter.

JeffAlyanak avatar JeffAlyanak commented on May 19, 2024

I've played around a bit with this tonight and I can't replicate the same issues that you had. For now I'm just going to file this under Unsolved Mysteries and close it as I'm hoping to automate the dotnet setup anyway.

from bitbetter.

DB-CL avatar DB-CL commented on May 19, 2024

I had the exact same issue on a fresh debian 9 install. I cannot provide more informations than @tam481 but his solution is working.

from bitbetter.

JeffAlyanak avatar JeffAlyanak commented on May 19, 2024

Hey @DB-CL, this issue has been fixed in the upcoming Interactive Mode release ( #23 ). It's still awaiting review and approval from another contributor before it hits the master branch, but it does appear to address this issue with newer versions of the dotnet-sdk.

from bitbetter.

JeffAlyanak avatar JeffAlyanak commented on May 19, 2024

The version of Newtonsoft in the newest commit has been bumped and should work with a wider variety of systems and versions of dotnet-sdk now.

The changes have merged to the master branch with PR #23.

Theoretically, you shouldn't even need to run the dotnet add package commands.

from bitbetter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.