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

VSIX based analyzers don't work on adding a VSPackage item (.pkgdef) to VSIX project (VS2015 RTM) #7008

Closed
BrianBergh opened this issue Nov 24, 2015 · 6 comments

Comments

@BrianBergh
Copy link

After updating to RC1, create a new "Analyzer with Code Fix (NuGet + VSIX) project".
image

Create a simple OptionsPackage class (:Package) by adding a VSPackage item to the VSIX project.

image

Bonus info regarding RC1 (this bug also exists in the pre-RC)
In the RC1, i actually get this, when i try to add a VSPackage:
image

It doesn't matter if you choose the UserControl method, or if you use the build-in property converter method.

In this sample, i've added a usercontrol.

image

These are the VSIX properties:
image

Now, if you press F5 (or at least when i do), i get this error (from the VSPackage):

image

Resulting in this error in the log:

444
2015/11/23 20:17:32.463
Error
VisualStudio
CreateInstance failed for package [CCopOptionsPackage]
{921C5AE7-5515-4020-A281-4C16AC518882}


80131522
Could not load type 'CCop.CCopOptionsPackage' from assembly 'CCop, Version=1.0.5805.38057, Culture=neutral, PublicKeyToken=3058d244428cca12'.

Now, when I continue, I can see, that the analyzers doesn't work. I don't get any exceptions, but it seems like if the analyzers aren't even invoked at all.

image

So, no analyzers, and no options :/

Now, stop debugging.

Try disabling the VSIX property "Include assembly in VSIX container"
image

Now, F5 to debug again.

Still the same error dialog, and still no analyzers working (nor any options).

Even if i set all properties to false, I still can't make the analyzers work.

Now, try installing the VSIX package manually from the bin/debug folder:
At this point, the analyzers worked in VS2015 RTM, but still no luck in the Update 1 RC1.

Now, the options works (no error dialogs), but the analyzers still won't work:
image

Bonus info: I get this warning:
image

This is what the folder looks like:
image

I have no clue what dependency it talks about, as the VSIX installer should include any dependencies, but it seems that it doesn't.

Back to VS, i try to set all properties in the VSIX package to false:
I get the same result.

But, if i reference the Analyzer project output dll manually into my test project (Consoleapp), the analyzers gets invokes, and works great.
image

But i still get an odd warning at the bottom (from the VSIX package) that it can't find the referenced assembly?

@BrianBergh
Copy link
Author

To @mavasani

@mavasani
Copy link
Contributor

@BrianBergh Thanks a lot for filing the issue. I am going to verify your scenario on the latest Update1 bits and post an update here.

@Suchiman
Copy link
Contributor

Should be fixed, @DustinCampbell already saw this here DustinCampbell/CSharpEssentials#38 (comment)

@mavasani
Copy link
Contributor

@Suchiman There are couple of issues mentioned here:

  1. On VS2015 RTM - trying to add a .pkgdef + analyzer assembly to a VSIX project causes only one of them to work.
  2. On VS2015 Update1 RC - VSIX based analyzers don't work at all.

#2 was fixed by #6285 as you noted. This issue tracks investigating #1 - I'll modify the title accordingly.

@mavasani mavasani changed the title VSIX based analyzers doesn't work as expected in VS2015 Update1 RC1 VSIX based analyzers don't work when adding a VSPackage item (.pkgdef) to VSIX project (VS2015 RTM) Nov 24, 2015
@mavasani mavasani changed the title VSIX based analyzers don't work when adding a VSPackage item (.pkgdef) to VSIX project (VS2015 RTM) VSIX based analyzers don't work on adding a VSPackage item (.pkgdef) to VSIX project (VS2015 RTM) Nov 24, 2015
@mavasani mavasani added this to the 1.2 milestone Nov 25, 2015
@mavasani
Copy link
Contributor

mavasani commented Dec 1, 2015

@BrianBergh I investigated this further and confirmed that issue 1. repros on VS2015 RTM and VS2015 Update1 RTM. Below are the simple repro steps:

  1. Create a C# Analyzer + CodeFix project, say "Analyzer1".
  2. Right click on the VSIX project in solution explorer => Add New item => "Visual Studio Package", say "VSPackage1".
  3. Add an options grid to the project by following steps over here
  4. F5 => Tools => Options => Click on "My Category"

Got: Options grid throws a package load failure dialog and doesn't work.

---------------------------
Microsoft Visual Studio
---------------------------
The 'VSPackage1' package did not load correctly.

The problem may have been caused by a configuration change or by the installation of another extension. You can get more information by examining the file <%user%>\AppData\Roaming\Microsoft\VisualStudio\14.0Roslyn\ActivityLog.xml'.

Restarting Visual Studio could help resolve this issue.

Continue to show this error message?
---------------------------
Yes   No   
---------------------------

Root Cause: The name of the analyzer project is same as the name of the VSIX project (Analyzer1).

Details: When you add a pkgdef to your VSIX project, the VSIX project packages it in an assembly with the same name as the VSIX project. Now the pkgdef assembly and referenced analyzer assembly have the same name, causing only one of them to be packaged in the VSIX and hence both don't work.

Workaround: Right click on VSIX project => Project properties => Change "Assembly Name" of the VSIX to something else and repeat step 4 above. Both analyzer and options grid should work in VS2015 Update1 RTM.

We should fix our Analyzer + CodeFix template project to use different names for the VSIX project and analyzer project, so users don't run into this. Assigning it to @jmarolf to fix.

@mavasani mavasani assigned jmarolf and unassigned mavasani Dec 1, 2015
@BrianBergh
Copy link
Author

@mavasani
I have just tested this with my project, and I can confirm that this approach works for my project as well, after updating VS2015 to Update 1RTM. Thanks for the notification :)

@jmarolf jmarolf closed this as completed Dec 4, 2015
@jmarolf jmarolf removed their assignment Jan 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants