-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Ensure GitHub.TeamFoundation.15 MEF assembly is always installed on Visual Studio 2017 #1875
Conversation
Don't specify a target Visual Studio version for the GitHub.TeamFoundation.15 MEF assembly. Specifying a TargetVersion was causing it to sometimes incorrectly be excluded when installed on some Visual Studio 2017 versions. We can leave TargetVersion on the GitHub.TeamFoundation.14 MEF assembly because this attribute isn't supported on Visual Studio 2015 and we do want it excluded on Visual Studio 2017. This is a workaround for #1859.
Sometimes servicehub's version is used (currently ~1.3) when installing for Visual Studio 2017. If the VS version is reported as 1.x, assume we're installing for Visual Studio 2017.
22ddfc7
to
d171790
Compare
@@ -31,6 +31,8 @@ | |||
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="GitHub.Services.Vssdk" Path="|GitHub.Services.Vssdk|" /> | |||
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="GitHub.TeamFoundation.14" TargetVersion="[14.0,15.0)" Path="|GitHub.TeamFoundation.14|" /> | |||
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="GitHub.TeamFoundation.15" TargetVersion="[15.0,16.0)" Path="|GitHub.TeamFoundation.15|" /> | |||
<!-- Sometimes servicehub's version is used (currently ~1.3) when installing for Visual Studio 2017. If the version is 1.x, assume we're installing for Visual Studio 2017. --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure it's always servicehub's version that's being used, or is it just a random assembly that's loaded into the process? If the latter, then this won't fix the problem I guess...
Might it be best to just remove the version check and fall back to MEF erroring out as before? This is what we're doing for 2015 after all, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing the issue is that the version of vs_installerservice.exe
is being used (which is 1.3.x
) rather than VSIXInstaller.exe
(which is 15.7.x
).
I'd like to find out when servicehub's version is being used so we can test the proposed fix. Hopefully @dgriffen will be able to point us in the right direction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version is actually the version of the VSDetouredHost
which can be found in Common7\ServiceHub\Hosts\ServiceHub.Host.CLR.x86\
The reason this happens is that the VSDetouredHost loads a copy of the extension manager which may try to write to the extensions cache.
This fix should work but you'll want to test it to make sure you don't see the issue popping up still. I don't know enough about why you started using the target versions to say if this approach is better than just falling back to always attempting to load it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know enough about why you started using the target versions to say if this approach is better than just falling back to always attempting to load it.
The problem was that the MEF log ended up looking this this when the extension installed normally. This made diagnosing MEF issues for our own and other extensions problematic (you needed to know which exceptions to ignore in order to find any genuine issues).
The reason this happens is that the VSDetouredHost loads a copy of the extension manager which may try to write to the extensions cache.
When should I expect ServiceHub.VSDetouredHost.exe
to run? I'm hoping I can simply delete the component cache and then do whatever causes it to run?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When should I expect ServiceHub.VSDetouredHost.exe to run?
The timing is tricky and I was never able to reliably produce a cache that wouldn't get detected as invalid by the next launch of VS. VSDetouredHost
runs whenever someone requests a servicehub service that is not installed in the Common7\ServiceHub\Services
. The most common time for this is project load. After you get it to regenerate the cache you will need to shutdown VS and delete the ComponentModelCache
folder to trigger it to regenerate from the broken state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dgriffen, thanks. I've added How to repro
and How to test
sections to the PR. I'm able to trigger it relatively consistently, even it this isn't exactly what is happening in the wild.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a hack, but it seems to fix the problem until VS gets a bugfix. 👍
From @meaghanlewis
Merging... |
What's the issue
Specifying a
TargetVersion
was causing theGitHub.TeamFoundation.15
MEF assembly to sometimes incorrectly be excluded when installed on Visual Studio 2017 (see #1859).@dgriffen said:
What this PR does
Assuming this issue is fixed in 2019, we can assume that when the version is reported as
1.x
(instead of15.x
) we're installing for Visual Studio 2017. Specifying a version range isn't supported when installing for Visual Studio 2015, so this isn't an issue there.How to repro
GitHub
andTeam Explorer
panes closed)%USERPROFILE%\AppData\Local\Microsoft\VisualStudio\15.0_xxxxxxxx
(where
15.0_xxxxxxxx
is a unique name corresponding to the instance of Visual Studio you're running)ComponentModelCache
Extensions\extensions.en-US.cache
ServiceHub.VSDetouredHost.exe
View > Other Windows > GitHub
. Expect nothing to happen.The extensions cache (
extensions.en-US.cache
) is now corrupted. 🎉 😭 The only way to fix it is to deleteExtensions\extensions.en-US.cache
andComponentModelCache
and relaunch Visual Studio.How to test
Following on from
How to repro
...How to repro
Phew! 🤞
Related
Fixes #1859 Corrupt extension cache and missing MEF exports
Fixes #1826 GitHub Extension broken with VS 15.7.6
Fixes #1810 SetSite failed for the package [GitHubPackage], VS 15.8 Preview 4/5
Fixes #1812 Error On Project Load