ricosuter / nugetreferenceswitcher Goto Github PK
View Code? Open in Web Editor NEWVisual Studio extension to switch between NuGet and project references.
Home Page: http://nugetreferenceswitcher.org
License: Microsoft Public License
Visual Studio extension to switch between NuGet and project references.
Home Page: http://nugetreferenceswitcher.org
License: Microsoft Public License
We use own Nuget package sources and can not use this tool for switch between private Nuget plugin and project .
Can we use this tool with another package sources?
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.
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.
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>
Same exact issue in Visual Studio 2015 Update 3
[Here is the previously closed issue for VS 2013](Keyboard Input Inconsistent related to)
Would be awesome to see VS2022 support for this extension :-)
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.
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.
Could this code be refactored to work with MSBuild only, embedded within a custom DevOps (TFS) extension? I'm curious how much it requires of Visual Studio capabilities vs. standalone MSBuild.
It look like it doesn't find any nugets in "Switch to Project references" tab...
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!
It would be helpful to support the new Visual Studio 2019.
When selecting "remove projects" and the project is already removed, this gives an object not set exception, this should the just skip the removal step instead of the error.
DEFENSIVE PROGRAMING 101
Upgdade this extension to work in Visual Studio 2022
Docs - Update a Visual Studio extension for Visual Studio 2022
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.
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 InformationCool to have this support *.xproj files as well.
Alternatively, #17 would also work as a nice workaround for now.
Will this project be updated to support Visual Studio 2022? We still use this package for our older projects.
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.
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:
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?"
Hi,
When selecting a project can you please remove the open dialog filter of .csproj and .vbproj as I use vcxproj and I cannot import it
Thanks
Will this project be updated to support Visual Studio 2022? We still use it in our older projects.
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.
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.
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
It would be super nice if this could be updated for VS2017!
I am working in a ASP.NET project with 8 nugets installed but the switcher just shows 4 of them(these are also used in a class library inside the same solution)
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
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.
I would like to install the extension on VS 2022
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:
Xamarin.Forms
and Xamarin.Forms.Platform.UAP
projects in the cloned solution.Xamarin.Forms.Platform.UAP
project. At this point this project is part of my solution as well as the Xamarin.Forms
solution.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!
It seems that key-down closes the OpenFileDialog and key-up closes the dialog. This can be a bit annoying when you have to add multiple projects and suddenly dialog is closed and you need to start again.
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)
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?
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:
p
in the solution s
r
in p
s
contains a project q
that builds r
then switch r
in p
to q
.After changing back to using nuget packages from projects, there are two files being left in the directory that are no longer needed:
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.
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.
Does it makes sense?
Thank you!
Konstantin
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?
`<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);
}
}
}
When I switch back to NuGet references, I get the error Project unavailable. If I opt not to remove projects when switching, I don't get the error message.
Upon switching from Project references to Nuget references.
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__0
1.MoveNext()
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 ...."
It would be great if it was possible to, instead of adding a project the the solution, to just tell it to use a specific dll file instead of the nuget package, no matter where the dll file is located.
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?
I have projects with many packages, and finding them in a large list can be time consuming.
Happy to implement if you're willing to take the feature.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.