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

nbgv install command can not find 'Nuget.ProjectModel' #646

Closed
B45man opened this issue Aug 27, 2021 · 6 comments
Closed

nbgv install command can not find 'Nuget.ProjectModel' #646

B45man opened this issue Aug 27, 2021 · 6 comments

Comments

@B45man
Copy link

B45man commented Aug 27, 2021

I have a freshly created Blazor project. Following the recommended guide, I run the command dotnet tool install -g nbgv (in a PowerShell window with admin rights). After this, in the root of my project, I run nbgv install (again, PowerShell with admin rights). I see a version.json file being created in the folder, but immediately after this I get an exception in my console. What am I doing wrong?

Unhandled exception:
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'NuGet.ProjectModel, Version=4.9.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. ---> System.IO.FileNotFoundException: Could not load file or assembly 'NuGet.ProjectModel, Version=4.9.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef, IntPtr ptrLoadContextBinder)
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingLoad(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
--- End of inner exception stack trace ---
at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, Boolean inherit)
at System.Attribute.GetCustomAttributes(MemberInfo element, Type type, Boolean inherit)
at System.Reflection.CustomAttributeExtensions.GetCustomAttributes[T](MemberInfo element)
at System.Diagnostics.StackTrace.TryResolveStateMachineMethod(MethodBase& method, Type& declaringType)
at System.Diagnostics.StackTrace.ToString(TraceFormat traceFormat)
at System.Exception.GetStackTrace(Boolean needFileInfo)
at System.Exception.ToString(Boolean needFileLineInfo, Boolean needMessage)
at System.Exception.ToString(Boolean needFileLineInfo, Boolean needMessage)
at System.CommandLine.Builder.CommandLineBuilderExtensions.g__Default|14_1(Exception exception, InvocationContext context)
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass14_0.<b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__5_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.CommandLine.Invocation.InvocationPipeline.Invoke(IConsole console)
at Nerdbank.GitVersioning.Tool.Program.MainInner(String[] args) in D:\a\1\s\src\nbgv\Program.cs:line 225
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Nerdbank.GitVersioning.Tool.Program.Main(String[] args) in D:\a\1\s\src\nbgv\Program.cs:line 75

@KalleOlaviNiemitalo
Copy link

NuGet.ProjectModel (assembly version 4.9.3.0) is referenced by NuGet.PackageManagement.dll (assembly version 4.9.3.0, AssemblyInformationalVersionAttribute "4.9.3+e5150f1e119e456e01c4f1e413213d392eda1c3a") in nbgv/3.4.231. NuGet.PackageManagement/4.9.3 depends on NuGet.Commands (>= 4.9.3), which depends on NuGet.ProjectModel (>= 4.9.3), so I think it's a bug in nbgv if the DLL is not included in the .NET tool package.

@B45man
Copy link
Author

B45man commented Aug 27, 2021

I (temporarily?) solved this by uninstalling nbgv:

dotnet tool uninstall -g nbgv

Then installing version 3.1.91:

dotnet tool install -g nbgv --ignore-failed-sources --version 3.1.91

Running nbgv install in the root folder now creates a version.json and Directory.Build.props file.

@KalleOlaviNiemitalo
Copy link

@B45man, which version of .NET SDK did you use for dotnet tool install -g nbgv?

@B45man
Copy link
Author

B45man commented Aug 27, 2021

I’m not sure @KalleOlaviNiemitalo, how do I check this?

@KalleOlaviNiemitalo
Copy link

I wanted to file an issue at https://github.com/dotnet/runtime/ for making StackTrace recover from missing assemblies but I'm not sure which version of the runtime was being used here.

@AArnott
Copy link
Collaborator

AArnott commented Aug 28, 2021

Duplicate of #588

@AArnott AArnott marked this as a duplicate of #588 Aug 28, 2021
@AArnott AArnott closed this as completed Aug 28, 2021
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

No branches or pull requests

3 participants