Git Product home page Git Product logo

resharper-nuget's Introduction

obsolete JetBrains project

resharper-nuget

This plugin for ReSharper adds support for NuGet references to ReSharper. It supports ReSharper 8.x, 7.1 and 6.1.

DEPRECATED

Please note that this plugin is now deprecated. The functionality has been rolled into the main product as of ReSharper 9.1. This repo is left as a sample (albeit slightly out of date).

What does it do?

ReSharper has a Context Action on undefined types that looks at assemblies referenced in other projects for that type. If it finds a match, it will add a reference to the assembly, and import the namespace, fixing up the undefined error.

However, ReSharper always adds the assembly as a file reference, even if the assembly is part of a NuGet package. This means NuGet's referencing is bypassed, and the packages.config file isn't updated, dependencies aren't installed, and things don't work when it's time to update the package.

This plugin makes ReSharper invoke NuGet when adding a reference to an assembly in a NuGet package.

How do I get it?

If you wish to just install a copy of the plugins without building yourself:

  • Download the latest zip file: resharper-nuget.1.2.zip
  • Extract everything
  • Run the appropriate batch file for your version of ReSharper, e.g. Install-NuGetSupport.7.1.bat for ReSharper 7.1, or Install-NuGetSupport.6.0.bat for ReSharper 6.0

How does it work?

From the end user's perspective, there is no noticeable user interface. When you use a type that lives in an assembly that is not part of the assemblies currently referenced, but is in an assembly referenced by other projects in the solution, ReSharper will mark the type as an error, and display the context action icon when the cursor is on the type name (the red light bulb). Pressing Alt-Enter displays the action "reference 'asm' and use 'Asm.Type'". This plugin hooks into that process. Selecting that action for an assembly referenced as part of a NuGet package will be installed by NuGet.

For example, if project Test1 adds a NuGet reference to the xUnit.net: extensions package, NuGet will also download the xUnit.net package, and extracts the files to the packages\xunit.1.9.1\lib\net20 and packages\xunit.extensions.1.9.1\lib\net20 folders. NuGet will then add a reference to xunit.extensions.dll and xunit.dll, and run any script files that are in the packages.

If you then add a new project to the solution, Test2, and before adding any references, try to use TheoryAttribute, ReSharper will mark that usage as an error. It also looks for any types called TheoryAttribte in any assembly that's known in the solution. It finds Xunit.Extensions.TheoryAttribute from xunit.extensions.dll being referenced by Test1, and offers a quick-fix red lightbulb for the usage of TheoryAttribute. When you hit alt-enter, you'll see a menu option that reads "reference 'xunit.extensions' and use 'Xunit.Extensions.TheoryAttribute'".

Without the plugin, ReSharper would now just add a reference to packages\xunit.extensions.1.9.1\lib\net20\xunit.extensions.dll file. With the plugin, ReSharper knows that this is a NuGet pacakge, and invokes NuGet to install xunit.extensions in the Test2 project. NuGet adds the references, updates the packages.config file, and also installs the dependency on the xunit package.

Building

To build the source, you need the ReSharper 7.1 SDK installed (ReSharper 6.1.1 support requires the ReSharper 6.1 SDK, which can be downloaded from the previous versions archive). Then just open the src\resharper-nuget.sln file and build.

Version

The current version is 1.2. It has been tested with Visual Studio 2012 and 2010, and supports ReSharper 7.1.1 and 6.1.1. See the ReleaseNotes wiki page for more details.

Contributing

Feel free to raise issues on GitHub, or fork the project and send a pull request.

Roadmap

Please see the Issues tab on JetBrains' GitHub page.

resharper-nuget's People

Contributors

citizenmatt avatar derigel23 avatar mrinaldi avatar thoemmi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

resharper-nuget's Issues

Nuget support for R# isn't updated in ReSharper 8.2

After launch Visual Studio I see notifications to update NuGet support for R#. I click yes and it seems that everything ok. But when I open VS another time I see notification to update plugin again.

I attached two images. Before.jpeg - before update and after.jpg after plugin update respectively. And when I open VS again I see before.jpg again.

after
before

----- system info ------
JetBrains ReSharper 8.2 Full Edition
Build 8.2.0.2160 on 2014-03-20T15:53:08

Licensed to: bla-bla-bla
Plugins: 3
#1. “Agent Mulder plugin for ReSharper” v1.1.2.0 by “Igal Tabachnik”
#2. “NuGet support for ReSharper” v1.3.0.35071 by JetBrains
#3. “Postfix Templates” v2.0.1.0 by “Shvedov Alexander”

Visual Studio 10.0.40219.1.

Copyright © 2003–2014 JetBrains s.r.o. All rights reserved.

Adds reference to bin folder when no-one is referencing a nuget package

  1. Given a solution with a single project which has a nuget package installed
  2. Build the project
  3. Remove the reference. The dll is still in the bin dir
  4. Close and reopen the solution
  5. Alt+Enter on the invalid code will offer to add a reference to the dll in the bin dir

Since no-one else is referencing the package, ReSharper doesn't know about the dll in the package dir, even though it's "installed" in the project. Instead, it only knows about the dll in the bin dir. The plugin doesn't join the dots to know that there is a dll in the package that would help.

Possible solutions:

  • Tell ReSharper about the dlls in packages - this would presumably require knowing how NuGet resolves the target framework folder, especially for PCL references
  • Deny adding a reference to a dll in a bin folder. This feels more like a fix that ReSharper should handle itself. Also, the interface doesn't really support denying adding a reference. We can (and do) fudge it though.

ReSharper references dlls in bin/debug

Fairly reliable way to reproduce:

  • Project A references a package assembly
  • Project B references the same package assembly
  • Build both, then delete the reference to the package assembly from project B
  • Close and reopen the solution, use the quick-fix to reference the assembly and import a type - this will most likely be the file from bin\debug

ReSharper keeps a list of each assembly it sees, and a list of file locations it's seen the assembly at. The problem is that the order of this list is important - the quick-fix adds a reference to the first location in the list. If that location is bin\debug, you get a bad reference. I can't see what's causing the ordering to collect bin\debug before the assemblies in the project references, but it's a fairly reproducible scenario.

ReSharper 8.0

I see only install scripts for ReSharper 6.1 and 7.1 in the latest download linked from the Release Notes. Is this also supported for Re# 8.0?!

Flag references to DLL's where a packaged DLL is available

It would be great to detect when a project is referencing a (non-package) DLL that is also available in a package. Would be particularly useful in cases where I might have updated one project to a new nuget version, but not another - I could end up mixing the DLL's in the output on build.

Not sure how much this might collide with actual use cases supported by NuGet where people may want to have several versions of a package installed side-by-side - however I cannot really imagine why somebody would intend to do so.

Support for R#9

Please release a new version with added support for R# 9

Many thanks, Michael

Fails to add packages with NuGet 2.2

Everything worked nicely with 2.1, now fails with 2.2.

Exception states it can't find the nuspec file because it repeats the package name in the path.

Keep getting update notification

I update nugget support for resharper several times but every time I boot up visual studio, it notifies me of an update. But the versions are the same.

constant update notification

The 'VSTS for Database Professionals' package did not load correctly - when using the plugin

Hi everyone,

Plugin seemed to work great but after re-opening a few of my solutions then visual studio 2010 complains that "The vsts for database professionals package did not load correctly''.

Tried a number of things to resolve it including running devenv with /resetpkgs but still happens..

Had to disable the plugin.

I am using resharper 7.1 and I installed the correct plugin.

This has happend on 2 machine with 2 different solutions.

Problem loading

Information about extension ReSharper.NuGet

Version: 1.4.1158.1070
Description: Adds support for NuGet references in ReSharper
Authors: JetBrains
Tags: NuGet
Dependencies: ReSharper (= 8.0 && < 8.3)
License: http://www.apache.org/licenses/LICENSE-2.0
Project: https://github.com/JetBrains/resharper-nuget/wiki

This extension contains: a Plugin

ExtensionManager (Info): Adding extension 'ReSharper.NuGet' 1.4.1158.1070 from 'Default' source
ExtensionPluginSource (Info): Discovering plugins from extension 'ReSharper.NuGet'
NuGetExtension (Info): Looking for 'plugins' files in the ReSharper.NuGet package folder at C:\Users\Dennis\AppData\Local\JetBrains\ReSharper\vAny\packages\ReSharper.NuGet.1.4.1158.1070
NuGetExtension (Info): The package contains no files in ReSharper\v8.2\vs12.0\plugins
NuGetExtension (Info): The package contains no files in VisualStudio\v12.0\vs12.0\plugins
NuGetExtension (Info): Found 1 files under ReSharper\v8.2\plugins
NuGetExtension (Info): The package contains no files in VisualStudio\v12.0\plugins
NuGetExtension (Info): The package contains no files in ReSharper\vAny\plugins
NuGetExtension (Info): The package contains no files in VisualStudio\vAny\plugins
NuGetExtension (Info): The package contains no files in DotNet\v1.0\plugins
NuGetExtension (Info): The package contains no files in DotNet\vAny\plugins
ExtensionPluginSource (Info): Discovered plugins 'NuGet support for ReSharper' from extension 'ReSharper.NuGet'
ExtensionPluginSource (Info): Adding 1 plugin(s) from extension 'ReSharper.NuGet'
ExtensionPluginSource (Info): Enabling plugin 'NuGet support for ReSharper' from extension 'ReSharper.NuGet'
ExtensionManager (Info): Enabling extension 'ReSharper.NuGet'
PluginLoader (Info): Plugin has 1 files under the C:\Users\Dennis\AppData\Local\JetBrains\ReSharper\vAny\packages\ReSharper.NuGet.1.4.1158.1070\ReSharper\v8.2\plugins\JetBrains.ReSharper.Plugins.NuGet.8.2.dll folder: “”.
PluginLoader (Error): The plugin “NuGet support for ReSharper” assembly file C:\Users\Dennis\AppData\Local\JetBrains\ReSharper\vAny\packages\ReSharper.NuGet.1.4.1158.1070\ReSharper\v8.2\plugins\JetBrains.ReSharper.Plugins.NuGet.8.2.dll with assembly name “JetBrains.ReSharper.Plugins.NuGet.8.2, Version=1.3.0.35071, Culture=neutral, PublicKeyToken=null” was denied loading because its short assembly name is the same as one of the already loaded assemblies of plugin “NuGet support for ReSharper” with assembly name “JetBrains.ReSharper.Plugins.NuGet.8.2, Version=1.3.0.35071, Culture=neutral, PublicKeyToken=null” and codebase C:\Users\Dennis\AppData\Local\JetBrains\ReSharper\vAny\packages\ReSharper.NuGet.1.4.1158.1070\ReSharper\v8.2\plugins\JetBrains.ReSharper.Plugins.NuGet.8.2.dll.
ExtensionsExternalAnnotationsFileProvider (Info): Discovering external annotations files for extension 'ReSharper.NuGet'
NuGetExtension (Info): Looking for 'annotations' files in the ReSharper.NuGet package folder at C:\Users\Dennis\AppData\Local\JetBrains\ReSharper\vAny\packages\ReSharper.NuGet.1.4.1158.1070
NuGetExtension (Info): The package contains no files in ReSharper\v8.2\vs12.0\annotations
NuGetExtension (Info): The package contains no files in VisualStudio\v12.0\vs12.0\annotations
NuGetExtension (Info): The package contains no files in ReSharper\v8.2\annotations
NuGetExtension (Info): The package contains no files in VisualStudio\v12.0\annotations
NuGetExtension (Info): The package contains no files in ReSharper\vAny\annotations
NuGetExtension (Info): The package contains no files in VisualStudio\vAny\annotations
NuGetExtension (Info): The package contains no files in DotNet\v1.0\annotations
NuGetExtension (Info): The package contains no files in DotNet\vAny\annotations
ExtensionsExternalAnnotationsFileProvider (Info): No external annotations files found for extension 'ReSharper.NuGet'
ExtensionSettingsLoader (Info): Discovering settings files for extension 'ReSharper.NuGet'
NuGetExtension (Info): Looking for 'settings' files in the ReSharper.NuGet package folder at C:\Users\Dennis\AppData\Local\JetBrains\ReSharper\vAny\packages\ReSharper.NuGet.1.4.1158.1070
NuGetExtension (Info): The package contains no files in ReSharper\v8.2\vs12.0\settings
NuGetExtension (Info): The package contains no files in VisualStudio\v12.0\vs12.0\settings
NuGetExtension (Info): The package contains no files in ReSharper\v8.2\settings
NuGetExtension (Info): The package contains no files in VisualStudio\v12.0\settings
NuGetExtension (Info): The package contains no files in ReSharper\vAny\settings
NuGetExtension (Info): The package contains no files in VisualStudio\vAny\settings
NuGetExtension (Info): The package contains no files in DotNet\v1.0\settings
NuGetExtension (Info): The package contains no files in DotNet\vAny\settings
ExtensionSettingsLoader (Info): No settings files files found for extension 'ReSharper.NuGet'

Looks like it is trying to load itself 2 times

Add installer

Add user-friendly installer. Not geek-friendly like existing one.

Flag references to wrong framework files

(Once we've figured out how to display an error in references - ReSharper currently only warns about source code issues...)

Warn when a project is referencing files from the wrong framework in a package, when there is a newer framework available. This is usually due to a project having been upgraded, but the packages not re-added.

E.g. a .net 2 project updated to .net 4 still referencing the net2 folder when there is a net40 folder. Or a wp8 project still referencing the wp7 files.

(This last example can cause issues with the BCL Async packages - http://youtrack.jetbrains.com/issue/RSRP-336161)

Tests for other ReSharper plugins fail when installed

Other ReSharper plugins are failing their tests when resharper-nuget is installed. This is because the ReSharper test environment tries to load plugins and the nuget plugin relies on a Visual Studio assembly. Since this isn't available when running in the test environment, the nuget plugin assembly fails to load and causes the tests to fail.

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.