NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 252 forks source link

[Bug]: Visual Studio Nuget Package Manager UI does not open if other extension is enabled #11636

Closed tonyhallett closed 2 years ago

tonyhallett commented 2 years ago

NuGet Product Used

Visual Studio Package Management UI

Product Version

Visual Studio: 2022 Enterprise / Possibly Professional/Communiy - multiple versions

Worked before?

No response

Impact

I'm unable to use this version

Repro Steps & Context

I am a contributor to a Visual Studio extension Fine Code Coverage that is built for Visual Studio 2019 and Visual Studio 2022.

Users of the 2022 extension are reporting the following behaviour.

FCC ( Fine Code Coverage ) and (NPMUI) Nuget Package Management UI working together no problem. For no known reason this changes With FCC enabled NPMUI no longer works. Disable FCC and NPMUI works.

The logs provided by the 3 users of FCC that have reported the issue are consistent in the error.

Here are the log entries from ActivityLog that are written when I try to open the NuGet Package Manager:

  <entry>
    <record>790</record>
    <time>2021/11/22 08:40:51.160</time>
    <type>Error</type>
    <source>NuGetPackage.ShowManageLibraryPackageForSolutionDialog</source>
    <description>XamlParseException - Provide value on &apos;System.Windows.Markup.StaticExtension&apos; threw an exception.</description>
  </entry>
  <entry>
    <record>791</record>
    <time>2021/11/22 08:41:20.206</time>
    <type>Error</type>
    <source>NuGetPackage.ShowManageLibraryPackageForSolutionDialog</source>
    <description>Exception - The component &apos;NuGet.PackageManagement.UI.PackageManagerControl&apos; does not have a resource identified by the URI &apos;/NuGet.PackageManagement.UI;component/xamls/packagemanagercontrol.xaml&apos;.</description>
  </entry>

I see this error when running VS in log mode, not sure if that means anything.

2149 2022/03/01 21:39:52.229 Error NuGetPackage.ShowManageLibraryPackageDialog Exception - The component 'NuGet.PackageManagement.UI.PackageManagerControl' does not have a resource identified by the URI '/NuGet.PackageManagement.UI;component/xamls/packagemanagercontrol.xaml'.

Comparing the two VS activity logs generated in each case, I can see the following in the log with FCC enabled that doesn't appear in with it disabled:

<entry> <record>2052</record> <time>2022/03/01 22:38:01.536</time> <type>Error</type> <source>NuGetPackage.ShowManageLibraryPackageDialog</source> <description>XamlParseException - Provide value on &apos;System.Windows.Markup.StaticExtension&apos; threw an exception.</description> </entry>

Verbose Logs

No response

erdembayar commented 2 years ago

@tonyhallett Thank you for filing this issue. But I was not able to repro this issue with latest VS 2022 Pro, not only I can open PMUI also I was able to install new package without issue.

image

Could you give us repro steps?

tonyhallett commented 2 years ago

Could you give us repro steps?

No. Nobody has noticed anything in particular that could have been the cause.

It has happended to me in the last 20 minutes believe it or not !

The first time I noticed it was in a UWP project ( that I ran no tests in ) - a project type that I rarely use.

Note that the Package Manager Console can be opened and that there is nothing reported in the Package Manager Output Window Pane.

Unfortunately game bar recording do not show the context menu otherwise I would post it.

tonyhallett commented 2 years ago

@erdembayar

If I fork the repo and build the vsix can I debug locally ?

Do you want to see my screen some time tomorrow ? I am in the UK.

erdembayar commented 2 years ago

@erdembayar

If I fork the repo and build the vsix can I debug locally ?

Which repo are you referring here?

Do you want to see my screen some time tomorrow ? I am in the UK.

Sorry, I'm afraid I can't attend it, I have other responsibilities too.

tonyhallett commented 2 years ago

If I fork the repo and build the vsix can I debug locally ?

Nuget

erdembayar commented 2 years ago

If I fork the repo and build the vsix can I debug locally ?

Nuget

Sure, you can. We have independent contributors. https://github.com/NuGet/NuGet.Client/blob/dev/CONTRIBUTING.md https://github.com/NuGet/NuGet.Client/blob/dev/docs/debugging.md

tonyhallett commented 2 years ago

Thanks for the links - the debugging link had the information for installing that I required. I will debug the commands and hopefully find a way to get back this odd behaviour.

donnie-msft commented 2 years ago

Debugging is a good suggestion. Just curious, do you test/debug your VSIX in the VS Experimental Instance? If you open NuGet PMUI in that Experimental VS, does the same error occur?

Another quick thing to check:

The component 'NuGet.PackageManagement.UI.PackageManagerControl' does not have a resource identified by the URI '/NuGet.PackageManagement.UI;component/xamls/packagemanagercontrol.xaml'.

This is the sort of error I've seen with assembly version issues/conflicts. I'd check any configs you may find here: C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\17.0_<some goo>\devenv.exe.config ...to see if the assemblies listed here for our NuGet extension makes sense (files exist at path, version # is expected, etc): Sample:

<dependentAssembly>
    <assemblyIdentity name="NuGet.PackageManagement.UI" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
         <codeBase version="6.2.0.75" href="c:\program files\microsoft visual studio\2022\preview\common7\ide\commonextensions\microsoft\nuget\NuGet.PackageManagement.UI.dll"/></dependentAssembly>

Also any assembly errors show up in ILDasm?

tonyhallett commented 2 years ago

@donnie-msft

Just curious, do you test/debug your VSIX in the VS Experimental Instance?

Indeed.

If you open NuGet PMUI in that Experimental VS, does the same error occur?

Unfortunately I do not have the issue on my machine. If it does reappear I will see if it occurs in the experimental instance.

I have version 6.0.1.1 of NuGet.PackageManagement.UI. I used Reflector to check the nuget dependencies and they all opened. I opened NuGet.PackageManagement.UI in ILDasm and there were no errors.

6.0.1.1 is a release candidate.... I will update visual studio when I get the opportunity.

donnie-msft commented 2 years ago

@tonyhallett I reached out to the VS Extensibility team, and their suggestion was to get a full heap dump. They said,

This is almost always the best first step, then one can look at what dlls are loaded / where they are loaded from. Generally, these things happen when extensions ship VS dlls (like say the NuGet one that is failing to load) and the ‘wrong’ one (from VS’ perspective) gets loaded, which can happen for a variety of reasons.

I'd suggest, the next time a contributor has a repro of this problem, in VS use the Help -> Report a Problem to submit a report. Be sure to reference this issue, and the issue in your repo, so we can see the context of we have in this thread. Make sure to include a DMP in that report and that it finishes uploading. For more information on doing that, see https://docs.microsoft.com/en-us/visualstudio/ide/how-to-report-a-problem-with-visual-studio?view=vs-2022

tonyhallett commented 2 years ago

@donnie-msft Thank you. I will inform the users of the extension.

cutty225 commented 2 years ago

I am one of the users of @tonyhallett FCC extension. As per instructions, I have reproduced the issue this morning and submitted a report via Visual Studio with DMP attached: https://developercommunity.visualstudio.com/t/NuGet-Package-Manager-prevented-from-ope/1684617

donnie-msft commented 2 years ago

@cutty225 Just took a look and replied. In short, the DMP is corrupted, and I could not reproduce the NuGet issue. Instead, your extension was not successfully loaded. My first guess is there's a broken MEF export in your extension. NuGet also uses an export for the Output Window in VS and implements an ILogger , so perhaps it's related to why NuGet is broken on your machine.

Error
<source>VisualStudio</source>
<description>SetSite failed for package [**OutputToolWindowPackage**]Source: &apos;Microsoft.VisualStudio.Composition&apos; Description: **Expected 1 export(s) with contract name &quot;ILogger&quot; but found 0 after applying applicable constraints.&#x000D;&#x000A;Microsoft.VisualStudio.Composition.CompositionFailedException: Expected 1 export(s) with contract name &quot;ILogger&quot; but found 0 after applying applicable constraints.**&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.GetExports(ImportDefinition importDefinition)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.GetExports[T,TMetadataView](String contractName, ImportCardinality cardinality)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.GetExport[T,TMetadataView](String contractName)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.GetExportedValue[T]()&#x000D;&#x000A;   at Microsoft.VisualStudio.ComponentModelHost.ComponentModel.GetService[T]()&#x000D;&#x000A;   at **FineCodeCoverage.Output.OutputToolWindowPackage**.&lt;InitializeAsync&gt;d__4.MoveNext()&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#x000D;&#x000A;   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#x000D;&#x000A;   at Microsoft.VisualStudio.Shell.AsyncPackage.&lt;&gt;c__DisplayClass20_0.&lt;&lt;Microsoft-VisualStudio-Shell-Interop-IAsyncLoadablePackageInitialize-Initialize&gt;b__1&gt;d.MoveNext()&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#x000D;&#x000A;   at Microsoft.VisualStudio.Services.VsTask.RethrowException(AggregateException e)&#x000D;&#x000A;   at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck)</description>
<guid>{4E91BA47-CD42-42BC-B92E-3C4355D2EB5F}</guid>
<hr>80131500</hr>
<errorinfo></errorinfo>
tonyhallett commented 2 years ago

@donnie-msft I had that Mef exception in the last couple of days during extension debugging. It did not matter what component I asked Vs for. Even ILogger with export having no imports. I cleared the Mef cache and the problem went away.

tonyhallett commented 2 years ago

@donnie-msft

@cutty225 has also cleared the MEF cache https://github.com/FortuneN/FineCodeCoverage/issues/213#issuecomment-1062293464 which may be a common resolution.

NuGet also uses an export for the Output Window in VS and implements an ILogger , so perhaps it's related to why NuGet is broken on your machine.

Seems unlikely to me ? I will fork the repo so I can search it efficiently.

Is there a method to get MEF to provide better logging ?

donnie-msft commented 2 years ago

Found this.. maybe a better approach than just deleting the folder.

The following file is created whenever VS MEF constructs its cache of MEF parts: %localappdata%\microsoft\visualstudio<instanceID>\ComponentModelCache\Microsoft.VisualStudio.Default.err This cache is replaced with each update of the MEF cache. Because most updates of the MEF cache are incremental, the log file can be incomplete, showing only issues found during the incremental update. To ensure that the log is complete, run these commands:

devenv /clearcache
devenv /updateconfiguration
donnie-msft commented 2 years ago

Also using these MEF Analyzers may be helpful to identify code issues: https://github.com/microsoft/vs-mef/blob/main/doc/analyzers/index.md

tonyhallett commented 2 years ago

@donnie-msft Thanks

nkolev92 commented 2 years ago

@donnie-msft Do you think there's still something to investigate on NuGet end?

donnie-msft commented 2 years ago

@nkolev92 We don't know either way until we receive a DMP and someone takes a look at that.

nkolev92 commented 2 years ago

Thank you reporting this issue. At this point we do not have enough information to continue investigating the issue. Please feel free to comment or open a new issue if needed.

bstordrup commented 1 year ago

I can reproduce the error on my Visual Studio 2022 17.4.1 installation. With Fine Code Coverage activated, I get this entry in the AcivityLog.xml file, and PMUI does not show.

  <entry>
    <record>518</record>
    <time>2022/11/28 20:55:15.073</time>
    <type>Error</type>
    <source>NuGetPackage.ShowManageLibraryPackageForSolutionDialog</source>
    <description>XamlParseException - Provide value on &apos;System.Windows.Markup.StaticExtension&apos; threw an exception.</description>
  </entry>

Version of Fine Code Coverage is 1.1.188

If I disable Fine Code Coverage extension, then the above entry is not written ti ActivityLog, and the PMUI shows up as expected.

bstordrup commented 1 year ago

Reported as new issue: https://developercommunity.visualstudio.com/t/Nuget-package-manager-not-opening/10215434

jeffkl commented 1 year ago

@bstordrup Are there exact steps I can follow to reproduce the issue? I installed FCC, ran tests with code coverage, loaded the FCC tool window and then loaded Manage Packages for Solution without issues.

image

bstordrup commented 1 year ago

@jeffkl Not sure. As I demonstrated in the screen record, all I did was to enable the FCC extension, and then the Package Management UI would no longer load. Disabling it made the PMUI work again. That were the steps provided.

Did any of the files provided in by bug report that was closed provide any further information around Visual Studion?

jeffkl commented 1 year ago

Did any of the files provided in by bug report that was closed provide any further information around Visual Studion?

The feedback ticket had the recording of you enabling the FCC extension and then Package Manager not loading. I think the Activity Log also shows the error you had included in the main description. What I'd really like to do is repro it on my machine and then look at it under the debugger.