Coder Social home page Coder Social logo

ricosuter / nugetreferenceswitcher Goto Github PK

View Code? Open in Web Editor NEW
208.0 208.0 69.0 1.2 MB

Visual Studio extension to switch between NuGet and project references.

Home Page: http://nugetreferenceswitcher.org

License: Microsoft Public License

C# 98.95% Batchfile 1.05%

nugetreferenceswitcher's Introduction

nugetreferenceswitcher's People

Contributors

kwalitykoder avatar lucasrossoni avatar ricosuter avatar twenzel avatar waldfee 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  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

nugetreferenceswitcher's Issues

Port to Visual Studio for Mac (previously Xamarin Studio)

This is an amazing extension, but when I am working on my Mac side (which is pretty much when Im not developing specifically for Windows) I use Visual Studio for Mac. It would be great to have this same functionality in VS for Mac.

The parameter is incorrect

image

I have a single project I'm switching references on. If I open my solution, go to Tools->Switch references, I see the project path selected. Clicking "Switch" produces the error you see.
If I click on "Select project to add" first and re-select the same project, the switch works fine.
This error is consistent on the new 1.3 release.

NuGetReferenceSwitcher not detecting NuGets when packages folder is /Packages (VS 2017)

I have some NuGet Packages used in two solutions.
Solution #1 - all the projects referencing the NuGets are directly under the Solution.
NuGetReferenceSwitcher lets me convert the NuGet Refs to local projects.

Solution #2 - all the projects are grouped into folders under the solution.
The projects reference the same NuGet packages as Solution #1.
This time NuGetReferenceSwitcher doesn't detect the same NuGet refs, so I can't convert the NuGet Refs to local projects.


The issue is in ProjectModel.LoadReference():

        private void LoadReferences()
        {
               :      :     :
                if (vsReference.Path.Contains("/packages/") || vsReference.Path.Contains("\\packages\\"))
                    NuGetReferences.Add(reference);
            }
        }

Our projects in Solution #2 use /Packages not /packages. A ToLower() call would fix this issue.


Can confirm using

if (vsReference.Path.ToLower().Contains("/packages/") || vsReference.Path.ToLower().Contains("\\packages\\"))
   NuGetReferences.Add(reference);

fixes the issue. This may also be the root cause of NuGet references not being detected within projects for other users too.


Obviously instead of just assuming that the NuGet packages folder is called /packages or /Packages, the best approach would be to for NuGetReferenceSwitcher to get the path directly from its definition inside the nuget.config file.

<settings> <repositoryPath>{some path here}</repositoryPath> </settings>

VS2022 support

Would be awesome to see VS2022 support for this extension :-)

Support searching for Nuget package

It would be nice if I can search for a particular NuGet package in the Switch to project references tab because it's not easy to scroll and find a NuGet package when the project has a lot of them.

Error: "Specified method is not supported" in VS 2017

I have an Asp.Net Core project referencing my own lib, which is dependent on another library. I have all 3 projects opened in one solution, referencing the dependencies via NuGet. When I try to switch from NuGet to Project reference, I get the following error:

"Specified method is not supported."

Please let me know what I am missing.

Thanks.

Spaces in Path confuse the Reference Switcher, when switching to a formerly saved project

The path of a project to reference is C:\blub blub\MyProject.csproj
The first switch from package to project is successful. Switching back works.
Once you now try to switch again into the project (without selecting the project again), the path is: C:\blub%20blub\MyProject.csproj.

As consequence, the project can not be loaded and the switching does fail.

Thanks a lot, guys!

retsore to nuget packages fails if exact version was not found

when I try reverting projects back to references and the reference was already removed due to another partial solution, the project references remains (message states replacement is skipped).

When restoring the package folder and trying again, there is no trace of leftovers that need replacing.

Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

Situation: I have one project switched successfully
Action: I attempt to switch another, using "Add new project to solution", then hitting "Switch to project references"
Result: Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)) popup. I hit Ok and the switcher closes but the project isn't switched.
Setup: VS 2013 Premium Update 5, reference switcher version 1.7

Nothing noteworthy in the VS log (see below). Is there anywhere else I can look for clues?

1067 2016/01/27 10:14:17.672 Information VisualStudio Entering function CVsPackageInfo::HrInstantiatePackage {87A7B0E9-E41C-47C8-953C-B81650401EDB} 1068 2016/01/27 10:14:17.673 Information VisualStudio Begin package load [NuGetReferenceSwitcherPackage] {87A7B0E9-E41C-47C8-953C-B81650401EDB} 1069 2016/01/27 10:14:17.676 Information VisualStudio End package load [NuGetReferenceSwitcherPackage] {87A7B0E9-E41C-47C8-953C-B81650401EDB}

Visual Studio 2022

Will this project be updated to support Visual Studio 2022? We still use this package for our older projects.

Does not work if packages path is modified using Nuget.config

I use Nuget.config to change the path where packages are stored. The extension fails to detect any nuget references. I just had casing differences in the folder name and relocated it outside the solution folder. It should use packages.config/project.json file to detect nuget references rather than looking at the references in project file.

Keyboard Input Inconsistent related to "an operation is blocking user input"

I've noticed that when I use the tool, I get in a state where certain types of input are no longer possible.

For example, I'll be able to type characters but not cut & paste or be unable to delete characters.

I've also noticed that this message is displayed consistently when I close visual studio after getting into this state:

image
Text of image says: "Microsoft Visual Studio has detected that an operation is blocking user input. This can be caused by an active modal dialog or a task that needs to block user interaction. Would you like to shut down anyway?"

Visual Studio 2022

Will this project be updated to support Visual Studio 2022? We still use it in our older projects.

Unobtrusive callee registration

Add support for an unobtrusive callee registration using [namespace].[type].[methodname] for generating the procedure name.

This would enable easy addition of services/callees that are defined in external projects or packages, without having to implement and maintiain any adaptor code.

Support for Nuget.config with repositoryPath

If we have a nuget.config file with a repositoryPath for a directory than is not named "packages" the nuget package references are not recognized as nuget package references and you are not presented with the option to change them to project references.

Here is a Nuget.Config that I have for my solution:

. .

I see in the ProductModel.cs (LoadReferences method) the Path of the vsReference (e.g. does it contain "\packages" in the path) is used to determine if a reference is from a nuget package. If a directory other than "packages" (the default) is used then you don't get the option to switch those references to project references. A simple option would be to let the user specify a regular express or at least a string to use. Another more complicated option would be to search for a nuget.config and see if it has a repositoryPath.

Filter for Projects in My SLN

How about a filter for only the projects in my SLN? Having the ability to switch everything is great but I wouldn't think is the common case, no?

I'm happy to take a stab at it if you're open a PR like this; let me know!


Example: hide red boxes, show green box:

image

NuGetReferenceSwitcher not reverting Project files back to their original state (VS 2017)

Within a Project, if I use NuGetReferenceSwitcher to switch from a NuGet to a Project Reference for NuGet Package X, and then use NuGetReferenceSwitcher to revert back to the NuGet reference, the .csproj file has an extra line added immediately following the <ItemGroup> ,<Reference Include="X"> nodes as follows:

<SpecificVersion>False</SpecificVersion>

I would expect the csproj file to remain completely unchanged after reverting back to the original NuGet package reference.


Coding fix was to modify ProjectModel.AddReference() to reset the SpecificVersion flag to true.

                // ReSharper disable once SuspiciousTypeConversion.Global
                if (_vsProject.References.Add(assemblyPath) is Reference4 reference)
                {
                    reference.SpecificVersion = true;
                }

where Reference4 is a new Interface I created following the instructions here

Setting the properties of a reference programmatically

VS2017 Support

It would be super nice if this could be updated for VS2017!

[Feature Request] Cake plugin for switching references

Could these functions be wrapped into a cake package?

We have some projects shared across various apps. Working on the projects it is much easier to dev with local references, but for the CD pipeline to not deploy every single app on a commit it would be nicer to be able to switch the references automatically during the build. I've done a lot of searching but can't find anything that comes close. Cake.NuGet can install a new reference, but there doesn't seem to be anything that will remove an existing ref from a project

Ability to switch to dll file path instead of project reference

Hi.

Thank you for NuGetReferenceSwitcher.

I'd like to request the ability to switch to a dll file path instead of a project reference.

For example, I'd like to be able to test a dll built from a project, but don't want to add the project to the current solution. And so I just want to reference "..\Common\MySharedDependency\bin\Release\MySharedDependency.dll".

Thank you.

Log or a more verbose output

In my Visual Studio 2015, the NuGet Reference Switcher extension is not working. And there's no errors. It might have been usefull to have some output. We do have about 40 projects in our solution and a couple of hundred NuGet references.

untitled

Error while attempting to switch reference to project

I'm trying to switch a particular assembly, Xamarin.Forms.Platform.UAP, to a project, so that I can debug into it. The source for this assembly is part of a public github repo.

I followed these steps:

  1. Cloned the Xamarin.Forms repo at https://github.com/xamarin/Xamarin.Forms
  2. Built the Xamarin.Forms and Xamarin.Forms.Platform.UAP projects in the cloned solution.
  3. To my own solution, added the external Xamarin.Forms.Platform.UAP project. At this point this project is part of my solution as well as the Xamarin.Forms solution.
  4. Opened Nuget Reference Switcher in my solution, and edited the entry for Xamarin.Forms.Platform.UAP to point to the above project.

At this point, this error occurs:

This reference cannot be removed from the project because it is always referenced by the compiler.

Any idea what's going on?
Thanks!

Add support for new MSBuild .csproj format

Could not load project NewProjectFormat
(new MSBuild .csproj are not supported, unload them first):

System.NullReferenceException: Object reference not set to an instance of an object.

   at NuGetReferenceSwitcher.Presentation.Models.ProjectModel.LoadReferences()
   at NuGetReferenceSwitcher.Presentation.ViewModels.MainDialogModel.GetAllProjects(IEnumerable`1 objects)

Package not loading correctly, version 1.5 from extension gallery

image

Shown when clicking the menu option to switch packages. Digging through ActivityLog I found this:

  <entry>
    <record>1147</record>
    <time>2015/11/24 18:56:34.042</time>
    <type>Information</type>
    <source>VisualStudio</source>
    <description>Begin package load [NuGetReferenceSwitcherPackage]</description>
    <guid>{87A7B0E9-E41C-47C8-953C-B81650401EDB}</guid>
  </entry>
  <entry>
    <record>1148</record>
    <time>2015/11/24 18:56:34.081</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>CreateInstance failed for package [NuGetReferenceSwitcherPackage]</description>
    <guid>{87A7B0E9-E41C-47C8-953C-B81650401EDB}</guid>
    <hr>80070002</hr>
    <errorinfo>Could not load file or assembly 'Microsoft.VisualStudio.Shell.12.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.</errorinfo>
  </entry>
  <entry>
    <record>1149</record>
    <time>2015/11/24 18:56:34.081</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>End package load [NuGetReferenceSwitcherPackage]</description>
    <guid>{87A7B0E9-E41C-47C8-953C-B81650401EDB}</guid>
    <hr>80004005 - E_FAIL</hr>
    <errorinfo>Could not load file or assembly 'Microsoft.VisualStudio.Shell.12.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.</errorinfo>
  </entry>

Possibly a bad reference?

Simple mode

Great plugin, but having to manually select projects every time you want to switch is really tedious.

All I need is a 'simple mode' that:

  • for every project p in the solution s
  • for every reference r in p
  • if s contains a project q that builds r then switch r in p to q.

Files Leftover After Switching Back To Nuget Packages

After changing back to using nuget packages from projects, there are two files being left in the directory that are no longer needed:

  • *.nugetreferenceswitcher
  • *.previous.nugetreferenceswitcher

This is also causing a tag to be removed from the csproj file and a to be added, and this is not reversed when switching back to nuget packages from projects.

Would it be possible to internally create a git "feature" branch on the solution being edited when using this utility so that when project references are switched back to nuget packages then everything can be rolled back?

I would be willing to work in this change myself.

ReferenceSwitcher as a tool to facilitate partitioned solutions

I'm looking to split huge VS solution to multiple smaller "partial" solutions. Partial solutions would build separate components (in a form of one or multiple NuGet packages) and Master solution would assemble them together. Partial solutions also tend to reference projects from other partial solutions.
Normally developers only load one partial solution they work on and expect all other components to be available as NuGets to accelerate local dev build. But occasionally developers are interested to load more than one code area and have some NuGets in their partial solution replaced with the references to the actual projects.

Your reference switcher is the closest thing I could find to make it happen, but it misses a couple important usability points.

  1. We use more than hundred external NuGet packages, which we never going to switch to project references. Would be great to exclude those from UI based on some criteria or simple configuration file.
  2. When NuGet get replaced with project references it usually means that the whole another partial solution is switched, so instead of NuGet by NuGet control it would be much more effective to switch those replacements on and off for some logical GROUPS of NuGet packages, again probably taken from configuration.

Does it makes sense?

Thank you!
Konstantin

FSharp support

Hi,

i just added *.fsproj to the open project dialog in order to support fsharp projects. unfortunately i got a null exception (in a message box) when trying to switch to projects in my rather big project.

Should FSharp support be as simple as this? Do you have any tips how i can debug the vsx in order to add proper fsharp support?

NuGetReferenceSwitcher throws if it encounters a new style PackageReference in a csproj

`<ItemGroup> <PackageReference Include="Newtonsoft.Json" Version="8.0.3" />

causes any other Nuget Refs to be skipped in a project due to throwing an exception.


Fix (which worked for me) is to add an extra line of code to ensure vsReference.Path is not null or empty before checking to see if its value contains /packages.

    private void LoadReferences()
    {
        References = new ExtendedObservableCollection<ReferenceModel>();
        NuGetReferences = new ExtendedObservableCollection<ReferenceModel>();

        foreach (var vsReference in _vsProject.References.OfType<Reference>())
        {
            var reference = new ReferenceModel(vsReference);
            References.Add(reference);

            if (!string.IsNullOrWhiteSpace(vsReference.Path))       // fix
            {
                if (vsReference.Path.ToLower().Contains("/packages/") || vsReference.Path.ToLower().Contains("\\packages\\"))
                    NuGetReferences.Add(reference);
            }
        }
    }

Error HRESULT E_FAIL has been returned from a call to a COM component.

Upon switching from Project references to Nuget references.

image

Error occurred looking for one of our internal custom packages:
"C:\src\vso\Ganon\master\packages\Iro.Cache.1.0.2744.372\lib\net451\Iro.Cache.dll"

Error code was: -2147467259

So my first guess is it is trying to add back references that don't exist anymore.

Note that this happened in the experimental hive so in theory no other plug ins should be affecting yours.

Stack Tace:
System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
at VSLangProj.References.Add(String bstrPath)
at NuGetReferenceSwitcher.Presentation.Models.ProjectModel.AddReference(String assemblyPath) in c:\src\Open\NuGetReferenceSwitcher-master\src\NuGetReferenceSwitcher.Presentation\Models\ProjectModel.cs:line 101
at NuGetReferenceSwitcher.Presentation.ViewModels.MainDialogModel.b__1a() in c:\src\Open\NuGetReferenceSwitcher-master\src\NuGetReferenceSwitcher.Presentation\ViewModels\MainDialogModel.cs:line 175
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at MyToolkit.Mvvm.ViewModelBase.<>c__DisplayClass6.<b__5>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at MyToolkit.Mvvm.ViewModelBase.<RunTaskAsync>d__01.MoveNext()

NuGetReference Switcher is blocking VS Input

Hello,

when I use the NuGet Reference Switcher in VS 2013 newest Updates installed inkluding Resharper 9.2.x. then after opening the Switcher Window and Applying a switch after that all shortcuts in VS are blocked I can't debug with F5 and so on. And when I want to close VS the following message shows up. "The userinput is blocked, .... by a active modal window or a task ...."

image

Private and SpecificVersion references

Glad to find such handy extension, thank you!

This is a crosspost from my comment on Visual Studio gallery.

I've did a quick forward and back test - switched Nuget reference to project reference and restored it using the extension. However it's easily discoverable via git diff that original Nuget reference was not restored in full: it used to have tag set to "True" and didn't have tag, but after the test it lacks tag and instead has False. Preserving original state of the reference is a key for successful using of this extension, could you address this?

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.